I want to maintain seperate twilio phone unsubscribers list and this can be done when webhook is configured via twilio console to receive incoming messages. I would parse only those messages when some one types "STOP". I have successfully configured webhook
Now from my phone when i type "STOP" to my twilio number, I am receiving always bad request. My code looks as follows
@app.route('/twilio/unsubscribes_incremental', methods=['POST', 'GET'])
def phone_unsubscribes_incremental():
print("start")
print("The arguments are ", request.args)
payload = request.get_json(force=True)
print("The payload is ", payload)
#resp = MessagingResponse()
if payload.get('Body') in twilio_unsubscribe_list:
stream_data_to_bq(payload)
#resp.message("")
#return str(resp)
return jsonify({"status":"ok"})
My python console shows as follows
My ngrok console shows as follows
My twilio console logs shows as follows
For some reason iam unable to parse request object sent to my webhook. This account is in free trial. Can any one point out to me right documentation to parse incoming messages.
The webhook is application/x-www-form-urlencoded
For inbound text messages, Twilio will send an HTTP POST request to your server with a body that uses the application/x-www-form-urlencoded encoding. View the list of parameters sent in that request.