You need python 3.6 or 3.7 and pip
- pip install -r requirements.txt
- pip install flask
- On Mac:
FLASK_APP=application.py flask run
. On Window:set FLASK_APP=application.py && flask run
- Then go to http://localhost:5000/api/train to train data
- http://localhost:5000/api/messages?q=Hi to test
- You can use MS Bot Framework Emulator to test it as well. Use URL: http://localhost:5000/api/messages to connect if you want to test it locally.
- Create Azure account. You will need valid credit card for it.
- Create resource group: e.g. "BotGroup"
- Create Bot Channels Registration
- Get APP_ID and APP_SECRET from Bot Channels' Settings under Microsoft App Id.
- Create App Service with python
- Use Deployment Center and select your source code from github
- Select App Service build service
- Add APP_ID and APP_SECRET to Configuration > Application settings > New application setting
- Go back to Bot Channels' Settings and update Endpoint URL e.g. https://pythonchatbot.azurewebsites.net/api/messages
- Install azure-cli
- az login
- open az_deploy.sh and update gitrepo, webappname and group
gitrepo=https://github.com/huan-mai/pythonchatbot/
webappname=pythonchatbot1
group=BotGroup1
- chmod +x ./az_deploy.sh
- ./az_deploy.sh
Follow this article to integrate the bot to Slack.
Notes:
- We can ignore "Add and Configure Interactive Messages" and "Create an Add to Slack button" step
- For
{YourBotHandle}
field in "Subscribe to Bot Events" step, we can grab it fromSettings
screen of theBot Channels Registration
- If you get
[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed
error when runningpip install
command, download the pem file from http://curl.haxx.se/ca/cacert.pem, then run the command with--cert
parameter. Example:pip --cert /path/to/cacert.pem install linkchecker
(Reference: https://stackoverflow.com/questions/25981703/pip-install-fails-with-connection-error-ssl-certificate-verify-failed-certi/26062583)