The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.
TypeScript ai-receptionistanswering-serviceappointment-bookinglivekitlocal-firstmcpopen-sourceself-hostedsiptelephonytypescriptvoice-agentvoice-ai
import { afterEach, beforeEach, expect, test, vi } from 'vitest'
import { canOpenInDesktop, desktopLink, desktopLinkForPageLoad, stayInBrowser } from './openInDesktop.ts'
// The tests run without a DOM: a window with only the session storage this needs.
const session = new Map<string, string>()
beforeEach(() =>
vi.stubGlobal('window', {
sessionStorage: {
getItem: (k: string) => session.get(k) ?? null,
setItem: (k: string, v: string) => session.set(k, v),
},
}),
)
afterEach(() => {
session.clear()
vi.unstubAllGlobals()
})
const location = { origin: 'https://app.linedesk.ai', pathname: '/', search: '', hash: '#call/abc' }
const fromEmail = { location, navigation: 'navigate', referrer: '' }
test('a page from an email goes to the desktop app when the setting is on', () => {
expect(desktopLinkForPageLoad(fromEmail, true)).toBe('linedesk://open/#call/abc')
expect(desktopLinkForPageLoad(fromEmail, false)).toBeNull()
})
test('reloads, Linedesk’s own links and the bare start page stay in the browser', () => {
expect(desktopLinkForPageLoad({ ...fromEmail, navigation: 'reload' }, true)).toBeNull()
expect(desktopLinkForPageLoad({ ...fromEmail, navigation: 'back_forward' }, true)).toBeNull()
expect(desktopLinkForPageLoad({ ...fromEmail, referrer: 'https://app.linedesk.ai/#inbox' }, true)).toBeNull()
expect(desktopLinkForPageLoad({ ...fromEmail, location: { ...location, hash: '' } }, true)).toBeNull()
expect(desktopLinkForPageLoad({ ...fromEmail, referrer: 'https://mail.google.com/' }, true)).toBe(
'linedesk://open/#call/abc',
)
})
test('"Open here instead" keeps this tab in the browser', () => {
stayInBrowser()
expect(desktopLinkForPageLoad(fromEmail, true)).toBeNull()
})
test('only the start page with a page is a link for the app', () => {
expect(desktopLink({ pathname: '/', search: '?ws=1', hash: '#call/x' })).toBe('linedesk://open/?ws=1#call/x')
expect(desktopLink({ pathname: '/app-sign-in', search: '', hash: '#x' })).toBeNull()
})
test('only browsers on a Mac or a Windows PC', () => {
const mac = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 Chrome/142 Safari/537.36'
expect(canOpenInDesktop({ userAgent: mac, maxTouchPoints: 0 })).toBe(true)
expect(canOpenInDesktop({ userAgent: mac, maxTouchPoints: 5 })).toBe(false) // an iPad
expect(canOpenInDesktop({ userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64)', maxTouchPoints: 0 })).toBe(true)
expect(canOpenInDesktop({ userAgent: 'Mozilla/5.0 (Linux; Android 15)', maxTouchPoints: 5 })).toBe(false)
})