TwiML App - Invoke AWS Lambda when user replies ST

2019-03-01 03:39发布

Here is my scenario: I am using Twilio to send SMSes to my clients. When user decides not to receive these SMSes they reply STOP and START to receive again. This is automatically handled by Twilio. But, i need to invoke a AWS Lambda function and update my database accordingly.

This is what i am doing till now: 1. I have created a TwiML App 2. I have added this TwilML App to my Twilio number. 3. Created a Lambda Function and API Gateway. Added the end-point in TwiML App.

Adding AWS Lambda - API Gateway to TwiML App enter image description here

Adding TwiML App to my Twilio Phone Number enter image description here

I am getting the SMS Logs saying that the user has sent START/STOP from his phone number, but, the Lambda function is not getting invoked.

Here is the SMS Log from Twilio: enter image description here enter image description here enter image description here enter image description here

Can someone help me understand what's going wrong? And what it means when the response is "Unsupported media type"?

1条回答
狗以群分
2楼-- · 2019-03-01 04:01

If you're using Java code for your TwiML app, have you specified the XML content type for TwiML as such:

    response.setContentType("application/xml");
    response.getWriter().print(twiml.toXML());

That could be one of a handful of causes as explained in the link from the comments.

查看更多
登录 后发表回答