This is the Facebook Messenger chatbot for microwork made by group 6 for the course IN4325 Information Retrieval.
Go to the Facebook page and click 'Message' to chat with our bot. You need to be added as developer or tester of the Facebook app, otherwise it will give you the silent treatment. If you post your Facebook account name on our slack channel, we will add you as soon as possible.
The project directories and files are structured in the following tree:
setup.py
runs worker API, requester API and chatbotapi
apiserver.py
webserver that contains logic for the requester and worker APIdatabase.py
initializes database configurationmodel.py
datamodel used by both API'stests
integration tests for both API's
chatbot
api_helper.py
helper methods to call the worker APIchatbot.py
entry point of chatbot, uses messaging and logger functionalityfacebook_helper.py
helper methods to call Facebook API and Facebook-specific functionalitylocal_test.py
tests communication with chatbot without having to use the Facebook interfacelogger.py
wraps (heroku) logging functionalitymessaging.py
logic to handle the chatbot interaction flow by reading user messages and replying according to current chatbot state
pipelines
pipeline_1.py
pipeline for Albert Heijn Twitter WebCare evaluation task (Type 1: global content)pipeline_2.py
pipeline for Albert Heijn floor plan evaluation task (Type 2: local content)pipeline_3.py
pipeline for Albert Heijn store stocking evaluation task (Type 3: content generation)reviewPipeline.py
pipeline for generation of review tasks
The following paragraph describe how to set up the project to run and test it locally.
To run the chatbot (on Windows) execute the following steps:
- Make sure you have installed Python 3 (I used 3.6) and Heroku CLI. I also assume you have Git installed and know how it works.
pip install virtualenvwrapper-win
to install the virtualenv stuff we are going to use. For Unix you need to installvirtualenvwrapper
mkvirtualenv chatbot
to enter our virtual environment. It doesn't matter how you call it, but it's useful to remember how you call it.pip install -r requirements.txt
to locally install project dependencies in the virtual environment
If you run a Unix machine I assume you know how to adapt the above instructions to your own machine.
heroku git:remote -a fathomless-cove-38602
adds the Heroku app to the local git to push the code to. You need to be added to the Heroku app for this to work.- Execute
workon chatbot
to re-enter the virtual environment if you come back to develop. - Execute
git push heroku master
to deploy the chatbot to Heroku. In order to push a branch different than master to Heroku, executegit push heroku your-branch-name:master
. - You can run the chatbot locally with
heroku local
. This will allow you to run the application locally, with the heroku database. If you have MySQL installed you can also run the app with your local database. In order to do this you need to enter your database settings inapi/config/settings.json
, and run the server app withpython ./setup.py
.
- Once you have the app running locally you can run the API tests using
python -m unittest discover
.
To test the communication between the chatbot and facebook do the following:
- Add a new Environment variable to your machine, with name
PAGE_ACCESS_TOKEN
and as value the token which can be found in Heroku at Settings -> Config vars - Run the server locally as described above using the
heroku local
command, this will start the server at localhost:5000 - Start the chatbot/local_test.py script and follow the instructions