'Build a WhatsApp Chatbot With Python, Flask, and Messagebird' python whatsapp
Step 2: Create an Environment
Activate the virtual environment in Linux and MacOS with, replace whatsappbot with the name of the environment you created in step 2:For Windows, activate the virtual environment with, replace whatsappbot with the name of the environment you created in step 2:pip install Flask messagebird requests gunicorn jinja2 werkzeug urllib3
from flask import Flask app=Flask @app.route def bot: #webhook logic if __name__==‘__main__’: app.runOn WindowsThe first thing we need to do in our chatbot is to obtain the message entered by the user. This message comes in the payload of theimport jsonfrom flask import Flask, jsonify, request import requests app=Flask @app.route def hello: return “Bot is alive!” @app.route def bot: data=request.json message=data[“message”][“content”][“text”].
import requests reqUrl=“https://conversations.messagebird.com/v1/webhooks"headersList={ “Authorization”: “AccessKey MESSAGEBIRD_ACCESS_KEY”, “Content-Type”: “application/json” } payload=json.dumps response=requests.request printDeploying a WhatsApp bot to HerokuInside the Procfile add.Requirements.txt add the following replacing with the actual versions you are using
Canada Latest News, Canada Headlines
Similar News:You can also read news stories similar to this one that we have collected from other news sources.
Developing, Packaging and Distributing a Python Library | HackerNoonHow to use new packaging standards with virtual environment tools — adapted from the official documentations of python.org and Pipenv
Read more »
Developing, Packaging and Distributing a Python Library | HackerNoonHow to use new packaging standards with virtual environment tools — adapted from the official documentations of python.org and Pipenv
Read more »
Great Expectations: Chapter VII | HackerNoonGreat Expectations by Charles Dickens is part of HackerNoon’s Book Blog Post series. You can jump to any chapter in this book here.
Read more »
Adventures of Huckleberry Finn: Chapter IX | HackerNoonAdventures of Huckleberry Finn, by Mark Twain (Samuel Clemens) is part of HackerNoon’s Book Blog Post series.
Read more »
Moby-Dick; or The Whale: Chapter 15 - Chowder | HackerNoonMoby-Dick; or The Whale, Chapter 15: Chowder by Herman Melville is part of HackerNoon’s Book Blog Post series.
Read more »
Andrus, Lowrie homer, A’s end 13-game skid against MarinersA’s beat their AL West rivals for the first time since last July.
Read more »