Skip to content

Elcid-Chawa/mybot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mybot

This is a test messenger bot app build with Python - Flask library. It connects to a facebook page via a token and respose to messages sent by clients to the facebook page.

Setup Requirements

  • Python 3.6 or higher
  • Flask
  • pymessanger
  • ptyhon-dotenv
  • ngrok

Environment Setup

Install Libraries

  • Install python libraries to run project
pip3 install -r requirements.txt
  • Download ngrok
  • Login to ngrok from your browser.
  • Follow instructions here to connect to your account from your local machine.

Facebook App Setup

  • Login/Register to Facebook Developers site
  • Create a new app create
  • Select Business app type then Click Continue select
  • Enter app name and Contact email Then click Create APP select
  • Select the Product Messenger and Click SetUp product
  • Create new facebook page or Add an Existing Page where you will use the bot. page
  • Generate an Access Token for the page. Copy and keep this token secrete and do not share with any one. token

Running the App

  • We would clone this repo

  • Navigate to the project root folder

  • create a .env file with fields

    • -> VERIFIER_JETON="add any verificatio message here"
    • -> PAGE_ACCESS_TOKEN="add the token generated from facebook here"
  • Now run the flask app

FLASK_APP=mybot.py flask run

flask

  • Navigate to where you downloaded the ngrok application and run ngrok.
./ngrock http 5000

ngrok

  • Copy the Fowarding url with https
https://230696fa7855.ngrok.io
  • Go back to your facebook app settings and Edit the Webhook webhook
  • Insert the url you coppied adding /webhook to hit the webhook endpoint served by the app
https://230696fa7855.ngrok.io/webhook

verify

  • Save the configurations. The webhook config page should close without errors.
  • You should see a message from your flask app terminal showing your conncetion was successfull. verified
  • Now send a message to your faceboog page and it should respond to you directly.

About

Test messenger bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages