Code Monkey home page Code Monkey logo

messenger-chatbot's Introduction

Facebook Messenger ChatBOT

Flask based HTTP application to consume / provide data to a real time Facebook Messenger chat bot.

Demo The project is up and running for demo purposes: ProjectDemo

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Linux system: Ubuntu 16.04 (Xenial) or later
python 3.5
pip

Installing

Clone source code from git repo

$ git clone https://github.com/fernandorovai/Messenger-ChatBOT

Setup and activate virtual environment

$ virtualenv Messenger-ChatBOT -p python3
$ cd Messenger-ChatBOT
$ source ./bin/activate

Install python dependencies via pip

$ pip install -r requirements.txt

Running the Server

Start the webserver

Facebook requires ssl certificate.
Setup ssl credentials in context variable (server.py):
context = ('/path/fullchain.pem',
           '/path/privkey.pem')

obs: if your credentials are in root dir, you may have to install the dependencies also using root

$ cd Messenger-ChatBOT
$ python3 server.py or sudo python3 server.py

Expected output

 * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)

Principal Methods

  • sendCarouselMsg(sender_id, elements)
# elements structure
elements = [
                {'subtitle': 'Price or a subtitle', 
                 'buttons': [{'url': 'url', 'type': 'web_url', 'title': 'Ver Detalhes'}], 
                 'image_url': 'imageUrl', 
                 'title': 'Product Title'}, 
                {...}
             ]
  • sendQuickReply(sender_id, quickReplies)
quickReplies = [{"content_type": "text","title": "Lustres","payload": "lustres"},
                {"content_type": "text","title": "Embutidos","payload": "embutidos"},
                {"content_type": "text","title": "Ir para Categorias","payload": "categorias"}]
  • sendTypingBubble(sender_id)
  • getPersonInfo(sender_id)
  • callSendAPI(sender_id, {"text": "yourText"})

Keywords / Phrases

This bot uses pre-defined keywords to chat. These keywords are found in keywords.py file. In order to advance its intelligence, consider using RNN (Recurrent Neural Networks).

Products Data

The file data.py holds all products offered by the bot. All products information belongs to HunterTrade company that authorized the usage for this demonstration. Consider retrieving information from database / API.

Deployment

Flask’s built-in server is not suitable for production. Consider deploying the application to a WSGI Server. For more information, check Flask Documentation

Built With

  • Flask - Microframework for Python
  • Pip - Dependency Management
  • Nltk - Natural Language Toolkit

Authors

  • Fernando Rodrigues Jr - Initial work - Fernando

messenger-chatbot's People

Contributors

fernandorovai avatar

Stargazers

Mana avatar

Watchers

James Cloos avatar  avatar Emiliano avatar

Forkers

dexterrlz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.