ivr-migrator
Skill2 starsChanged 8 months agoMITView on GitHub
Twilio development skill: ivr-migrator
- Reads credentials
In this repository66 other files it gives its agents.
- adversarial-reviewSkill
- agent-connectSkill
- agent-teams-guideSkill
- agent-testingSkill
- android-sdkSkill
- brainstormSkill
- branded-callingSkill
- callbacksSkill
- compliance-regulatorySkill
- conferenceSkill
- context-engineeringSkill
- context-hubSkill
- conversational-intelligenceSkill
- conversation-relay-referenceSkill
- conversation-relaySkill
- conversationrelaySkill
- conversations-v2Skill
- customer-memorySkill
- deepgramSkill
- deep-validationSkill
- elastic-sip-trunkingSkill
- env-doctorSkill
- event-streamsSkill
- getting-startedSkill
- hooks-referenceSkill
- iamSkill
- ios-sdkSkill
- ivr-crawlerSkill
- lookupSkill
- media-streamsSkill
- memory-systemsSkill
- messaging-services-referenceSkill
- messaging-servicesSkill
- messagingSkill
- multi-agent-patternsSkill
- operational-gotchasSkill
- paymentsSkill
- paySkill
- phone-numbersSkill
- proxySkill
- real-time-transcriptionSkill
- recordingsSkill
- segmentSkill
- sendgrid-emailSkill
- sip-byocSkill
- sipSkill
- sync-referenceSkill
- syncSkill
- taskrouter-referenceSkill
- taskrouterSkill
- tdd-workflowSkill
- tool-boundariesSkill
- twilio-cliSkill
- twilio-invariantsSkill
- verify-referenceSkill
- verifySkill
- video-patternsSkill
- videoSkill
- voice-insightsSkill
- voice-referenceSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 4 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 20
Read an IvrTree JSON file and understand its structure
- Distinctive: line 51
Read the input and present a summary:
- Distinctive: line 75
Run the standard pipeline:
- Distinctive: line 86
Call it manually to verify
- Very specific: line 166
services.jsondirectory depth: Only single-level directory names work. - Very specific: line 169
Query parameter propagation: Every handler must propagate variant, ppm, amount, and other state through redirect and Gather action URLs.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
name: ivr-migrator description: Generate Twilio Serverless Functions from an IVR crawler tree JSON. Use when migrating an IVR to Twilio, rebuilding an IVR from a crawl, or generating IVR functions from structured data.
IVR Migrator
Takes an IVR tree JSON (produced by /ivr-crawler) and generates Twilio Serverless Functions that replicate the original IVR. The migrator feeds the tree as requirements into the standard pipeline — /architect → /spec → /test-gen → /dev → /review → /docs.
This is NOT a template engine. Claude Code writes all functions using the full twilio-feature-factory tooling: voice skill, serverless invariants, TwiML patterns, hooks, learnings, and testing conventions.
Scope
CAN
- Read an IvrTree JSON file and understand its structure
- Accept VoiceXML documents as input (parsed via
vxml-parser.tsinto IvrTree IR) - Generate Twilio Serverless Functions for each menu/node in the tree
- Produce
<Gather>,<Say>,<Play>,<Record>,<Redirect>,<Hangup>TwiML - Handle multi-language IVRs (per-node voice selection)
- Generate business hours helpers from
hours_checknodes - Generate retry/timeout logic matching the original IVR behavior
- Generate unit tests for all handlers via TDD pipeline
- Deploy the migrated IVR via
twilio serverless:deploy - Generate VXML from crawl output for customer verification (via
vxml-generator.ts)
CANNOT
- Replicate authentication flows (account number entry, PIN verification)
- Reproduce exact hold music (uses generic Twilio hold music URL)
- Clone agent transfer destinations (generates placeholder
<Dial>or CR TwiML) - Generate code without going through the pipeline (architect → spec → test-gen → dev)
Workflow
Step 1: Load the IVR Tree
/ivr-migrator path/to/ivr-tree.json
# or from VXML:
/ivr-migrator path/to/ivr.vxmlAccepts two input formats:
- IvrTree JSON (from
/ivr-crawler) — used directly - VoiceXML document — parsed via
vxml-parser.tsinto IvrTree IR first
Read the input and present a summary:
- Total nodes and node types
- Languages detected
- Max depth
- Estimated files to generate
Step 2: Plan the Migration (via /architect)
Feed the tree to /architect with these requirements:
Generate Twilio Serverless Functions that replicate this IVR tree. Follow existing patterns from
ivr-welcome.jsandivr-menu.protected.js. Place files undermigrated-ivr/(or user-specified path). Eachmenunode becomes a handler with<Gather>andclassifyMenuSelection(). Eachinformation/dead_endnode becomes a<Say>+<Hangup>handler. Eachtransfernode becomes a<Dial>or placeholder handler. Eachhours_checknode gets business hours logic via a private helper. Eachcallbacknode gets<Record>with proper action URL. Root handler is.js(public), all sub-handlers are.protected.js.
The architect produces a file inventory and routing table.
Step 3: Generate Tests and Implementation (via pipeline)
Run the standard pipeline:
/spec— Detailed spec per handler from the architect output/test-gen— Failing tests for all handlers (TDD Red)/dev— Implement handlers to pass tests (TDD Green)/review— Code review/docs— CLAUDE.md for the migrated IVR directory
Step 4: Deploy and Validate
twilio serverless:deploy- Configure a phone number to point to the migrated IVR's welcome handler
- Call it manually to verify
- Optionally, run
/ivr-crawleragainst the migrated IVR and compare trees
Orange Migration Reference (2026-04-06)
The Orange Utility IVR migration serves as the canonical reference for migrating a real-world payment IVR. 22 handlers, 247 tests, deployed to prototype-orange service.
Key Architectural Decisions
- Single handler set with
variantquery parameter — Both DTMF and Voice+DTMF variants share identical flow logic. Avariant=dtmf|voiceparam controls Gather config and prompt text. Produces 22 handlers instead of 44. - Entry+confirm as one handler with
phaseparameter — Account, ZIP, amount, card, routing, and bank account entry all follow an enter→readback→confirm/re-enter loop.phase=entry|confirmkeeps each unit in one file.enteredValuepasses between phases via query string. - PPM via
ppm=truequery parameter — Pre-paid meter variant skips the payment-method handler. Structural hook for phone-number-specific behavior. - Top-level `` directory —
services.jsononly supports single-level directory names. URL paths:/orange/welcome. Do NOT useorange/. - Even/odd amount logic —
payment-result.protected.jschecksparseInt(amount) % 2 === 0to determine success vs decline. Matches the test system's behavior.
Handler Inventory (22 total)
Core: welcome, account-entry, zip-entry, balance-info, payment-menu, amount-entry, payment-method Card: card-entry, card-expiry, card-cvv, card-zip Bank: bank-notice, bank-type, bank-routing, bank-account Shared: payment-confirm, payment-processing, payment-result Error: account-not-found, card-blocked, error-max-retries, transfer
Reference Files
- Handlers: ``
- Tests:
__tests__/unit/orange/ - Crawl data:
ivr-maps/orange-*.json - CLAUDE.md:
CLAUDE.md
Node-to-TwiML Mapping
| IvrNode.nodeType | Generated TwiML | File Pattern |
root / menu | <Gather input="dtmf speech"><Say> | welcome.js / *.protected.js |
information | <Say> message + <Hangup> or <Redirect> | *.protected.js |
dead_end | <Say> + <Hangup> | inline in parent handler |
transfer | <Say> hold + <Dial> or CR connect | agent-transfer.protected.js |
hold_music | <Play> + timeout <Say> + <Hangup> | inline in parent |
callback | <Say> + <Record action="?afterRecord=true"> | *.protected.js |
hours_check | JS time logic → open/closed branch | *.protected.js + helper |
voicemail | <Record> + action handler | *.protected.js |
| input_entry | <Gather finishOnKey="#"><Say> + confirm phase | *.protected.js (phase=entry/confirm) |
| payment_auth | <Gather numDigits=1><Say> (press 1/2/9) | payment-confirm.protected.js |
| payment_processing | <Say> + <Pause> + <Redirect> | payment-processing.protected.js |
| payment_result | JS amount parity check → success <Say> or decline <Gather> | payment-result.protected.js |
| bank_menu | <Gather numDigits=1><Say> (multi-step via step param) | bank-type.protected.js |
Voice Selection
Map the language field from each node to a Polly voice:
| Language | Voice | TwiML language |
en | Polly.Amy | en-GB |
es | Polly.Lupe | es-US |
fr | Polly.Lea | fr-FR |
| other | Polly.Amy | en-US |
Handling Edge Cases in the Tree
| Tree Condition | Migration Strategy |
Node with confidence < 0.5 | Add a // LOW CONFIDENCE comment, implement best-guess |
error type node | Skip — add comment noting the crawl error |
unknown type node | Generate a <Say> with the raw prompt text + <Hangup> |
| Cycle (node with empty edges + redirect summary) | Generate <Redirect> to the referenced node's handler |
| Very deep tree (>5 levels) | Flatten where possible; menus with single options can be inlined |
Gotchas
- Prompt text is transcribed, not exact: The crawler captures STT output, not the original TTS text. The migrated
<Say>content will be a close approximation, not verbatim. - Business hours are detected, not replicated:
hours_checknodes note that business hours logic exists, but the exact schedule comes from thebusinessHoursInfofield if Claude detected it. May need manual verification. - Hold music URLs: The original IVR's hold music is not captured. Use
https://api.twilio.com/cowbell.mp3or ask the user for their music URL. - Agent transfers need configuration:
transfernodes generate placeholder<Dial>TwiML. The actual agent phone number or ConversationRelay URL must be configured by the user. - Pipeline enforcement: The pre-write hook blocks new
functions/*.jswithout tests. The migrator MUST go through/test-gen→/dev. No shortcuts. services.jsondirectory depth: Only single-level directory names work.voice/orangefails because the deploy script can't create nested symlinks. Useorange(→ ``) as a top-level directory.- Deploy env var size limit: Twilio Serverless has a 3583-byte context size limit for environment variables. Services that don't need env vars (pure TwiML generators) should deploy with a minimal
.envcontaining onlyTWILIO_ACCOUNT_SIDandTWILIO_AUTH_TOKEN. - classifyConfirmation must check 'incorrect' before 'correct': The word "incorrect" contains "correct" as a substring. If you check
includes('correct')first, speech like "no that is incorrect" matches the wrong branch. Always check negative keywords before positive ones. - Query parameter propagation: Every handler must propagate
variant,ppm,amount, and other state through redirect and Gather action URLs. Use abuildQs()helper that filters empty values. - Voice variant Gather config: DTMF uses
input: 'dtmf',numDigits: N. Voice usesinput: 'dtmf speech',speechTimeout: 'auto', plushintsfor each Gather. Both share the same handler logic.
Related Resources
- IVR Crawler:
/ivr-crawler— produces the input tree JSON - Tree Schema:
skills/ivr-crawler/references/tree-schema.md— IvrTree JSON format - Voice Patterns:
ivr-welcome.js,ivr-menu.protected.js— existing IVR patterns to follow - Test IVR:
test-ivr/CLAUDE.md— reference implementation of a complex IVR
Reference Files
| Topic | File | When to read |
| IvrTree JSON schema | skills/ivr-crawler/references/tree-schema.md | Before reading crawl output |
| Node-to-TwiML rules | references/generation-rules.md | During architect/spec phase |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

