- API & Docs
Twilio behaves just like a web browser, so there's nothing new to learn.
Twilio will keep cookie state across multiple SMS messages between the same two phone numbers. This allows you to treat the separate messages as a conversation, and store data about the conversation, such as a session identifier, in the cookies for future reference. Twilio will expire the cookies for that conversation after four hours of inactivity.
Twilio does the right thing when your application responds with different mime types.
|text/xml, application/xml, text/html||Twilio interprets the returned document as a TwiML XML Instruction Set. See the XML Verbs section for details. This is the most commonly used response.|
|text/plain||Twilio returns the content of the text file to the sender in the form of a SMS message.|
The root element of a TwiML document is always
<Response>. When Twilio interprets a TwiML document it starts at the top and executes verbs in the order they are placed in the document. For example, Twilio will respond with a SMS message containing "Hello World".
<?xml version="1.0" encoding="UTF-8" ?> <Response> <Sms>Hello World</Sms> </Response>
You can provide multiple
<Sms> verbs in one document to send multiple messages. For example:
<?xml version="1.0" encoding="UTF-8" ?> <Response> <Sms>This is message 1 of 2.</Sms> <Sms>This is message 2 of 2.</Sms> </Response>
There are certain situations when elements in a TwiML document may not be reached because control flow has passed to a different document. For example, if a
<Redirect> verb is followed by a
<Sms> will not be reached as Twilio will fetch TwiML at the specified redirect URL.