Using Messenger as Google sheets interface using Python Flask

let’s start by building the webhook:

pip3 install Flask
pip3 install pymessenger
from flask import Flask, requestapp = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def receive_message():
return "Hello World!"
if __name__ == '__main__':
VERIFY_TOKEN = 'access_token'
@app.route("/", methods=['GET', 'POST'])
def receive_message():
if request.method == 'GET':
"""Before allowing people to message your bot, Facebook has implemented a verify token
that confirms all requests that your bot receives came from Facebook."""
sent_verify_token = request.args.get("hub.verify_token")
if sent_verify_token == VERIFY_TOKEN:
return request.args.get("hub.challenge")

Now we need to create a Facebook page and an app to link it to the webhook:

Ready to connect your webhook to the app? let’s do it:

ngrok http 5000

Note: if you get bad gateway response 502 that’s because you’re not running the flask development server

VERIFY_TOKEN = 'access_token'



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store