Webhook is created in Flask and hosted on the google cloud Platform.
Link to the web hook URL.
https://webhook-app-305615.df.r.appspot.com/
Payload To be received:
{
"uri" : "https://webhook-app-305615.df.r.appspot.com/",
"data" : {
"messagepreview" : "Hi",
"connectionname" : "919995669111",
"uri" : "whatsappsandbox://919995669111@2935e36-983a1b8",
"receiveraddress" : "919995669111",
"senderaddress" : "6585909227",
"attachment" : {
"value" : "Hi"
},
"timestamp" : 1563183428,
"attachmenttype" : "text",
"webhookaccesskey" : "abc-xyz",
"parts" : [{
"contentType" : "text",
"data" : "Hi",
"uri" : "",
"originalEvent" : "{\"from\":\"919995669111\",\"id\":\"ABEGkMT-o1QcQQ4GP\",\"text\":{\"body\":\"Hi\"},\"timestamp\":\"1563183428\",\"type\":\"text\",\"profile\":{\"name\":\"John\"}}"
}
],
"sender" : "whatsappsandbox://6585909227",
"receiver" : "whatsappsandbox://919995669111@whatsapp.com?name=John"
}
}
My Post Method:
from flask import Flask, jsonify, request
app = Flask(__name__)
@app.route('/')
@app.route('/api/echo-json', methods=[ 'POST'])
def add():
data = request.get_json()
return jsonify(status=200,info='OK')
Secondly, it should always return a 200 ok HTTP JSON response.
Please explain how to develop the post method.
What I have tried:
I have tried methods from the internet but I am a newbie.