We recently built an AI phone receptionist for small businesses: a caller dials a local number, a large language model (LLM) holds the conversation, and the business owner gets a text and email summary when the call ends. The stack is Next.js route handlers on Vercel, Twilio Programmable Voice with Gather speech input, Deepgram Nova-3 for speech-to-text, Amazon Polly voices for text-to-speech, and an LLM that returns structured JSON on every turn.
The happy path took a day. These are the seven things that took the rest of the time.
1. Validate the Twilio signature, and know exactly which URL Twilio signed
Every webhook (incoming call, each conversation turn, the status callback) must check the X-Twilio-Signature header: an HMAC-SHA1 of the full URL plus the sorted POST parameters, keyed with your auth token. The gotcha is the URL. Behind a proxy, the URL your code sees may not be the public URL Twilio called, so build it from a configured canonical origin plus the path and query string. Our first deploy rejected every call with a 403 because the stored auth token had picked up a trailing newline when it was piped into the CLI. Write secrets from a file with no trailing newline.
2. You do not need a database for call state
Each Gather posts the caller's speech to an action URL. We compress the conversation so far (deflate, then base64url) and put it in that URL's query string. Every turn is stateless, there are no race conditions, and there is nothing to clean up. Cap the history so the URL stays a sensible length.
3. Ask the model for JSON, not prose
Each turn returns a schema-validated object: what to say, whether to end the call, whether it is urgent, whether to transfer, whether the caller confirmed their details, plus the details collected so far. Structured output means the route code, not the model, decides when to hang up, transfer or send the summary. Keep a fallback turn ("Sorry, could you say that again?") for the rare parse failure.
4. Tell the model what it has already collected
The model sees the transcript, but it does not reliably track which fields it has. Merging the details after every turn and adding an "already collected, do not ask again" list to the context removed most of the repetitive questions. Keep the stable instructions first so they can be cached, and put the per-turn context in a separate block after them.
5. Text-to-speech reads phone numbers as integers
"7809952732" becomes "seven billion, eight hundred…". We post-process the model's output with a regular expression that finds runs of seven or more digits (allowing spaces, dashes and brackets) and rewrites them as spaced digits in natural groups: "7 8 0, 9 9 5, 2 7 3 2". Shorter runs are left alone, otherwise prices and street numbers break.
6. Use a speech model built for phone audio, and give it hints
Phone audio is narrow-band and callers have accents. Switching to Deepgram Nova-3 and passing hints built from the business's own vocabulary (its name, its services, local place names) noticeably reduced mishearings. Twilio passes those hints to Nova-3 as key terms.
7. Make every webhook idempotent
Twilio retries status callbacks and Stripe retries webhooks. Usage tracking keys each call by its call ID with a create-if-not-exists write, so a retry cannot double-count minutes. Onboarding, which buys a phone number when someone subscribes, takes a lock on the checkout session ID before buying anything, and refuses to run at all if the database is not configured. A retried webhook should never buy a second phone number.
Bonus: the hard part is not technical
Most of the week went into instructions, not code: when to confirm details, how to answer "how much for my whole house?", when not to book. We wrote those lessons up in how to make an AI receptionist sound human. If you would rather not build one yourself, that is what the Aethely AI receptionist does for small businesses.