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 type { Call } from '@linedesk/db/types'
import { expect, test } from 'vitest'
import { newlyFinished, newlyUrgent, type Seen } from './useCallNotifications.ts'
const since = Date.parse('2026-11-10T17:00:00Z')
const call = (id: string, over: Partial<Call> = {}) =>
({
id,
status: 'completed',
ended_at: '2026-11-10T17:05:00Z',
deleted_at: null,
source: 'phone',
outcome: 'message',
urgency: 'normal',
started_at: '2026-11-10T17:01:00Z',
...over,
}) as Call
test('only calls that just finished are news', () => {
const before = new Map<string, Seen>([
['live', { status: 'live', urgency: 'normal' }],
['old', { status: 'completed', urgency: 'normal' }],
])
const calls = [
call('live'), // was live, now completed
call('old'), // was already completed
call('history', { ended_at: '2026-11-09T10:00:00Z' }), // first sync of a fresh browser
call('test', { source: 'test' }),
call('spam', { outcome: 'spam' }),
call('still-live', { status: 'live', ended_at: null }),
call('new'), // arrived finished
]
expect(newlyFinished(calls, before, since).map(c => c.id)).toEqual(['live', 'new'])
})
test('a running call notifies once when it becomes urgent', () => {
const before = new Map<string, Seen>([
['flagged', { status: 'live', urgency: 'normal' }],
['already', { status: 'live', urgency: 'urgent' }],
])
const calls = [
call('flagged', { status: 'live', ended_at: null, urgency: 'urgent' }), // the assistant just flagged it
call('already', { status: 'live', ended_at: null, urgency: 'urgent' }), // notified before
call('arrived', { status: 'live', ended_at: null, urgency: 'urgent' }), // new and urgent
call('old', { status: 'live', ended_at: null, urgency: 'urgent', started_at: '2026-11-09T10:00:00Z' }),
call('done', { urgency: 'urgent' }), // finished: newlyFinished's
call('test', { status: 'live', ended_at: null, urgency: 'urgent', source: 'test' }),
]
expect(newlyUrgent(calls, before, since).map(c => c.id)).toEqual(['flagged', 'arrived'])
})