Twilio webhook sms response format

2019-06-24 12:48发布

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

1条回答
放荡不羁爱自由
2楼-- · 2019-06-24 13:34

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.

查看更多
登录 后发表回答