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 { describe, expect, it } from 'vitest'
import { outboundCallIdOf } from '../outbound/model.ts'
import { DIALOG_PLACES, dialogOf, hasFlag, withFlag } from './dialogAddress.ts'
import { contactIdOf, parseHash } from './useRoute.ts'
describe('dialogs with an address', () => {
it('each lies on a page the router knows, and is not a record of that page', () => {
for (const [place, page] of Object.entries(DIALOG_PLACES)) {
expect(dialogOf(`#${place}`), place).toBe(place)
expect(dialogOf(`#${place}?help`), place).toBe(place)
const at = parseHash(`#${place}`)
expect(at.known, place).toBe(true)
expect(at.route, place).toBe(page.split('/')[0])
expect(place.startsWith(`${page}/`), place).toBe(true)
expect(contactIdOf(`#${place}`), place).toBeNull()
expect(outboundCallIdOf(`#${place}`), place).toBeNull()
}
expect(dialogOf('#contacts/ct_1')).toBeNull()
expect(dialogOf('#contacts')).toBeNull()
expect(contactIdOf('#contacts/ct_1')).toBe('ct_1')
})
it('the shortcuts flag goes on and off any address and keeps the rest', () => {
expect(withFlag('#calls', 'help', true)).toBe('#calls?help')
expect(withFlag('#calls?q=leak', 'help', true)).toBe('#calls?q=leak&help')
expect(withFlag('#calls?q=leak&help', 'help', true)).toBe('#calls?q=leak&help')
expect(withFlag('#calls?q=leak&help', 'help', false)).toBe('#calls?q=leak')
expect(withFlag('#insights?help&period=7d', 'help', false)).toBe('#insights?period=7d')
expect(withFlag('#contacts/ct_1?help', 'help', false)).toBe('#contacts/ct_1')
expect(hasFlag('#calls?q=help', 'help')).toBe(false)
expect(hasFlag('#calls?q=x&help', 'help')).toBe(true)
// The page under the flag is still the page.
expect(parseHash('#calls/done?help')).toMatchObject({ route: 'calls', tab: 'done', known: true })
expect(parseHash('#calls?q=leak&help')).toMatchObject({ search: 'leak', known: true })
})
})