Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:

JSON
{
    "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:

Python
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.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900