All modules
Module 13 · ai · intermediate
AI Voice Agent Backend
After this module you can give an AI phone receptionist (Retell AI or Vapi) real abilities: check availability, book, cancel and recognise callers, plus a summary of every call.
What it does
Voice platforms handle the talking; they call your webhook whenever the agent needs to do something. This workflow is that backend, for a demo clinic, Bright Smile Dental:
POST /webhook/voice/tools: one endpoint for every tool:check_availability,book_appointment,cancel_appointment,lookup_customer. It accepts Retell ({name, args, call}), Retell's args-only mode (?tool=), and Vapi (message.toolCallList), and replies in each platform's format in ~25 ms. Every reply has amessagethe agent can read out loud.POST /webhook/voice/call-ended: receives the end-of-call webhook, summarizes the transcript with AI (intent, follow-up needed), and branches to an owner alert.
Bookings live in the workflow's static data, so the whole tool flow works with zero credentials. The Business tier swaps in Google Calendar.
Flow
Voice Tools API → Business Settings → Normalize Tool Calls → Route Tool ─┬→ check_availability ─┐
├→ book_appointment ───┤
├→ cancel_appointment ─┼→ Format for Platform → Respond
├→ lookup_customer ────┤
└→ Unknown Tool ───────┘
Call Ended → Normalize Call → Summarize Call (OpenAI) → Call Record → Needs Follow-up? → Notify Owner / Log Call
Verification status (n8n 2.43.6)
- Tools endpoint: 16/16 checks pass without credentials (Retell, Vapi and args-only payloads; booking, double-booking, cancel, lookup, weekend/past/missing-field handling, unknown tool). Median response 24 ms.
- Call-ended webhook: acknowledges immediately; a real transcript reaches the AI node and stops at "Error in sub-node OpenAI Chat Model" until you add an OpenAI credential (
WITH_CREDS=1 ./test/test.sh). - Not tested against a live Retell/Vapi phone call. Payload formats follow their docs (Retell custom functions, Vapi custom tools). Log one real request before going live (lesson, Step 6).
Files
| File | Tier | Purpose |
|---|---|---|
| lesson.md | Free | Step-by-step build + connecting Retell/Vapi |
| workflow/starter.json | Free | Endpoint, normalizer and availability tool |
| workflow/learner.json | Learner | Finished backend (tools + post-call summary) |
| workflow/code/ | Learner | Readable copies of every Code node |
| exercises.md | Learner | Practice tasks |
| solutions.md | Learner | Exercise solutions |
| notes.md | Private | Learning log |
| sell/ | Private | Offer, video script, blog post |
The JSON workflow is the source of truth; workflow/code/*.js are copies for reading and diffing.