A sample app that uses vaisnava-calendar-data-collection to send reminders for special events on Telegram.
- Clone the Repository:
git clone https://github.com/gauracreative/vcalapp.git cd vcalapp - Install Node Modules:
npm install- Set Up the Environment File: Copy the example .env.dist file and adjust it with your configuration:
cp .env.dist .env- DATA_URL: URL pointing to your calendar data. Consult the vaisnava-calendar-data-collection documentation for details.
- TELEGRAM_BOT_TOKEN: Create a Telegram bot via BotFather and add the token here.
- TELEGRAM_CHAT_ID: Add your Telegram group, channel, or personal chat ID where reminders will be sent. Don’t forget to add your bot to the group/channel if applicable.
-
Run the app manually to send events:
node index.js today
-
Send tomorrow’s events:
node index.js tomorrow
-
Send this week’s events:
node index.js week
You can automate reminders by setting up a cron job. Follow these steps:
- Edit Crontab: Open the cron editor:
crontab -e- Add Jobs: Add the following entries to schedule the reminders:
# optional - if your server system time is different (adjust to your own time zone)
TZ=America/Chicago
# Run the script for today's events at 4 AM every day except Sunday
0 4 * * 1-6 cd /path/to/vcalapp && /usr/bin/node index.js today >> cron.log
# Run the script for tomorrow's events at 9 AM every day except Sunday
0 9 * * 1-6 cd /path/to/vcalapp && /usr/bin/node index.js tomorrow >> cron.log
# Run the script for this week's events at 4 AM on Sunday
0 4 * * 0 cd /path/to/vcalapp && /usr/bin/node index.js week >> cron.log
Explanation of Schedule:
0 4 * * 1-6: Executes at 4:00 AM, Monday to Saturday.0 9 * * 1-6: Executes at 9:00 AM, Monday to Saturday.0 4 * * 0: Executes at 4:00 AM on Sunday.
- Save and Exit: Save the file in your preferred editor (e.g., vim, nano) and exit. The cron jobs are now active.
-
Ensure the environment file (
.env) contains the correctDATA_URL,TELEGRAM_BOT_TOKEN, andTELEGRAM_CHAT_ID. -
Use
node index.jswith the appropriate argument to test each functionality before adding it tocron. -
For advanced scheduling or monitoring, consider using a process manager like PM2.
-
When setting up a cronjob, ensure that the server's timezone is correctly configured. On a Linux server, you can check the current timezone using:
timedatectl
To change the timezone, use the following command (replace America/Chicago with your desired timezone):
sudo timedatectl set-timezone America/Chicago
This ensures your cronjob runs at the intended local time.
Enjoy sending timely Vaiṣṇava reminders! 🙏