🔍 Overview

Link Switcher includes a simple Telegram bot used to register Telegram users.

The bot validates a shared secret (TELEGRAM_BOT_AUTH_KEY) and stores the Telegram profile in the database as a TelegramUser.

Note: this bot does not automatically link a Telegram user to a Django User. The association is done via TelegramUserMapping (usually in the admin panel).


🤖 Bots


🛠 How to Run

Run from the Link Switcher project root:

poetry run python apps/telegram/bot.py

The bot requires Django settings + database access.

Relevant settings:

  • TELEGRAM_BOT_TOKEN
  • TELEGRAM_BOT_AUTH_KEY

⚙️ How It Works

  1. User sends /start.
  2. Bot asks for the authorization key.
  3. If the key matches TELEGRAM_BOT_AUTH_KEY, the bot upserts TelegramUser by user_external_id.
  4. The bot replies with success (or asks to retry).

✅ Example Session

User: /start
Bot: 💡 For authorization, please enter the authorization key:
User: my-secret-key
Bot: ✅ Successfully authorized.
     🚀 Welcome, John!

💡 Notes

  • Notification delivery is handled by Celery tasks and can use multiple bot tokens (base/offers/tracking-domain). See Send Messages Task.