{"slug": "how-to-build-voice-ai-for-inbound-calls", "title": "how to build voice ai for inbound calls", "summary": "A developer detailed a workflow for building a voice AI agent that answers inbound calls, qualifies leads, and books meetings automatically using Vapi, Twilio, Calendly, and n8n. The setup involves creating a Vapi agent via API, configuring Twilio to forward calls, and using n8n to orchestrate webhooks and calendar scheduling. The developer provided step-by-step instructions and configuration snippets for reproducibility.", "body_md": "You can have a Vapi agent answer every inbound call, ask qualifying questions, and hand the prospect off to Calendly to lock in a meeting - all without writing a single line of custom telephony code. **The result is a self-contained voice AI agent that routes calls, captures lead data, and books calendar slots automatically.**\n\n**voice is the audible sound produced by a human speaker that can be captured, transmitted, and synthesized by software.**\n\n**voice AI agent is a software component that receives spoken input over a phone line, runs speech-to-text, applies a language model, and returns synthesized speech to the caller.**\n\nBelow you'll find everything you need to reproduce the exact workflow, from the required services to the n8n JSON that creates the Vapi agent, plus the pitfalls that usually bite new builders.\n\n| Tool | Plan / Price | Role |\n|---|---|---|\n| Vapi | Free tier or paid plan - check the Vapi pricing page | Voice AI platform that hosts the conversational model and performs voice synthesis |\n| Twilio | Pay-as-you-go voice minutes - check Twilio pricing | Provides the inbound phone number and SIP termination for Vapi |\n| Calendly | Free tier or paid plan - check Calendly pricing | Calendar link generator and meeting scheduler |\n| n8n (self-hosted) | Community edition - free (Docker) | Orchestrates the webhook chain between Vapi, Twilio, and your CRM |\n| HubSpot CRM (optional) | Free tier - check HubSpot pricing | Stores qualified lead details for follow-up |\n\n**Estimated build time:** 1-2 days for a minimal production-ready flow, assuming you already have accounts for the services above.\n\nThe core of the solution is a Vapi \"agent\" that runs a scripted dialogue, a Twilio phone number that forwards calls to Vapi, and an n8n workflow that receives the webhook payload, enriches the lead, and creates a Calendly event. Follow each numbered step precisely; the configuration values are written exactly as they appear in the UI.\n\n`https://your-n8n-instance.com/webhook/vapi-inbound`\n\n).\n\nTip:Twilio will send a`POST`\n\nrequest with`CallSid`\n\n,`From`\n\n, and`To`\n\non every inbound call. n8n will use those fields to correlate the call with Vapi.\n\nVapi agents are defined via a JSON payload that describes the prompt, voice synthesis settings, and webhook callbacks. Use the Vapi dashboard or API; the snippet below is the API version for reproducibility.\n\n**What this does:** Sends a POST request to Vapi's `/v1/agents`\n\nendpoint, creating an agent that asks the caller for name, company, and a brief need description, then forwards the captured slots to a webhook.\n\n```\ncurl -X POST https://api.vapi.ai/v1/agents \\\n -H \"Authorization: Bearer YOUR_VAPI_API_KEY\" \\\n -H \"Content-Type: application/json\" \\\n -d '{\n \"name\": \"Lead Qualifier\",\n \"voice\": \"en-US-Standard-C\",\n \"prompt\": {\n \"system\": \"You are a friendly sales development rep. Greet the caller, ask for name, company, and a short description of their challenge. Then say: I will send you a link to book a time with our specialist.\",\n \"temperature\": 0.7\n },\n \"slots\": [\n {\"name\": \"caller_name\", \"type\": \"string\", \"question\": \"May I have your name?\"},\n {\"name\": \"company\", \"type\": \"string\", \"question\": \"Which company are you representing?\"},\n {\"name\": \"challenge\", \"type\": \"string\", \"question\": \"Briefly describe the problem you want to solve.\"}\n ],\n \"on_complete\": {\n \"webhook_url\": \"https://your-n8n-instance.com/webhook/vapi-complete\",\n \"method\": \"POST\"\n }\n }'\n```\n\nReplace `YOUR_VAPI_API_KEY`\n\nwith the secret you generate in the Vapi dashboard under **API Keys**. After a successful call, the response contains an `agent_id`\n\n; copy that value for the next step.\n\nNow tell Twilio to forward the call audio to the Vapi agent you just created.\n\n`AGENT_ID`\n\nyou recorded:\n\n```\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response>\n <Dial>\n <Sip>sip:AGENT_ID@sip.vapi.ai</Sip>\n </Dial>\n</Response>\n```\n\nSave the Twiml Bin and associate it with the phone number. Twilio now streams the call directly into the Vapi agent, which will run the qualification script defined earlier.\n\nn8n will receive the lead data once the Vapi dialogue ends, enrich it, push it to HubSpot (optional), and generate a Calendly link.\n\n`POST`\n\nand the `vapi-complete`\n\n. | From | To |\n|---|---|\n`caller_name` |\n`firstname` |\n`company` |\n`company` |\n`challenge` |\n`description` |\n\n`YOUR_CALENDLY_TOKEN`\n\nwith the personal access token from Calendly's Integrations page.\n\n```\n{\n \"method\": \"POST\",\n \"url\": \"https://api.calendly.com/scheduled_events\",\n \"headers\": {\n \"Authorization\": \"Bearer YOUR_CALENDLY_TOKEN\",\n \"Content-Type\": \"application/json\"\n },\n \"body\": {\n \"max_event_count\": 1,\n \"owner\": \"https://api.calendly.com/users/YOUR_USER_UUID\",\n \"invitees\": [\n {\n \"email\": \"{{ $json.email }}\",\n \"name\": \"{{ $json.firstname }}\",\n \"custom_questions\": [\n {\n \"question\": \"Company\",\n \"answer\": \"{{ $json.company }}\"\n },\n {\n \"question\": \"Challenge\",\n \"answer\": \"{{ $json.description }}\"\n }\n ]\n }\n ]\n }\n}\n```\n\nConnect the **HTTP Request** node's output to a **Respond to Webhook** node that reads the `invitee_uri`\n\nfrom Calendly's response and speaks it back to the caller via Vapi's *callback* feature. In Vapi's dashboard, set **Post-call webhook** to point at the n8n **Webhook** node you just created (e.g., `https://your-n8n-instance.com/webhook/vapi-return`\n\n).\n\nDeploy the workflow and copy the public webhook URLs; paste them into the Vapi agent's `on_complete`\n\nand post-call webhook fields respectively.\n\nIf you hear the call drop or the conversation stops after the last question, check the **Vapi agent logs** and the **n8n execution history** for HTTP errors.\n\nBuilding a voice AI pipeline sounds linear, but several hidden constraints surface in production.\n\n**Rate limits** - Vapi caps outbound webhook calls at 500 requests per hour on the free tier. If you expect more inbound traffic, upgrade or implement exponential back-off in the n8n **HTTP Request** node.\n\n**Auth token expiry** - Both Vapi and Calendly use bearer tokens that rotate every 30 days. If a token expires, the webhook will return `401 Unauthorized`\n\nand the workflow halts. Set up a **Cron** node in n8n that refreshes the Calendly token using the OAuth refresh endpoint, and store the fresh token in an **Environment Variable**.\n\n**Twilio call failures** - If the Twilio number is not correctly linked to the Sip address (`sip:AGENT_ID@sip.vapi.ai`\n\n), the call will end with \"Call failed\". Double-check the `AGENT_ID`\n\nvalue and ensure the Sip domain is reachable (no firewall blocking port 5060).\n\n**Voice synthesis latency** - Vapi's TTS can take up to 3 seconds per utterance on the free tier. If you chain many prompts, callers may perceive lag. Keep the dialogue under four turns, or pre-generate static prompts and serve them via the **Play** verb in Twiml.\n\n**CRM field mismatch** - HubSpot expects specific property IDs; if the Set node's field names do not match, the contact creation fails silently. Verify the property keys in HubSpot's **Custom Properties** section and adjust the Set node mapping accordingly.\n\nWarning:Ignoring webhook retry headers will cause lost lead data under high load. Configure n8n'sWebhooknode to respect the`Retry-After`\n\nheader and enableMaximum Retriesset to`5`\n\n.\n\nVapi uses SIP (Session Initiation Protocol) to accept inbound audio streams. When Twilio forwards a call to `sip:AGENT_ID@sip.vapi.ai`\n\n, Vapi creates a media session that runs the LLM-driven script, captures speech-to-text in real time, and sends synthesized audio back over the same channel. The **on_complete** webhook is only triggered after the dialogue finishes or the caller hangs up. Understanding this flow helps you debug why a call might appear muted: the SIP handshake may have timed out if the Vapi agent is still initializing. In that case, restart the agent via the Vapi dashboard or re-POST the creation payload.\n\nThe n8n workflow described in step 4 is the glue that turns raw voice data into actionable business objects. It follows a classic **trigger → transform → action** pattern:\n\n`vapi-complete`\n\n). Because each node is a discrete, reusable component, you can swap HubSpot for Salesforce, or Calendly for Microsoft Bookings, without rewriting the entire pipeline. This modularity is what makes the automation workflow robust for scaling.\n\nFor a deeper technical reference, see [n8n's documentation](https://docs.n8n.io/).\n\nAll the tools have free tiers that let you prototype end-to-end. Production usage (high call volume, advanced voice models, or premium Calendly features) may require paid plans. Check the Vapi, Twilio, and Calendly pricing pages for the latest rates.\n\nn8n supports dozens of CRM integrations out of the box. Replace the HubSpot node with the appropriate node (e.g., Salesforce, Pipedrive) and adjust the field mapping in the Set node to match the target CRM's schema.\n\nVapi is a hosted SaaS product; there is no self-hosted edition. If you need on-premise control, you would have to replace Vapi with an open-source stack such as Mozilla DeepSpeech + Coqui TTS, but that adds significant engineering overhead.\n\nTwilio supplies phone numbers in many countries. Purchase the appropriate national number, and update the **Voice → A CALL COMES IN** webhook URL to point at the same n8n endpoint. Vapi's TTS supports dozens of locales; set the `voice`\n\nfield in the agent payload to the appropriate language code (e.g., `en-GB-Standard-A`\n\nfor UK English).\n\nOur **free guide** walks you through every API call, includes sample n8n workflows, and shows how to monetize the solution: [https://getaab.com/free](https://getaab.com/free). For ideas on packaged products you can sell, see our curated list of **AI automations you can sell**: [https://getaab.com/ai-automations-to-sell](https://getaab.com/ai-automations-to-sell).\n\nBy following these steps you now have a fully functional voice AI agent that answers inbound calls, qualifies leads, and books meetings without any manual intervention. The same pattern can be duplicated for support hotlines, appointment reminders, or any scenario where spoken interaction needs to be automated at scale. Happy building.", "url": "https://wpnews.pro/news/how-to-build-voice-ai-for-inbound-calls", "canonical_source": "https://dev.to/samchenreviews/how-to-build-voice-ai-for-inbound-calls-2hpk", "published_at": "2026-08-22 00:32:08+00:00", "updated_at": "2026-08-22 00:44:11.138926+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools"], "entities": ["Vapi", "Twilio", "Calendly", "n8n", "HubSpot"], "alternates": {"html": "https://wpnews.pro/news/how-to-build-voice-ai-for-inbound-calls", "markdown": "https://wpnews.pro/news/how-to-build-voice-ai-for-inbound-calls.md", "text": "https://wpnews.pro/news/how-to-build-voice-ai-for-inbound-calls.txt", "jsonld": "https://wpnews.pro/news/how-to-build-voice-ai-for-inbound-calls.jsonld"}}