Objective
On a live call there's no time for a clarifying menu — the caller says "I think my card got declined" and the voice agent must instantly route to the billing skill, not read out a phone tree. Hard-coded grammars break on natural speech. Here you'll route by meaning: embed each skill's description, match the transcribed utterance to the nearest skill in one query, and gate low-confidence matches to a quick "could you say that another way?" instead of a wrong action. Your STT/TTS and telephony live outside the database; the routing brain is the database. See Use it from your agent for wiring it into any voice stack.
Step 1: Create the skill registry
Each row is a skill the voice agent can hand off to, described in natural language and embedded.
CREATE TABLE IF NOT EXISTS recipe_voice_skills (
skill_id INTEGER PRIMARY KEY,
skill_name TEXT, -- the skill/flow the agent triggers
description TEXT, -- what the caller wants, in plain language
embedding VECTOR(384)
);
Step 2: Register the voice agent's skills
A realistic skill set for a phone support line.
INSERT INTO recipe_voice_skills (skill_id, skill_name, description) VALUES
(1,'billing_help','Questions about charges, declined cards, invoices, or payments.'),
(2,'tech_support','The product or service is broken, erroring, slow, or not connecting.'),
(3,'account_access','The caller cannot log in, is locked out, or needs a password reset.'),
(4,'new_order','The caller wants to place a new order or sign up for a plan.'),
(5,'speak_to_human','The caller is frustrated or explicitly asks for a live person.'),
(6,'order_status','The caller wants to know where their order or delivery is.');
Step 3: Embed the skill descriptions
The embedding model runs in-database; this is the index the router searches each turn.
UPDATE recipe_voice_skills SET embedding = EMBED(description);
Step 4: Route a transcribed utterance to a skill
Match what the caller said to the nearest skill — robust to natural, messy speech.
SELECT skill_name, description,
COSINE_SIMILARITY(embedding, EMBED('uh yeah my payment didn''t go through and I got charged anyway')) AS match_score
FROM recipe_voice_skills
ORDER BY match_score DESC
LIMIT 3;
Step 5: Pick one skill with a confidence gate
Trigger the top skill only when it clears a threshold; otherwise reprompt rather than misroute mid-call.
SELECT skill_name, match_score,
CASE WHEN match_score >= 0.32 THEN 'TRIGGER' ELSE 'REPROMPT' END AS decision
FROM (
SELECT skill_name,
COSINE_SIMILARITY(embedding, EMBED('I just want to talk to a real person, this is ridiculous')) AS match_score
FROM recipe_voice_skills
ORDER BY match_score DESC
LIMIT 1
);