See what you can build with Twilio

Play with a phone menu demo and see how it works.

Call (555) 555-5555 and enter code 555
Notice: session expired

To generate a new keyword, please refresh this page.

Ahoy, there!

Give us a call at (555) 555-5555 and enter "5555". This will pair your call to this text editor. Next, we'll customize the message you hear when you call into the IVR.

Next: Customize the phone menu

On the line? Great, you should hear the welcome message over there. You can make changes to this welcome message and call back or press * to hear your edits.

Awesome! Next, we'll dive into the instructions you can use to tell Twilio how you want it to handle calls.

Next: 👋 TwiML

The way you control calls on Twilio is with TwiML, the Twilio Markup Language. Your TwiML code tells Twilio what to do when your app receives a new phone call. You can write TwiML with raw XML or use your preferred server-side language (and our helper libraries) like we have on the right 👉below 👇.

The TwiML verb <Say> tells Twilio to read this dynamic text to the caller, and offers more than 50 voices in 25 languages. To play any type of audio file like a pre-recorded messages or music to your callers, use <Play> instead.

The TwiML verb <Gather> will collect digits or transcribe the caller's speech. When the caller is done, Twilio submits the data to the provided `action` URL.

Next: Pick the command you'd like to learn more about: <Dial>, <Record>, or SMS

The <Dial> verb will route your caller to the right place, whether that’s to another number, conference call, agent, or even a Programmable Wireless SIM.

In this example we’re using <Dial> to route you over to the Twilio support IVR that our customers use to connect with our sales, support, and front desk teams.

Thanks for trying this out!

Sign up for your free Twilio account to get your own Twilio number and build your first programmable phone menu.

The <Record> verb records the caller's voice and returns to you the URL of a file containing the audio recording. You can also generate text transcriptions of recorded calls by setting the 'transcribe' attribute of the <Record> verb to 'true'.

Sign up for your free Twilio account to get your own Twilio number and build your first programmable phone menu.

In order to send an SMS based on actions taken in an inbound call, our application will make an HTTP POST request to the Messages list resource URI: /2010-04-01/Accounts/{AccountSid}/Message.

You can use SMS to send the caller a map to your store, survey them about their experience, or offer to text with your business rather than sit on hold.

Thanks for trying out this demo.

Sign up for your free Twilio account to get your own Twilio number and build your first phone menu.


using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "dtmf", numDigits: 4);
gather.Say("Please enter the 4 digit code on your screen to get started");

response.Append(gather);

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Please enter the 4 digit code on your screen to get started.")
	.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF))
	.numDigits(4)
	.say(say)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
	input: 'dtmf',
	numDigits: '4',
});

gather.say('Please enter the 4 digit code on your screen to get started');

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'dtmf', 'numDigits' => '4']);
$gather->say('Please enter the 4 digit code on your screen to get started.');

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='dtmf', num_digits=4)
gather.say('Please enter the 4 digit code on your screen to get started.')

response.append(gather)

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.gather(numDigits: 4, input: 'dtmf') do |g|
    g.say(message: 'Please enter the 4 digit code on your screen to get started.')
  end
end

puts response

<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Please enter the 4 digit code on your screen to get started.</Say>
	</Gather>
</Response>

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "dtmf", numDigits: 1);
gather.Say("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you've made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.");

response.Append(gather);

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you&rsquo;ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.")
&#x9;.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF))
	.numDigits(1)
	.say(say)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
  input: 'dtmf',
  numDigits: '1',
});

gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'dtmf', 'numDigits' => '1']);
$gather->say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.');

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='dtmf', num_digits=1)
gather.say('Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you\'ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')

response.append(gather)

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
	r.gather(numDigits: 1, input: 'dtmf') do |g|
		g.say(message: 'Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR.')
	end
end

puts response

<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Welcome to the Twilio IVR! You can modify this message by changing this text in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR. </Say>
	</Gather>
</Response>

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

var gather = new Gather(input: "speech dtmf", numDigits: 1);
gather.Say("Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.");

var play = new Play(new Uri("http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3"));
gather.Append(play);

response.Append(gather);

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.")
	.build();

Play play = new Play.Builder("http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3")
	.build();

Gather gather = new Gather.Builder()
	.inputs(Arrays.asList(Gather.Input.DTMF, Gather.Input.SPEECH))
	.numDigits(1)
	.say(say)
	.play(play)
	.build();

VoiceResponse response = new VoiceResponse.Builder().gather(gather)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

const gather = response.gather({
	input: 'speech dtmf',
	numDigits: '1',
});

gather.say('Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.');

gather.play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3');

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$gather = $response->gather(['input' => 'speech dtmf', 'numDigits' => '1']);
$gather->say('Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.');
$gather->play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3');

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

gather = Gather(input='speech dtmf', num_digits=1)
gather.say('Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.')
gather.play('http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3')

response.append(gather)

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.gather(numDigits: 1, input: 'dtmf') do |g|
    g.say(message: 'Please choose from the following options. Press 1 or say “dial” to be connected to the Twilio support phone menu. Press 2 or say “record” to leave yourself a message. Press 3 or say “message” to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.')
    g.play(url: 'http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3')
  end
end

puts response

<Response>
	<Gather input="speech dtmf" numDigits="1">
	<Say>Please choose from the following options. Press 1 or say "dial" to be connected to the Twilio support phone menu. Press 2 or say "record" to leave yourself a message. Press 3 or say "message" to send yourself an SMS. While you choose your own adventure, here’s a lovely Chopin nocturne.</Say>
	<Play>http://com.twilio.sounds.music.s3.amazonaws.com/ith_chopin-15-2.mp3</Play>
	</Gather>
</Response>

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

response.Say("During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.");
response.Dial("+18448144627");

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.")
	.build();

Dial dial = new Dial.Builder("+18448144627")
	.build();

VoiceResponse response = new VoiceResponse.Builder()
	.say(say)
	.dial(dial)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

response.say('During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.');

response.dial('+18448144627');

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$response->say('During an active call, you can use the Dial verb to connect the current caller to another party. We\'re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.');
$response->dial('+18448144627');

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

response.say('During an active call, you can use the Dial verb to connect the current caller to another party. We\'re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.')
response.dial('+18448144627')

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.say(message: 'During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.')
  r.dial(number: '+18448144627')
end

puts response

<Response>
	<Say>During an active call, you can use the Dial verb to connect the current caller to another party. We’re now going to connect you to the Twilio support phone menu, which we built with these same TwiML verbs.</Say>
	<Dial>+18448144627</Dial>
</Response>

using Twilio.TwiML;
using Twilio.TwiML.Voice;
using System;

var response = new VoiceResponse();

response.Say("Please leave a message at the beep. Press the star key when finished.");
response.Record(transcribe:true, finishOnKey:"*");

Console.WriteLine(response.ToString());

import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.*;

import java.util.Arrays;

Say say = new Say.Builder("Please leave a message at the beep. Press the star key when finished.")
	.build();

Record record = new Record.Builder()
	.transcribe(true)
	.finishOnKey("*")
	.build();

VoiceResponse response = new VoiceResponse.Builder()
	.say(say)
	.record(record)
	.build();

System.out.println(response.toXml());

const VoiceResponse = require('twilio').twiml.VoiceResponse;
const response = new VoiceResponse();

response.say('Please leave a message at the beep. Press the star key when finished.');

response.record({
	transcribe: true,
	finishOnKey: '*'
});

console.log(response.toString());

<?php
require_once './vendor/autoload.php';

use Twilio\TwiML;

$response = new TwiML();

$response->say('Please leave a message at the beep. Press the star key when finished');
$response->record(['transcribe' => true, 'finishOnKey' => '*']);

echo $response;

from twilio.twiml.voice_response import VoiceResponse, Gather

response = VoiceResponse()

response.say('Please leave a message at the beep. Press the star key when finished.')
response.record(transcribe=True, finish_on_key='*')

print(response)

require 'twilio-ruby'

response = Twilio::TwiML::VoiceResponse.new do |r|
  r.say(message: 'Please leave a message at the beep. Press the star key when finished.')
  r.record(transcribe: true, finish_on_key: '*')
end

puts response

<Response>
	<Say>Please leave a message at the beep.Press the star key when finished.</Say>
	<Record transcribe="true" finishOnKey="*"/>
</Response>

using System;
using Twilio;
using Twilio.Rest.Api.V2010.Account;
using Twilio.Types;

const string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
const string authToken = "your_auth_token";

TwilioClient.Init(accountSid, authToken);

var to = new PhoneNumber("+15555555555");
var message = MessageResource.Create(
		to,
		messagingServiceSid: "MG9752274e9e519418a7406176694466fa",
		body: "Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality.");

Console.WriteLine(message.Sid);

import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;

Twilio.init(ACCOUNT_SID, AUTH_TOKEN);

Message message =
	Message.creator(new PhoneNumber("+15555555555"), "MG9752274e9e519418a7406176694466fa",
		"Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality.").create();

System.out.println(message.getSid());

client.messages
	.create({
		 body: 'Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality.',
		 messagingServiceSid: 'MG9752274e9e519418a7406176694466fa',
		 to: '+15555555555'
	 })
	.then(message => console.log(message.sid))
	.done();

<?php
require_once 'vendor/autoload.php';

use Twilio\Rest\Client;

$account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
$auth_token = 'your_auth_token';

$client = new Client($account_sid, $auth_token);

$message = $client->messages->create(
		"+15555555555",
		array(
			'messagingServiceSid' => "MG9752274e9e519418a7406176694466fa",
			'body' => "Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality."
		)
);

echo $message->sid;

from twilio.rest import Client

# put your own credentials here
account_sid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
auth_token = "your_auth_token"

client = Client(account_sid, auth_token)

client.messages.create(
	to="+15555555555",
	messaging_service_sid="MG9752274e9e519418a7406176694466fa",
	body="Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality."
)

require 'twilio-ruby'

# put your own credentials here
account_sid = 'ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
auth_token = 'your_auth_token'

# set up a client to talk to the Twilio REST API
@client = Twilio::REST::Client.new(account_sid, auth_token)

@client.messages.create(
  messaging_service_sid: 'MG9752274e9e519418a7406176694466fa',
  to: '+15555555555',
  body: 'Thank you for trying out our IVR demo! Feel free to call back and continue testing different functionality.'
)

<Response>
	<Gather input="dtmf" numDigits="1">
		<Say>Welcome to the Twilio IVR! You can modify this message by editing the TwiML in the text editor in your browser. Hang up and call back to hear the changes you’ve made or press * to restart this IVR with your changes. Press 2 to continue with the IVR. </Say>
	</Gather>
</Response>