● Reference · How it fits together
Architecture
who talks to whom on a call.
The call audio runs between Telnyx and ElevenLabs. Answerbell answers the agent's tool requests, keeps the records, sends e-mails and bills your clients.
01Diagram
02One call, step by step
- Caller dials. The client's Telnyx number sends the call over SIP to ElevenLabs.
- AI disclosure. The agent speaks it first; the caller cannot interrupt it.
- Tools. The agent calls
business_info,check_availability,book_appointment,cancel_appointment,take_messageorcaller_historyon Answerbell, and may transfer the call with ElevenLabs'transfer_to_number. Each request carries the client's secret in thex-answerbell-tool-secretheader; Answerbell answers with JSON. - Records and e-mail. Answerbell stores bookings and messages in SQLite (bookings checked inside one transaction) and e-mails the business through Resend. With a linked calendar the booking also appears there; your webhooks get the event.
- After the call. The sync job reads the conversation from ElevenLabs into the call log with its labels, adds the minutes to the client's usage (spam left out) and sends
call.completedto your webhooks.
03Where things are in the code
| File | What |
|---|---|
src/index.ts | start-up: config, database, console, server, background jobs (call sync, calendars, summaries, reports, overage, webhooks) |
src/server.ts | HTTP routes, CSP, body size caps, rate limits |
src/agent.ts | AI disclosure per language, agent configuration, transfers |
src/tools.ts | the six server tools, tool secrets |
src/provision.ts, src/elevenlabs.ts, src/knowledge.ts | creating and updating agents, tools and knowledge documents over the ElevenLabs REST API |
src/bookings.ts, src/clients.ts, src/messages.ts, src/time.ts, src/holidays.ts | clients, opening hours, special hours, holidays, free times, bookings, messages, timezones |
src/calls.ts, src/analytics.ts | call sync, labels, usage minutes, usage alerts, analytics |
src/contacts.ts | callers, VIP, block list |
src/report.ts, src/summaries.ts | monthly report, summary e-mails |
src/calendar/ | Google and Outlook two-way, iCal feeds, the bookings feed |
src/portal.ts, src/web/portal.ts | client portal accounts and pages |
src/webhooks.ts, src/net.ts | outgoing signed webhooks; the guarded fetch for typed addresses |
src/templates.ts, src/siteimport.ts | trade templates; "Fill from the website" |
src/stripe.ts, src/overage.ts | Checkout, webhook signature, invoices; minutes above the plan |
src/notify.ts | e-mails through Resend |
src/admin/ | console declaration (sections, pages, checks, metrics) for the Admin Kit |
src/web/, public/ | Today, Call analytics, Clients and their tabs, Bookings, Messages, Calls, Subscriptions, Webhooks |
src/addons/followup/ | the optional Follow-up add-on |
src/demo.ts | sample data for demo mode |
packages/admin-kit/ | operator console: settings, keys, team, audit, status |
dist/ | the compiled server, made by pnpm build; do not edit it |
04Customizing
Most changes need no code: brand name, logo, colour and support e-mail are under Brand; every client's facts are on the client page. Code changes most buyers make:
- Agent prompt wording:
basePromptinsrc/agent.ts(per language) and the tool rules insrc/tools.ts. Keep the disclosure rules. - E-mail texts:
bookingMail,messageMail,usageMailinsrc/notify.ts. - Console page layout:
src/web/andpublic/console.css. - Trade templates:
src/templates.ts.
Run pnpm typecheck and pnpm test after a change, then pnpm build and restart the server (WSL or Git Bash on Windows). While you work, pnpm dev restarts on every change.