Denis Cercasin

Sources for the Telegram Bot API

This document lists the official references, tutorials, and code snippets that informed our implementation of Telegram bots in Rent Tracker.


Official Documentation


Code Snippets Referenced/Adapted

1. Registering /start command

@bot.message_handler(commands=['start'])
def start(message):
    bot.send_message(message.chat.id, "Welcome! Please link your account.")

Taken from Telegram Bot API examples, adapted to trigger our user-token binding logic.

2. Sending messages to a specific chat ID

bot.send_message(chat_id=123456789, text="Your rent is due for June.")

Used in our daily reminder script. Syntax verified via official docs.

3. Using polling mode

import telebot
bot = telebot.TeleBot("BOT_TOKEN")
bot.polling()

Used during development phase for local testing.

4. Preparing for webhooks (production)

We plan to switch from polling to webhooks for production deployment. Reference used: Webhook Setup Guide

Additional Community Threads

Provided insight into handling errors in long-lived sessions.

Summary

We use two bots:

  1. Registration Bot - for binding Telegram accounts using /start
  2. Reminder Bot - sends monthly rent reminders based on unpaid records

Both rely on the python-telegram-bot library and were implemented using official API guidelines and adapted code snippets.

Last build: 20 Jul 2025, 00:44+00:00