'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
France Dernières Nouvelles, France Actualités
Similar News:Vous pouvez également lire des articles d'actualité similaires à celui-ci que nous avons collectés auprès d'autres sources d'information.
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
Lire la suite »
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
Lire la suite »
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.
Lire la suite »
Adventures of Huckleberry Finn: Chapter IX | HackerNoonAdventures of Huckleberry Finn, by Mark Twain (Samuel Clemens) is part of HackerNoon’s Book Blog Post series.
Lire la suite »
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.
Lire la suite »
Andrus, Lowrie homer, A’s end 13-game skid against MarinersA’s beat their AL West rivals for the first time since last July.
Lire la suite »