A telegram bot based on a finite state machine.
In this final project, I can communicate with my telegram chatbot.
- Python 3
pip install -r requirements.txt
- pygraphviz (For visualizing Finite State Machine)
API_TOKEN
and WEBHOOK_URL
in app.py 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.
ngrok
would be used in the following instruction
ngrok http 5000
After that, ngrok
would generate a https URL.
You should set WEBHOOK_URL
(in app.py) to your-https-URL/hook
.
python3 app.py
The initial state is set to user
.
Every time user
state is triggered to advance
to another state, it will go_back
to user
state after the bot replies corresponding message.
In this project, there are there usage of my chatbot: To list hotels in Tainan, movie theater timetable and Tainan one day tour.
First, I need to choose one of three options to ask my chatbot.
My options:
Hotels
Movie theater
Tainan sights
After the chatbot reply the message, you can ask next further questions related to your option.
Here, I described the input scheme:
-
Hotels
-
Top 5 review
- price
- location
-
Top 5 price
- review
- location
-
Top 5 near ncku
- review
- price
-
-
Movie theater
Guopin
- Now trending
Viewshow
- Now trending
-
Tainan Sights
One day tour
- Dine
And the chatbot will reply the answer of the above input strings one by one.
*(P.S. It's not efficient to write it all the answer here)*