birthday reminder bot to run as a simple cron job with a CSV file containing birthdays because i always forget birthdays
-
Create a telegram bot using @botfather and get your api key
-
Create venv
python3 -m venv ./bdaychecker
- Activate the new env
source ./bdaychecker/bin/activate
- Install requirements
pip install -r requirements.txt
As well as the python-telegram-bot library version v20.x:
pip install python-telegram-bot -U --pre
- Add telegram API to the .env file, I provided a template, but this command will create a new one with the needed environment variables, just replace
APIKEY
with your telegram bot API key andCHATID
with your chat ID (this thread in stackoverflow details how you can get that)
echo -e "TELEGRAM_BOT_API_KEY=\"APIKEY\"\nYOUR_CHAT_ID=\"CHATID\"" > .env && rm .env.template
- Create a csv file with your birthdays in the format shown below.
Example:
name | year | month | day |
---|---|---|---|
Carlos | 1967 | 11 | 7 |
Michael | 1983 | 3 | 2 |
George | 1988 | 9 | 15 |
You can skip the year if you don't know it, but the name, month and day must be populated, otherwise that row will be skipped.
echo -e "name,year,month,day\n" > birthday_list.csv
- Add a cron job to run this once a day every day, when it runs, you should receive a message from the bot if there's a birthday
crontab -e
And add (change the 6 with whatever hour you want this to run at):
0 6 * * * /path/to/cloned/repo/bdaychecker/bin/python /path/to/cloned/repo/check_bdays.py
I added a bash script to the root of the repo (initial_setup.sh
) which runs all commands before step 6, you can run this script with source initial_setup.sh
or . initial_setup.sh
in bash.