English · IndiaLog in
Rackwave Technologies
Request quote Free consultation
IntegrationUpdated 26 Nov 2026

Twilio Programmable Voice: TwiML, IVR and Call Control

Twilio Programmable Voice: TwiML, IVR, callbacks, regulation and cost.

Written by Ananya Iyer
  • Published25 Nov 2026
  • Read time6 min
  • Length1,296 words
Share this guide

What is Twilio Programmable Voice? Twilio Programmable Voice is a set of APIs and tools for making, receiving and controlling phone calls from software. You can place outbound calls, answer inbound calls on Twilio numbers, play messages, collect keypad input, record, transfer, run conferences and connect to existing phone systems over SIP. Behaviour is controlled by instructions called TwiML or by the API, and events are reported by webhooks. This guide explains how calls flow, what TwiML looks like, how to build menus and click-to-call, how call authentication and compliance affect outbound calling, how to monitor quality and cost and the mistakes to avoid. Features and rules change, so confirm details in current Twilio documentation and local regulation.

Short answer: Voice calls are controlled by TwiML instructions returned from your webhook or by API calls. Use status callbacks, keep logic idempotent, follow calling regulations and authentication rules and monitor quality and cost.

How a call works

When a call arrives at a Twilio number, Twilio makes an HTTP request to your webhook asking what to do. Your server responds with TwiML, a simple XML language, such as play a greeting, gather a keypress or dial another number. For outbound calls, your application calls the API with a destination and a URL that holds the instructions. The model is the same as for messaging in programmable SMS and relies on webhooks. For the platform overview see what is Twilio.

Twilio voice flow diagram
Figure 1. Twilio voice flow: caller, twilio, twiml and how they relate.

Common TwiML instructions

InstructionWhat it does
SaySpeaks text using text-to-speech
PlayPlays an audio file
GatherCollects keypad digits or speech
DialConnects the caller to another number, client, SIP endpoint or conference
RecordRecords the caller
Redirect and RejectSends the call to another instruction set or rejects it
Hangup and PauseEnds the call or waits

Combine these to build menus, voicemail, call forwarding and recorded notifications.

Typical use cases

  • Interactive voice response menus that route callers by keypress or speech.
  • Click-to-call buttons that connect a web user and an agent.
  • Automated reminders and notifications by phone call.
  • Call masking, where two parties talk without seeing each other numbers.
  • Conferencing and call recording for training and compliance.
  • Connecting a company phone system through SIP trunking. See system integration.

How to build a simple IVR

  1. Buy or port a number. Choose a number type suited to your country and use case.
  2. Point the number at your webhook. Set the voice URL to an HTTPS endpoint you control.
  3. Return a greeting and menu. Use Say or Play with Gather to collect a choice.
  4. Route the call. Dial the right team or queue, or play information.
  5. Handle no input and errors. Repeat the menu, then fall back to an agent or voicemail.
  6. Record and log. Store call identifiers, choices and outcomes.
  7. Test. Call from different networks and check timing and audio quality.

Status callbacks and call data

Each call has a lifecycle, such as queued, ringing, in progress, completed, busy, no answer and failed. Status callbacks send these events to your server so you can update records, trigger follow-up actions and calculate duration. Store the call identifier with your customer or case record. Use the logs and quality insights to investigate complaints, and keep recordings and transcripts under clear retention rules.

Regulation and call authentication

  • Outbound calling is regulated. Rules cover consent, do-not-call lists, calling hours, recording notices and automated or pre-recorded calls.
  • In the United States, call authentication frameworks such as STIR and SHAKEN help prove caller identity, and unauthenticated or flagged calls may be labelled or blocked.
  • Register your numbers and brand information where programmes exist, and use accurate caller IDs.
  • Recording laws differ by country and region, so tell callers and obtain consent where required.
  • Keep records of consent and call purposes. See GDPR for data protection duties.

Seek legal advice for your markets before running outbound campaigns.

Quality and cost

TopicWhat to do
Audio qualityMonitor latency, jitter and packet loss, and test on mobile and landline networks
Answer ratesUse accurate caller ID, sensible calling windows and reputation monitoring
CostCalls are billed by minute and destination, plus number fees, so review rates by country
Recording and storageSet retention and delete what you do not need
LimitsPlan concurrent call capacity and queue high-volume dialling

Set budgets and alerts to catch bugs that place unexpected calls.

Designing menus people can use

  • Keep menus short, with no more than four or five options and the most common choice first.
  • Offer a way to reach an agent at any point, such as pressing zero.
  • Use clear, natural prompts and test them with real callers, because prompts that sound clear on paper can confuse.
  • Support speech input where useful, with a keypad fallback for noisy environments.
  • Announce recording and give information about wait time or callback options.
  • Measure where callers abandon the menu and simplify those steps.

Click-to-call and callback patterns

PatternHow it worksUse
Click to callYour server calls the agent first, then connects the customerSales and support from a web page
Scheduled callbackThe customer chooses a time and the system calls both partiesReduce waiting and abandoned calls
Call maskingA temporary number connects two parties without exposing their own numbersMarketplaces, delivery and ride services
Voice notificationsAn automated message is played with an option to respondUrgent alerts and confirmations
ConferenceSeveral parties join one callTeam calls and escalations

Each pattern has consent and cost implications, so confirm the rules for the countries involved.

Testing and operations

  1. Create a test number and script that exercises every menu option and failure path.
  2. Test webhook downtime and slow responses and confirm fallbacks work.
  3. Call from mobile and landline networks in each region you serve.
  4. Monitor call volume, failure rate and average duration in dashboards.
  5. Set up an on-call route for voice incidents and rehearse it.

Voice problems are noticed instantly by customers, so operational readiness matters more than it does for asynchronous channels. See system integration for how voice connects to CRM and case systems.

Common mistakes

  • No fallback when the webhook is down, so callers hear an error.
  • Not handling no-input in menus.
  • Using unverified outbound numbers for volume dialling.
  • Recording calls without notice or consent.
  • Ignoring status callbacks, so records show the wrong outcome.

A worked example

A home services company wants a phone line that routes callers by service type and falls back to voicemail after hours. A Twilio number points to a server that returns a menu with Gather, checks business hours and dials the right team with a short ring timeout. Missed calls go to voicemail, which is transcribed and sent to a case record. A callback button on the website uses click-to-call to reach customers during working hours.

The team reduced missed calls and could finally see call outcomes in its CRM. The example is illustrative.

Best practices and support

  • Keep TwiML responses fast and idempotent, and set fallback URLs.
  • Verify webhook signatures and restrict who can change number settings.
  • Version the call flow code and test with automated call simulations where possible.
  • Review call logs weekly for failures and unusual patterns.

Our API development service builds voice workflows, and our system integration service connects calls to CRM and case systems.

Key takeaways

  • Calls are controlled by TwiML from your webhook or by API.
  • Build menus with Say, Gather and Dial.
  • Use status callbacks for outcomes and records.
  • Follow consent, recording and authentication rules.
  • Monitor quality, cost and failures.

Quick glossary

TermMeaning
TwiMLXML instructions that control calls
IVRInteractive voice response menu
SIP trunkConnection between a phone system and a provider
STIR and SHAKENCaller identity authentication framework
Status callbackEvent sent when call status changes

Read next: What Is API Management? Lifecycle, Features, Tools · What Is a Message Queue? Patterns and Best Practices · What Is RabbitMQ? Exchanges, Queues and Use Cases

Frequently asked questions

What is Twilio Programmable Voice?

A set of APIs for making, receiving and controlling phone calls from software.

What is TwiML?

An XML-based language you return from a webhook to tell Twilio what to do with a call, such as Say, Gather or Dial.

How do I build an IVR?

Point a number to a webhook that returns a greeting with Gather, then route the caller based on the input.

How do I know a call ended?

Use status callbacks, which report events such as completed, busy, no answer or failed.

Can I record calls?

Yes, but you must follow recording consent and retention rules for each country and region.

What is STIR and SHAKEN?

A US framework for authenticating caller identity to reduce spoofed calls.

Can I connect my existing phone system?

Yes, through SIP trunking and related connectivity options.

How is voice billed?

Usually per minute by destination and call type, plus monthly fees for numbers. Check current pricing.

Was this guide helpful?Your answer helps us decide what to improve. It is not linked to you.

#twilio programmable voice#twiml#twilio ivr#twilio voice api#click to call twilio

About the author

Ananya Iyer

CRM Strategy Consultant

Ananya advises clients on CRM platform selection and digital transformation roadmaps, sitting at the intersection of business process and technical implementation.

CRM Strategy & Digital Transformation

Ready to put AI and data to work?

Book a free consultation and leave with a plan, not a pitch.

Get a free consultationRequest quote