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
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).
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With