Code Monkey home page Code Monkey logo

facebook-messenger-auto-reply-using-php-nlp's Introduction

Facebook Messenger Auto Reply using PHP - NLP

This conversational bot will learn and answer , also it will search Wikipedia for you! Implement this app on your web server and setup automated conversations on your facebook page.

Configurations

  • First, create an app on https://developer.facebook.com with messenger API and webhook API enabled.
  • Connect your app with your facebook page.
  • Then copy this repository into your PHP web server and update config.php with your database and Facebook App configurations.
    'host' => '',
    'username' => '',
    'password' => '',
    'databse' => '',
    'hubVerifyToken' => 'hub verify token you set',
    'page_id' => 'your page ID obtained from app settings',
    'accessToken' => 'access token provided for the app',
    'admin_sender_ID' => 'To obtain the sender ID, send a message to the bot, then check the database for your sender ID'

Run composer to install dependancies. (NLP Tools and other libraries)

composer install

Functionality

  • The bot will recieve a message
  • It will tokenize the message to check the cosine smilarity and try to get the most suitable answer from the database.
  • It will send the query response obtained after searching wikipedia for the word or set of words recieved, if the cosine similarity is lower.
  • The admin user can teach the bot by providing some example responses. This method can be used to train the bot for specific responses. Even you can put an imoji to the response. Currently the bot can not understand imojis other than "thumbsup".

How to train

Send a message like this,

learn <Question>,<Answer> 

Example:

learn what are the types of services you offer?, We provide industrial level web application development and API integration services.

Responses

Training: 'what are the types of services you offer?'
Message: 'send me the services you offer?'
Response: 'We provide industrial level web application development and API integration services.'

Wikipedia API

https://en.wikipedia.org/w/api.php?action=query&prop=extracts&exlimit=max&format=json&exsentences=1&origin=*&exintro=&explaintext=&generator=search&gsrlimit=23&gsrsearch=chess

Demo

Master Wiki (Messenger) : http://m.me/wikipedia.lk

Master Wiki (Web): http://masterwiki.lankahot.net/

Contributions

Please contribute to make this more creative. For the repository and do the changes, then send me a pull request mentioning your changes and results. Feel free contact me for any clarifications.

facebook-messenger-auto-reply-using-php-nlp's People

Contributors

asirihewage avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.