Author: Raphael Chevallier
For this assignment, I build a chat bot to mimic basic bartending needs. Built with basic functionality that can accept a text entry and respond with a logical statement. My bot uses a trained NLP engine to provide language understanding as well as spell checking, sentiment analysis, synonym recognition, and entity recognition to help create the best response to the user. The app is accessible through Facebook and can be easily interacted with through the messenger. I decided to use Facebook Messenger for the wide use of Messenger letting many people reach my chatbot with ease
The bartender chatbot uses facebook as a front-end. Communication with facebook is done through a nodeJS webhook that passes the message data to a python service (flask) which processes the user's message and responds accordingly. In order to readily communicate with facebook, the chatbot is currently installed and running on a dedicated linux server. The flask chatbot bartenderChatbot.py can run as a stand-alone chatbot service and hook into any kind of front end interface with minimal changes. The flask chatbot uses LUIS to understand the incoming text as best it can. Chat flow when user messages the bot follows the steps below.
- User messages chatbot on facebook
- Facebook API
- Nginx Forward proxy (for SSL termination)
- Node JS
- Flask chatbot receives message and uses NLP engine to respond
- NLTK/TextBlob - Python framework used for natural language processing
- LUIS.ai - NLP engine from Microsoft that can be trained by user
- Express.js - A javascript Node.js library that facilitates REST API creation
- Flask - Python web framework used to communicate with POST requests
As facebook requires for any app on their services to be reviewed, my chatbot app is not accessible to the public. Awaiting facebook to review an app may take a while so for the meantime I need to authorize test users to access the chatbot through messenger. If you wish to test our app please contact [email protected] and pass your facebook ID or username. Once approved we will send back an invite to that facebook id/username and you will need to direct yourself to https://developers.facebook.com/ and accept the invite to be a tester. Once accepted, travel to https://www.facebook.com/Bartender-Chatbot-310-594256287663533/ and message the page. The chatbot will respond back to you and will be fully functional to you.
Potential improvements to the system would be to implement a sort of memory system. It would be good to have the chatbot "remember" what it talks about to more smoothly follow a conversation
- NodeJS - NPM
- Python 3
- Flask
Example commands for installing the Chatbot on an Ubuntu or Debian server. Flask can be installed using pip. It would be good practice to use a python virtualenv if installing on a shared computer.
user@server:~$ apt install nodejs
user@server:~$ apt install npm
user@server:~$ apt install python3-pip
user@server:~$ pip3 install flask
user@server:~$ apt install git
user@server:~$ git clone https://github.com/RaphaelChevallier/Software-Eng-Chatbot-G7.git
user@server:~$ cd Software-Eng-Chatbot-G7/
user@server:~$ npm install
Once installed, run flask and node as background processes.
user@server:~$ nodemon webhook.js &
user@server:~$ python3 bartenderChatbot.py &
- User types into messenger page
- Chatbot system understands and produces a response
- Repeat
- User goes to messenger and types intent
- Node.js file takes input and gives clean json to python file
- Python file calls NLP engine LUIS and understands intent
- Python file formulates response based off understanding
- Sends response to user through clean Node.js file again
Limitations:
- Can't remember previous conversations so can't string very well certain sentences
- The sentiment analysis I get is very basic of positive, negative, or neutral
- Spell check isn't perfect
- The analysis of sentiment can be used as an API for other bots
- Entity recognition can also be used for other bartender chatbots
- The spell check can
- The NLP engine can be used for training
- The weather topic can be used and shared to get weather in sourroundings