voice-reference
Skill2 starsChanged 8 months agoMITView on GitHub
Twilio development skill: voice-reference
- 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
- ivr-migratorSkill
- 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
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 48
When Twilio makes a request to your voice webhook, these parameters are included:
- Distinctive: line 106
Use the Conferences Participants API for programmatic control:
- Distinctive: line 191
Updating participant TwiML exits current state: If a participant is in a conference and you update their call with new TwiML, they …
- Very specific: line 193
Conference teardown risk: If the exiting participant had endConferenceOnExit=true, the entire conference tears down - appearing as a …
- Very specific: line 244
Use console.log for all logging, including error conditions and catch blocks.
- Very specific: line 246
Response bodies: Always pass a string to Twilio.Response.setBody(), not a plain object.
≈ “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
<!-- ABOUTME: Detailed reference material for TwiML verbs, patterns, and conference APIs. --><!-- ABOUTME: Contains code examples, options tables, and advanced call control patterns. -->Voice Reference
For essential context, file inventory, and gotchas, see CLAUDE.md.
Say Verb Options
twiml.say({
voice: 'Polly.Amy', // Amazon Polly voice
language: 'en-GB', // Language code
loop: 1 // Number of times to repeat
}, 'Your message here');Gather Verb Options
twiml.gather({
input: 'dtmf speech', // Input types to accept
timeout: 5, // Seconds to wait for input
numDigits: 4, // Expected DTMF digits
finishOnKey: '#', // Key to finish input
action: '/next-handler', // URL to POST results
method: 'POST', // HTTP method
speechTimeout: 'auto', // Auto-detect end of speech
hints: 'yes, no, help' // Speech recognition hints
});Dial Verb Options
twiml.dial({
callerId: '+1234567890', // Caller ID to display
timeout: 30, // Ring timeout in seconds
action: '/dial-complete',// Callback URL
record: 'record-from-answer' // Recording option
}).number('+1987654321');Voice Webhook Parameters
When Twilio makes a request to your voice webhook, these parameters are included:
| Parameter | Description |
CallSid | Unique identifier for the call |
AccountSid | Your Twilio Account SID |
From | Caller's phone number (E.164) |
To | Called phone number (E.164) |
CallStatus | Current call status |
Direction | inbound or outbound-api |
CallerName | Caller name (if available) |
FromCity | Caller's city |
FromState | Caller's state |
FromCountry | Caller's country |
Gather Callback Parameters
| Parameter | Description |
Digits | DTMF digits pressed |
SpeechResult | Transcribed speech |
Confidence | Speech recognition confidence (0-1) |
Common Patterns
IVR Menu
const twiml = new Twilio.twiml.VoiceResponse();
twiml.say('Press 1 for sales, 2 for support.');
twiml.gather({
numDigits: 1,
action: '/ivr-handler'
});
twiml.redirect('/voice/incoming-call'); // No input, restartCall Forwarding
const twiml = new Twilio.twiml.VoiceResponse();
twiml.dial({
callerId: event.To,
timeout: 20
}).number('+1234567890');
twiml.say('The person you called is unavailable.');Voicemail
const twiml = new Twilio.twiml.VoiceResponse();
twiml.say('Please leave a message after the beep.');
twiml.record({
maxLength: 60,
action: '/recording-complete',
transcribe: true,
transcribeCallback: '/transcription-ready'
});Conference via REST API (Preferred)
Use the Conferences Participants API for programmatic control:
// Create conference by adding first participant
const participant = await client.conferences('my-conference')
.participants
.create({
from: context.TWILIO_PHONE_NUMBER,
to: participantNumber,
timeout: 30, // Ring timeout
timeLimit: 600, // Max call duration (prevent runaway)
startConferenceOnEnter: true,
endConferenceOnExit: false,
muted: false,
beep: true
});
// Add additional participants
await client.conferences('my-conference')
.participants
.create({
from: context.TWILIO_PHONE_NUMBER,
to: anotherParticipant,
timeout: 30,
timeLimit: 600
});
// End conference
await client.conferences(conferenceSid)
.update({ status: 'completed' });Conference Options
| Option | Type | Default | Description |
startConferenceOnEnter | boolean | true | Start when participant joins |
endConferenceOnExit | boolean | false | End when participant leaves (moderator) |
muted | boolean | false | Join muted |
beep | boolean | true | Play beep on join/leave |
timeout | number | 30 | Ring timeout in seconds |
timeLimit | number | 14400 | Max call duration in seconds |
Finding Conferences by Name
// List in-progress conferences by friendly name
const conferences = await client.conferences.list({
friendlyName: 'my-conference',
status: 'in-progress',
limit: 1
});
if (conferences.length > 0) {
const conference = conferences[0];
console.log(`SID: ${conference.sid}`);
}TwiML Control Model
Critical: In almost all cases, only ONE TwiML document controls a call at any given time.
Exception: Background Operations
Some TwiML verbs start background processes that continue running even after the call moves to subsequent TwiML documents:
<Start><Stream>- Media streaming continues in the background<Start><Recording>- Recording continues until explicitly stopped<Start><Siprec>- SIPREC streaming continues in the background
These operations "fork off" and run concurrently with whatever TwiML executes next. The call can proceed through multiple TwiML documents while the stream/recording remains active.
// Recording starts and continues through subsequent TwiML
const start = twiml.start();
start.recording({
recordingStatusCallback: `https://${context.DOMAIN_NAME}/recording-complete`,
recordingStatusCallbackEvent: 'completed',
});
twiml.say('This is being recorded...');
twiml.redirect('/next-handler'); // Recording continues!Key Implications
- Updating participant TwiML exits current state: If a participant is in a conference and you update their call with new TwiML, they immediately exit the conference and execute the new TwiML.
- Conference teardown risk: If the exiting participant had
endConferenceOnExit=true, the entire conference tears down - appearing as a "dropped call" to other participants. - Call transfer in conference context: "Transfer" means adding a new participant to the existing conference, NOT replacing TwiML. The original parties stay in the conference.
Safe Conference Transfer Pattern
// "Transfer" a call by adding a new party to the conference
// Original caller and agent stay in conference with the new party
// 1. Agent is on call with customer in conference "support-12345"
// 2. Agent wants to bring in specialist
// Add specialist to existing conference (they join, nobody leaves)
await client.conferences('support-12345')
.participants
.create({
from: context.TWILIO_PHONE_NUMBER,
to: specialistNumber,
startConferenceOnEnter: true, // Start immediately
endConferenceOnExit: false // Don't end when they leave
});
// 3. All three parties now in conference
// 4. Agent can drop off by having their participant removed:
await client.conferences('support-12345')
.participants(agentCallSid)
.update({ status: 'completed' });Dangerous Pattern (Avoid)
// DON'T: Update participant with new TwiML - exits them from conference
await client.calls(participantCallSid)
.update({
twiml: '<Response><Dial>+15551234567</Dial></Response>'
});
// This removes them from conference and may tear it down!Logging and Response Rules
Twilio Functions generate debugger alerts based on log level:
| Log Level | Alert Code | Effect |
console.log | None | Silent — use for all operational logging |
console.warn | 82004 | Generates warning alert — never use |
console.error | 82005 | Generates error alert — never use |
Use console.log for all logging, including error conditions and catch blocks.
Response bodies: Always pass a string to Twilio.Response.setBody(), not a plain object. Use JSON.stringify() and set Content-Type: application/json. Passing an object causes Buffer.from(object) TypeError in the runtime.
// WRONG — triggers Buffer TypeError
response.setBody({ success: true });
// RIGHT — explicit JSON serialization
response.appendHeader('Content-Type', 'application/json');
response.setBody(JSON.stringify({ success: true }));Gotchas
Env Vars Can Reset on Deploy
twilio serverless:deploy doesn't preserve runtime env vars set via the Console or CLI. Always verify env vars after deployment and re-set any that were added outside of .env.
<Start><Recording> Syntax is .recording(), Not .record()
The correct TwiML builder syntax is twiml.start().recording({...}). Using .record() is a different verb entirely (<Record>, which has different behavior — see below).
Conference Has No Parent/Child Relationships
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.

