設計一個chatbot將使用者拆分為 1. 學習咖啡知識者 2. 消費者 若為學習咖啡者,可透過輸入特定關鍵字,來學習咖啡豆、咖啡相關器材等知識 若為消費者,可根據菜單上有什麼品項並輸入後,作為點餐的方式
In every states if the bot doesn't know the input message, it will reply 請重新輸入
The initial state is set to beginner
.
The state of being a coffee player. You can input some keywords here, for example
* Input : "咖啡豆"
* Reply : "分為兩種,羅布斯塔與阿拉比卡"
* Input : "手沖工具"
* Reply : "手沖壺、濾紙、濾杯、磨豆機"
The state of being a coffee master. You are already have enough knowledge.
The state of begin a customer in coffe shop. You can input some keywords here, for example
* Input : "美式"
* Reply : '美式為100元'
* Input : "拿鐵"
* Reply : '拿鐵為120元'
The state of being a space state.
A Line bot based on a finite state machine
More details in the Slides and FAQ
- Python 3.6
- Pipenv
- Facebook Page and App
- HTTPS Server
pip3 install pipenv
pipenv --three
pipenv install
pipenv shell
- pygraphviz (For visualizing Finite State Machine)
You should generate a .env
file to set Environment Variables refer to our .env.sample
.
LINE_CHANNEL_SECRET
and LINE_CHANNEL_ACCESS_TOKEN
MUST be set to proper values.
Otherwise, you might not be able to run your code.
You can either setup https server or using ngrok
as a proxy.
or you can use Homebrew (MAC)
brew cask install ngrok
ngrok
would be used in the following instruction
ngrok http 8000
After that, ngrok
would generate a https URL.
python3 app.py
Or You can use servo to expose local servers to the internet.
Setting to deploy webhooks on Heroku.
or you can use Homebrew (MAC)
brew tap heroku/brew && brew install heroku
or you can use Snap (Ubuntu 16+)
sudo snap install --classic heroku
-
Register Heroku: https://signup.heroku.com
-
Create Heroku project from website
-
CLI Login
heroku login
-
Add local project to Heroku project
heroku git:remote -a {HEROKU_APP_NAME}
-
Upload project
git add . git commit -m "Add code" git push -f heroku master
-
Set Environment - Line Messaging API Secret Keys
heroku config:set LINE_CHANNEL_SECRET=your_line_channel_secret heroku config:set LINE_CHANNEL_ACCESS_TOKEN=your_line_channel_access_token
-
Your Project is now running on Heroku!
url:
{HEROKU_APP_NAME}.herokuapp.com/callback
debug command:
heroku logs --tail --app {HEROKU_APP_NAME}
-
If fail with
pygraphviz
install errorsrun commands below can solve the problems
heroku buildpacks:set heroku/python heroku buildpacks:add --index 1 heroku-community/apt
refference: https://hackmd.io/@ccw/B1Xw7E8kN?type=view#Q2-如何在-Heroku-使用-pygraphviz
TOC-Project-2019 ❤️ @winonecheng
Flask Architecture ❤️ @Sirius207