This project is a Telegram bot designed to help users stay updated about food reservations by sending reminders at specific times. The bot features message scheduling, user management, and snooze functionality, making it adaptable for other types of reminders or scheduling tasks.
- Scheduled Reminders: Sends automated reminders for specific days and times:
- Monday: Reminder when the reservation system is updated.
- Tuesday: Evening reminder about upcoming reservations.
- Wednesday: Final reminder before the reservation window closes.
- Inline Keyboard: Includes snooze buttons for users who have already completed their reservations.
- Group Notifications: Sends group reminders in specified Telegram groups.
- Database Management: Tracks users and their snooze preferences in a PostgreSQL database.
- Weekly Data Reset: Resets user snooze statuses every Thursday.
- Admin Control: Admins can control whether reminders are sent through a
/status
endpoint. - Error Handling: Manages failed message deliveries and removes invalid users from the database.
- Node.js (v14 or later)
- PostgreSQL database
- Telegram Bot Token (from @BotFather)
- Hosting service like Railway.app or local environment
- Clone the repository:
git clone https://github.com/theycallmerubik/ReservReminder.git
- Install dependencies:
npm install
- Create a
.env
file in the root directory:BOT_TOKEN=your_telegram_bot_token ADMIN_CHAT_ID=your_admin_chat_id GROUP_CHAT_IDS=group_chat_id_1,group_chat_id_2 DB_USER=your_postgresql_user DB_HOST=your_postgresql_host DB_NAME=your_database_name DB_PASSWORD=your_database_password DB_PORT=your_database_port SECRET_KEY=your_secret_key PORT=your_port_number
- Start the bot:
node bot.js
- Access the bot on Telegram and test its features using
/start
and/help
commands.
- User Registration: When users send
/start
, they are added to the database and will receive scheduled reminders. - Reminder Scheduling:
- Predefined reminders are sent on Monday, Tuesday, and Wednesday.
- Messages include inline buttons for snoozing future reminders.
- Admin Management:
- Admins can manually confirm if Monday's reminder should be sent using the
/status
endpoint. - The admin API key ensures secure access to this functionality.
- Admins can manually confirm if Monday's reminder should be sent using the
- Group Notifications: Groups listed in
GROUP_CHAT_IDS
will receive reminders on Wednesday.
Returns a message confirming that the bot is running.
Allows admins to control whether Monday reminders should be sent based on the reservation system's status.
You can also use other scripts to send POST to the bot. see This git for more information.
- Headers:
x-api-key
: Admin secret key for authentication.
- Body:
{ "siteStatus": true }
The bot uses a PostgreSQL database to manage users:
CREATE TABLE users (
telegram_id BIGINT PRIMARY KEY,
snooze BOOLEAN DEFAULT FALSE
);
This bot is designed to be adaptable for other purposes beyond food reservation reminders. You can modify the code to:
- Change reminder messages.
- Add new scheduled tasks.
- Integrate with other APIs for dynamic content.
This project is licensed under the MIT License.
- node-telegram-bot-api for seamless Telegram bot integration.
- PostgreSQL for reliable database management.
Feel free to contribute to this project by submitting issues or pull requests!
For questions or suggestions, contact:
- Telegram: @Ru_bic
- Email: rubikmanyt@Gmail.com