← All posts
How-ToNovember 25, 2026 · 8 min

Build a voice AI chatbot for support that answers queries, books appointments, and upsells

To build a voice AI chatbot for support you combine Twilio's telephony API with a speech-to-text service (e.g., Deepgram or Whisper), route the transcript to a Retrieval-Augmented Generation (RAG) pipeline that pulls answers from a curated knowledge base, and synthesize the reply with ElevenLabs' realistic TTS voices. Use a webhook in n8n to orchestrate the flow: on incoming call Twilio triggers the webhook, the audio is transcribed, the RAG engine returns a confidence score, and if the score falls below a threshold the call is routed to a live agent via Twilio's call-routing API. For high-confidence answers, the response is spoken back and, if relevant, an appointment-booking node in n8n creates a calendar entry. Track call duration, hand-off rate, and resolved-issue count to quantify workload reduction.

How it works

  1. Incoming call reaches Twilio - A Twilio Programmable Voice number answers the call and forwards the audio stream to a webhook URL hosted in n8n. Twilio supplies the raw PCM data and a Call SID that will be used for later call-routing decisions.
  1. Speech-to-text conversion - The webhook sends the audio to Deepgram (or Whisper) via its Speech-to-Text API; the transcript is returned in JSON and attached to the Call SID context. This transcription is the textual input for the next stage.
  1. Retrieval-augmented generation (RAG) - n8n invokes a Retrieval-Augmented Generation service (e.g., an OpenAI embeddings endpoint combined with a Pinecone vector store) that queries a curated knowledge base of support articles. The RAG module returns a concise answer and a confidence score.
  1. Decision logic - If the confidence score is above a configurable threshold (e.g., 0.85), n8n proceeds to text-to-speech; otherwise it triggers an escalation path by calling Twilio's Call Routing API to transfer the caller to a live agent or schedule an appointment via an integrated calendar webhook.
  1. Text-to-speech synthesis - For confident answers, n8n forwards the response text to ElevenLabs' Text-to-Speech API, selecting a voice appropriate for your brand. The generated audio file (MP3) is streamed back to Twilio, which plays it to the caller in real time.
  1. Metrics collection - After each interaction, n8n logs the call duration, confidence score, and whether escalation occurred to a PostgreSQL table. These logs feed a simple dashboard that compares total handled calls versus escalations, showing the net reduction in manual support workload.

How to build it

Building a voice ai chatbot for support requires separating telephony, speech processing, logic, and content. Do not attempt to handle these in a single monolithic script. Use a microservices approach where Twilio handles the phone line, Vapi orchestrates the voice session, and n8n manages the business logic and data retrieval.

1. Provision the Telephony Layer Create a new project in Twilio. Buy a DID (Direct Inward Dialing) number. In the Twilio Console, create a new Voice Application. Set the Method to "Webhook" for the Call status. Paste your n8n webhook URL into the 'A Call is coming in' field. Ensure the Twilio number is ported or ready for forwarding.

2. Set Up Voice Infrastructure Sign up for Vapi if you prefer managed orchestration, or build a custom stack using ElevenLabs for TTS and Deepgram for STT. If using Vapi, create a new Voice Agent. Select a base model (e.g., OpenAI gpt-4o-mini for reasoning, though latency matters; consider lower-context models). For the Voice, select an ElevenLabs model. Identi is preferred for clarity. Set the Assistant's voice to "Alice" or "Aria." Check current pricing for ElevenLabs; it typically starts around $5/month for basic TTS usage.

3. Construct the Knowledge Base Gather your support documentation (PDFs, Markdown, HTML). Chunk the text into 400-600 token segments with 50 token overlap. Embed these chunks using an embedding model like text-embedding-3-small. Store the vectors in a vector database like Pinecone or Supabase pgvector. This infrastructure enables Retrieval-Augmented Generation (RAG). The bot must answer strictly from this retrieved context, not its training data, to prevent hallucinations.

4. Build the n8n Workflow Create a new workflow in n8n. Add a "Webhook" node triggered by Twilio. The node should return a 200 OK immediately to prevent Twilio timeouts. Use a "IF" node to check if the call ID is new. If new, add a "Postgres" node to log the call start. If the call is active, the logic will be handled by the Voice Agent, but you can use this node to trigger appointment booking slots if the intent is detected later.

5. Configure the System Prompt Define the persona and constraints in your Voice Agent configuration. The prompt must explicitly instruct the bot to use the provided context and to escalate if confidence is low. Do not allow the bot to improvise answers for technical issues.

text
 You are a support assistant for [Company Name]. 
 Your primary goal is to solve basic issues or book appointments.
 
 CONTEXT:
 {{retrieved_context}}
 
 RULES:
 1. Answer ONLY using the CONTEXT provided above.
 2. If the answer is not in the CONTEXT, or if the user asks for something complex, say: "I'm not sure about that specific detail. Let me connect you with a human agent."
 3. If the user wants to book a slot, use the tool 'book_appointment' with parameters: date, time, reason.
 4. Keep responses under 25 words. Be concise.
 5. If you detect high frustration or anger, immediately trigger 'transfer_to_human'.
 

6. Implement Escalation Logic In Vapi, configure the "Transfer to Agent" action. Connect this to a Twilio URL that forwards the call to your human support queue. Use call routing rules to ensure urgent issues go to Tier 1, while general queries might go to a shared queue. In n8n, create a separate branch that listens for the "transfer" event. When triggered, send an email to the support team with a transcript snippet and the call ID.

7. Add Appointment Booking Create a tool in Vapi called book_appointment. This tool should make a HTTP Request to your scheduling API (e.g., Cal.com or Calendly). Pass the user's preferred time. The response should confirm the hold or suggest alternative slots. If the scheduling API fails, the bot must gracefully apologize and ask if the user wants to try a different time.

8. Measure Workload Reduction You cannot claim automation success without data. In n8n, log every interaction. Track two metrics: Resolution Rate: Percentage of calls where the bot answered without transferring. Handle Time: Average duration of automated calls vs. human calls. Query your database weekly. If the Resolution Rate is below 40%, your knowledge base is likely too narrow, or the retrieval accuracy is poor. Tune your chunk size or improve the embedding model.

9. Deploy and Test Test the full loop: Call the number -> Bot answers -> Ask a question in the KB -> Bot answers -> Ask a question NOT in the KB -> Bot escalates. Verify that the escalation actually transfers the call and that the n8n workflow logs the event. Handle edge cases like silent calls or background noise. Adjust the VAD (Voice Activity Detection) thresholds if the bot responds to non-speech sounds.

Here is a sample n8n workflow JSON excerpt for the initial Twilio webhook receiver:

```json { "name": "New Call Receiver", "nodes": [ { "parameters": { "httpMethod": "POST", "path": "twilio-call-start", "respondWith": "text", "responseBody": "200 OK", "options": {} }, "id": "a1b2c3d4-1234-5678-90ab-cdef12345678", "name": "Twilio Webhook", "type": "n8n-nodes-base.webhook", "typeVersion": 1, "position": [ -400, 0 ] }, { "parameters": { "query": "INSERT INTO calls (call_id, start_time, status) VALUES ($1, NOW(), 'active')", "queryReplacement": "={{ $json.callSid }}" }, "id": "e5f6a7b8-9012-3456-78cd-efab23456789", "name": "Log Call Start", "type": "n8n-nodes

What it costs to run

Uses per monthMonthly costAssumptions
100 calls~$123 min per call, Twilio voice ($0.0135/min), ElevenLabs TTS ($0.0045/min), Vapi orchestration ($0.0003/min), storage & data transfer negligible
1 000 calls~$120Same per-call cost, 3 min average, volume discount on Twilio ~10 %
10 000 calls~$1 200Volume discount on Twilio ~20 %, same per-call TTS, Vapi, and Whisper/STT costs included

Notes - Twilio: Voice minutes from $0.0135/min. - ElevenLabs: Text-to-speech from $0.0045/min for standard voices. - Vapi: Voice-agent orchestration at $0.0003/min. - Deepgram/Whisper: STT cost included in Twilio's minute rate for simplicity; add ~5 % if using external STT. - Costs are rounded and may vary with actual call length, number of prompts, and API usage. Adjust based on your specific call profile.

Where this breaks

Speech-to-Text accuracy drops on noisy lines Symptom: The transcribed text contains many insertions, deletions, or garbled words, causing the RAG engine to retrieve irrelevant answers. Fix: Route calls through Twilio's <Gather> with a short "please speak clearly" prompt, enable Dual-Channel audio, and configure Deepgram/Whisper to use the "enhanced" model; optionally add a noise-reduction step in an n8n webhook before sending audio to the STT service.

Knowledge-base mismatch leads to wrong answers Symptom: The chatbot replies with information that does not apply to the caller's product version or region, prompting repeated clarifications. Fix: Tag every knowledge article with metadata (product, version, locale) and include those tags in the retrieval query; modify the RAG prompt to filter results by the caller's Twilio <Lookup> data (e.g., country code) before feeding the text to the LLM.

Escalation loop never triggers Symptom: Calls that should be transferred to a live agent stay in the voice AI loop, repeating "I'm sorry, I didn't understand" indefinitely. Fix: Define a confidence threshold on the LLM's response (e.g., < 0.6) and implement an n8n decision node that, when exceeded, sends a Twilio <Redirect> to a pre-configured agent queue or schedules an appointment-booking flow via a webhook.

Metrics collection overloads the monitoring pipeline Symptom: After a few hours of traffic, the dashboard shows missing or delayed values for "automation lift" and call-duration stats. Fix: Batch metric events in n8n (e.g., send a single payload every 30 seconds) and push them to a lightweight time-series store such as InfluxDB; ensure the webhook payload size stays under Twilio's 1 KB limit to avoid throttling.

Can I test a voice ai chatbot for support without spending money? Yes, most platforms offer limited free tiers or trial credits. For example, Deepgram provides a small amount of free STT tokens, and Python's open-source Whisper implementation is completely free to run locally. However, avoid starting production testing on Twilio's trial number, as it limits you to calling specific whitelisted numbers and restricts outbound traffic.

Which part of the stack is the hardest to integrate? Consistent latency and interruption handling are the most complex pieces to get right. You need to tune the webhook triggers in your orchestration layer to handle barge-in (user interrupting the AI) without dropping audio chunks. If your stack requires over 800ms total round-trip latency, users will perceive the bot as lagging and will interrupt it, breaking the conversation flow.

Do I need to replace my existing IVR system? No, you can bypass the traditional interactive voice response for common queries while keeping it for complex scenarios. Your call routing logic should send standard support calls to the AI and route only high-value or complaint-laden calls to human agents. This hybrid approach allows you to prove workload reduction metrics before fully retiring legacy audio menus.

How do I handle appointment booking within the call? Implement a deterministic state machine in your code rather than relying on the LLM to manage complex multi-step slots. Have the AI validate the customer's preferred time against your CRM API via a webhook, then confirm the booking only after the user explicitly agrees. This prevents the model from hallucinating appointments or double-booking resources during the conversation.

Get the full toolkit

Grab the free guide with the node-by-node build for all 10 automations.

By subscribing, you agree to receive this guide plus occasional AI Automation Blueprint educational and product emails. Unsubscribe anytime. Privacy policy.