Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twilio webhook sms response format

I'm using Twilio with my app and I have sms webhooks with my SMS numbers configured with URL. Everything is working except that Twilio send me an error in logs for each requests. I suppose that the response from my app is not well formated but I can't find on documentation how to format using JSON.

Can someone help me ? :)

Thanks, Gabriel

like image 271
Gabriel METZGER Avatar asked Apr 22 '16 11:04

Gabriel METZGER


People also ask

How do I reply to Twilio SMS?

When you send an SMS message to your Twilio phone number, Twilio will send a webhook, an HTTP request with all the details about the message, to a URL you associate with that number. You can reply to the message by responding to the webhook with TwiML (Twilio Markup Language).

How are webhooks used in Twilio?

Twilio uses webhooks to let your application know when events happen, such as receiving an SMS message or getting an incoming phone call. When the event occurs, Twilio makes an HTTP request (usually a POST or a GET) to the URL you configured for the webhook.

Can you reply to a web SMS?

The Web SMS interface allows you to do the following: Send SMS messages to individual or multiple recipients. Create and manage contacts and groups. Receive replies to messages you have sent.

What is webhook SMS?

Twilio can send your web application an HTTP request when certain events happen, such as an incoming text message to one of your Twilio phone numbers. These requests are called webhooks, or status callbacks. For more, check out our guide to Getting Started with Twilio Webhooks.


1 Answers

Twilio developer evangelist here.

When you return a webhook message to Twilio, you need to make sure it's valid TwiML, which in essence is just a set of XML verbs Twilio uses.

If you're responding to an SMS message for example, you would return TwiML as follows:

<?xml version="1.0" encoding="UTF-8"?>
<Response>
    <Message>Thanks for getting in touch, I'll call you later</Message>
</Response>

You can test the code above by changing the configuration of your number to point to this url and you should stop seeing the errors.

If you generating the TwiML yourself, you need to make sure that the page's MIME type is text/xml.

Hope this helps you out.

like image 132
Marcos Placona Avatar answered Sep 23 '22 08:09

Marcos Placona