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
// The recording notice is part of the greeting text (LIN-819): a new assistant's greeting says it before its closing
// question, call.start brings no separate notice, and a save that adds or removes it is in the audit log (A4).
import { assistants } from '@linedesk/db'
import { eq } from 'drizzle-orm'
import { describe, expect, test } from 'vitest'
import { listAudit } from '../src/audit.ts'
import { db } from '../src/db.ts'
import { act, agent, createWorkspace, randomNumber } from './helpers.ts'
const NOTICE = 'This call may be recorded and transcribed.'
describe('recording notice in the greeting', () => {
test('a new assistant says it in its greeting, before the closing question; call.start sends nothing else', async () => {
const ws = await createWorkspace('Notice Default Plumbing')
const [row] = await db.select().from(assistants).where(eq(assistants.id, ws.assistant.id))
const second = (await act(ws.owner, 'assistant.create', {})).body.data.assistantId as string
const [made] = await db.select().from(assistants).where(eq(assistants.id, second))
for (const greeting of [row!.greeting, made!.greeting])
expect(greeting).toMatch(/ This call may be recorded and transcribed\. [^.]+\?$/)
const started = await act(agent(), 'call.start', { from: randomNumber(), to: ws.number })
expect(started.body.data).not.toHaveProperty('recordingNotice')
expect(started.body.data.assistant.greeting).toContain(NOTICE)
})
test('taking it out of the greeting and putting it back are in the audit log; other greeting edits are not', async () => {
const ws = await createWorkspace('Notice Audit Plumbing')
const assistantId = ws.assistant.id
const update = (greeting: string) => act(ws.owner, 'assistant.update', { assistantId, greeting })
expect((await update('Hi, Brightwater Plumbing. How can I help?')).status).toBe(200)
expect((await update(`Hi, Brightwater Plumbing. ${NOTICE} How can I help?`)).status).toBe(200)
expect((await update(`Hello, Brightwater Plumbing. ${NOTICE} How can I help?`)).status).toBe(200)
const { entries } = await listAudit(db, { kind: 'team', workspaceId: ws.id, limit: 50 })
const notices = entries.filter(e => e.what === 'assistant.update')
expect(notices.map(e => e.recordingNoticeChange)).toEqual([{ greeting: true }, { greeting: false }])
})
test('assistant.update no longer takes the old notice fields', async () => {
const ws = await createWorkspace('Notice Fields Plumbing')
const res = await act(ws.owner, 'assistant.update', { assistantId: ws.assistant.id, recording_notice_on: false })
const [row] = await db.select().from(assistants).where(eq(assistants.id, ws.assistant.id))
expect(row).not.toHaveProperty('recording_notice_on')
expect([200, 422]).toContain(res.status)
})
})