TwiML App - Invoke AWS Lambda when user replies STOP / START for Twilio Number

耗尽温柔 提交于 2019-12-04 05:26:56

问题


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

Adding TwiML App to my Twilio Phone Number

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:

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


回答1:


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.



来源:https://stackoverflow.com/questions/38370533/twiml-app-invoke-aws-lambda-when-user-replies-stop-start-for-twilio-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!