Twilio Markup Language (TwiML)


TwiML, or the Twilio Markup Language, is an XML based language which instructs Twilio on how to handle various events such as incoming and outgoing calls, SMS messages and MMS messages.  When building a Twilio application you will use TwiML when communicating your desired actions to Twilio.


TwiML is the Twilio Markup Language, which is just to say that it's an XML document with special tags defined by Twilio to help you build your SMS and voice applications. TwiML is easier shown than explained. Here's some TwiML you might use to respond to an incoming phone call:

<?xml version="1.0" encoding="UTF-8"?>
    <Say>Thanks for calling!</Say>

And here's some TwiML you might use to respond to an incoming SMS message:

<?xml version="1.0" encoding="UTF-8"?>
    <Message>We got your message, thank you!</Message>

すべてのTwiMLドキュメントはルートの<Response>要素と、その中に含まれるひとつ以上の動詞からなります。 動詞とは、電話をかけてきた人にあいさつする<Say>や、受信メッセージへの返信としてSMSを送信する<Message>といったような、Twilioにおこなってほしいアクションのことです。 TwiMLで実行できることがあまねく網羅されたリファレンスについては、TwiML APIリファレンスを参照してください。

An Extensible, Powerful and Easy to Use Language

TwiML is, at it's core, a fun language to write.

Based on XML, eXtensible Markup Language, (just like HTML) it's also very simple to learn and write. Twilio's secret sauce is working to make it a very powerful language.

How powerful? Think allow customer service agents to transfer a caller in a support conference call without dropping it in under ten lines of code powerful.

* See our tutorials which include everything from basic to advanced TwiML constructs *

How Does TwiML Work?

TwiML is composed of a number of verbs and nouns which act as instructions for Twilio. Those verbs include:

  • Say - テキストを読み上げます。
  • Play - 発信者に音声ファイルを再生します。
  • Dial - 通話に参加者を追加します。
  • Record - 発信者の声を録音します。
  • Gather - 発信者がキーパッドでダイヤルした数字を収集します。
  • Sms - 通話中に SMS メッセージを送信します。
  • Hangup - 通話を終了します。
  • Queue - 発信者をキューに追加します。
  • Redirect - コールフローを別の TwiML 文書へリダイレクトします。
  • Pause - 次の指示を実行する前にポーズを挿入します。
  • Reject - 着信通話を拒否します。通話は課金されません。
  • Message - MMS もしくは SMS メッセージに返信します。

Nouns generally are acted on by a verb or will modify the verb's behavior. For example, the Message verb will send a text message but the text inside the tags and Body, and Media are nouns which change exactly what Twilio will do. Depending on how you use the nouns, the Message might be a SMS, multiple SMSes, or an MMS.

Click on individual verbs to see the nouns available.

How Do I Use TwiML?

TwiML is the primary language used to control actions on Twilio and is especially powerful when combined with our products such as Programmable SMS and Programmable Voice.

Your application will return TwiML in response to various events. Some of those events might be an incoming phone call or SMS, or perhaps a change in delivery status for a SMS your application sent.

Can I Use TwiML Without Writing Code?

Yes! We encourage you to look at TwiML Bins, Twilio's serverless (and codeless) solution to letting you write TwiML. It's the most frictionless way to start using Twilio: don't worry about spinning up a new VPS or exposing a route to your development machine. TwiML Bins allow you to quickly prototype your app - or even run it in production directly from our servers.

For those of you who are writing code, the Twilio helper libraries will automatically create valid TwiML for you. If you don't use one of our primary languages, don't sweat it! We've included curl commands and raw TwiML with most of our examples so you can call the API or return TwiML from your language of choice.

Ready to Start Exploring TwiML?

We know you're going to like TwiML as much as we do. Sign up for a Twilio account and try TwiML bins, follow one of our tutorials, or hop right into the SDKs.




Please select the reason(s) for your feedback. The additional information you provide helps us improve our documentation:

Sending your feedback...
🎉 Thank you for your feedback!
Something went wrong. Please try again.

Thanks for your feedback!

Refer us and get $10 in 3 simple steps!


Get link

Get a free personal referral link here


Give $10

Your user signs up and upgrade using link


Get $10

1,250 free SMSes
OR 1,000 free voice mins
OR 12,000 chats
OR more