Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions vapi/agency-routing/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ PORT=4000
# LOOKUP_DELAY_MS=6000

# Optional setup settings, read by `npm run setup`
# Model for the assistants (default gpt-4o)
# VAPI_MODEL=gpt-4o
# Model for the assistants (default gpt-4.1)
# VAPI_MODEL=gpt-4.1
# Have Vapi send "sha256=<hex>" instead of the bare hex digest as the signature
# VAPI_SIGNATURE_PREFIX=sha256=
# Have Event Gateway strip system prompts from payloads after verification
Expand Down
2 changes: 1 addition & 1 deletion vapi/agency-routing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ No Vapi dashboard needed.

1. Open http://localhost:4000.
2. On the Acme Dental card, click **Plug in and call** (**Call Acme Dental** in the System, Light and Dark themes) and allow microphone access. You are the caller; the card names the assistant you are ringing.
3. Say: "Hi, I'm Priya Shah, what's my next appointment?" The assistant says it is checking, then stays quiet (the prompt limits it to looking up an existing account and booking, so for anything else it says it can't do that and offers a call back); about 6 seconds later the CRM result is spoken into the call. The **While you wait** panel on the card shows the tool request, the CRM delay counting down and the result being posted to the call's `controlUrl`.
3. Say: "Hi, I'm Priya Shah, when's my next appointment?" The assistant says it is checking, then stays quiet (the prompt limits it to looking up an existing account and booking, so for anything else it says it can't do that and offers a call back); about 6 seconds later the CRM result is spoken into the call. The **While you wait** panel on the card shows the tool request, the CRM delay counting down and the result being posted to the call's `controlUrl`.
4. Click **End call** (**Pull the plug** in Switchboard). Repeat in the Globex Plumbing column with: "Hi, I'm Maria Lopez, when is my plumber coming?"

Each column shows the events that arrived through that client's Hookdeck source. The page loads the Vapi Web SDK (`@vapi-ai/web`, pinned) from esm.sh; the server only exposes `VAPI_PUBLIC_KEY` and the assistant IDs at `/api/config`.
Expand Down
4 changes: 3 additions & 1 deletion vapi/agency-routing/scripts/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const TOOL_NAME = 'lookup_customer';
const SIGNATURE_PREFIX = process.env.VAPI_SIGNATURE_PREFIX || '';
// Set TRIM_PAYLOAD=true to have Hookdeck strip system prompts from payloads after verification
const TRIM_PAYLOAD = process.env.TRIM_PAYLOAD === 'true';
const MODEL = { provider: 'openai', model: process.env.VAPI_MODEL || 'gpt-4o' };
const MODEL = { provider: 'openai', model: process.env.VAPI_MODEL || 'gpt-4.1' };

const CONNECTION_RULES = [
// The same message of the same call inside 10 minutes is a duplicate: the message type, call, status
Expand Down Expand Up @@ -128,6 +128,8 @@ async function setupVapi(secret: string, urls: { [slug: string]: string }) {
firstMessage: client.first_message,
model: { ...MODEL, messages: [{ role: 'system', content: client.system_prompt }], toolIds: [tool.id] },
voice: { provider: 'vapi', voiceId: 'Elliot' },
// Deepgram key-term prompting for the names callers give, so the lookup gets the right spelling
transcriber: { provider: 'deepgram', model: 'nova-3', language: 'en', keyterm: client.crm.map((r) => r.name) },
server: { url: urls[client.slug], credentialId: credential.id, timeoutSeconds: 20 },
serverMessages: ['status-update', 'end-of-call-report', 'tool-calls'],
monitorPlan: { controlEnabled: true, listenEnabled: false },
Expand Down
7 changes: 4 additions & 3 deletions vapi/agency-routing/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ Looking up a customer:
- After calling it, say one short sentence such as "One moment while I check that." and then say nothing more. Do not ask anything, do not fill the silence, and do not guess the result.
- When lookup_customer replies "Success.", you have already said your holding line, so say nothing at all. Do not speak again until the lookup message arrives.
- Only say "one moment" right after calling lookup_customer.
- The real result arrives a few seconds later as a system message that starts with "Account lookup finished." Until that message arrives you do not know the result. When it arrives, read the key facts out to the caller in one or two sentences, then ask if there is anything else.
- Never say a date, time, appointment, order, name or account detail unless you read it in that system message. Never say the words "CRM" or "lookup result" to the caller.
- The real result arrives a few seconds later as a system message that starts with "Account lookup finished." Until that message arrives you do not know the result. When it arrives, start straight with the facts (for example "Your next appointment is...") in one or two sentences, then ask if there is anything else.
- If the system message says no customer was found, say only that you couldn't find an account under that name and offer a call-back. Never give an appointment or other detail in that case.
- Never say a date, time, appointment, order, name or account detail unless you read it in that system message. Never say the words "Account lookup finished", "CRM" or "lookup result" to the caller.
Never invent account details.`;

/** Same for both clients: the assistants subscribe to status-update, tool-calls and end-of-call-report only */
Expand All @@ -68,7 +69,7 @@ export const CLIENTS: Client[] = [
system_prompt: `You are the phone receptionist for Acme Dental. Keep replies short and spoken-style.\n${TOOL_RULES}`,
agent_role: 'Phone receptionist',
caller_note: 'An Acme patient',
suggested_question: "what's my next appointment?",
suggested_question: "when's my next appointment?",
expect_note: EXPECT_NOTE,
crm: [
{ name: 'Priya Shah', phone: '555-0101', summary: 'Next appointment is a hygiene clean on Thursday at 9:30 am with Dr Lee. No outstanding balance.' },
Expand Down
Loading