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/
Please explain how to develop the 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')
When you get the payload in webhook, it should always return a 200 ok HTTP JSON response. Sample 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"
}
}
Aucun commentaire:
Enregistrer un commentaire