This is developed as one of Algoritma Academy Data Analytics Specialization Capstone Projects. The deliverable of this project is a Python script to create a Telegram chatbot using telebot package. I also deploy the chatbot to PythonAnywhere to run the program.
Note
You can test this Telegram chatbot live here. If the chatbot is unresponsive, it may be due to free-tier hosting limitations. Please check out the demo video (here) showcasing its full functionality. Alternatively, you can contact me and I'll be happy to activate it for you to test live!
The maximum score you will obtain from this project is 16 points:
-
Setup (3 points)
- Prepare virtual environment
- Please provide
requirements.txton the project folder.
- Please provide
- Create Telegram bot API via BotFather
- Please provide your bot link when making a submission.
- Using
os.environto secure token- Important: Make sure you do not push
.envto your GitHub Repository.
- Important: Make sure you do not push
- Prepare virtual environment
-
Chatbot functionalities
- Basic function (3 points)
- Command
/startor/help: correctly respond to user trigger - Command
/about: provide developer information - Function
echo_all(): usingemoji
- Command
- Summary text report:
/summary(3 points)- Perform necessary data wrangling steps to extract information
- Perform the right mathematical calculation
- Send summary message using
Template
- Visualization report:
/plot(4 points)- Perform necessary data wrangling steps to extract information
- Perform the right mathematical calculation
- Send plot with caption
- Tidy plot layout (title, label, color, size)
- Basic function (3 points)
-
Application deployment (3 points)
- Using
Flaskto serve the chatbot as an application - Deploy to Railway
- Deployed chatbot run smoothly without error
- Using
telebot
├── 📁 assets
├── 📁 cache
├── 📁 data_input
├── 📁 template_text
├── .gitignore
├── </> app.py
├── </> bot_local.py
├── 📝 Notebook Guide.ipynb
├── 🚀 Procfile
├── 📝 requirements.txt
└── 📝 runtime.txt
-
Folders (DO NOT CHANGE):
assets: Images used in notebookcache: Pickled Python objectdata_input: Dataset for analysistemplate_text: Text files for chat template
-
Application-related Files (TO BE COMPLETED BY STUDENT):
app.py: MainFlaskapplicationbot_local.py: Telegram bot to be run locallyNotebook Guide.ipynb: Main guide for the project workflow
-
Deployment-related Files (DO NOT CHANGE):
.gitignore: List of file extensions to be ignored whengit pushfrom localProcfile: Commands for app's dynos on Railwayrequirements.txt: List of package dependencies to be installed on Railwayruntime.txt: Python version to be installed on Railway
- Python 3.10
emoji==2.2.0Flask==2.2.2gunicorn==20.1.0matplotlib==3.6.2pandas==1.5.2pyTelegramBotAPI==4.8.0python-dotenv==0.21.0gTTS==2.3.0
For instructions on how to prepare the virtual environment and requirements, please read Notebook Guide.ipynb.
Create a bot that can provide report on Facebook daily ads for different marketing campaign. Here is an example: https://t.me/algo_capstone_telebot
Here are the chatbot functionalities:
- Command
/startor/help: send welcome message containing list of available commands.
- Command
/about: send information about the bot developer.
- Command
/summary: generate text report for selected campaign ID.
Reply from bot after campaign ID is selected:
- Command
/plot: generate visualization and voice message report per age group for selected campaign ID.
Reply from bot after campaign ID is selected:
Voice message: Sample audio for Campaign ID 916
This is your requested plot for Campaign ID 916. Age group with the highest total spent is 30-34, while the lowest is 40-44. Age group with the highest total approved conversion is 30-34, while the lowest is 45-49. Age group with the highest average CPC is 45-49, while the lowest is 40-44.
- Default message: handle messages other than the previous commands.
This bot is expected to run continuously on a server. Therefore we create a Flask application which deployed to Railway.








