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. We will also deploy the chatbot to Python Anywhere and use Flask
to set up the backend application.
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
: MainFlask
applicationbot_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 push
from localProcfile
: Commands for app's dynos on PythonAnywhererequirements.txt
: List of package dependencies to be installed on PythonAnywhereruntime.txt
: Python version to be installed on PythonAnywhere
- Python 3.10
emoji==2.2.0
Flask==3.0.0
gunicorn==20.1.0
matplotlib==3.6.2
pandas==1.5.2
pyTelegramBotAPI==4.8.0
python-dotenv==0.21.0
gTTS==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/capstone_da_bot
Here are the chatbot functionalities:
- Command
/start
or/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 Python Anywhere.