Skip to main content

Telegram

Use Telegram when you need bot commands, team alerts, simple customer notifications, or lightweight operational workflows.

Example app: task reminders

Build a task reminder app with React, NestJS, PostgreSQL, and a Telegram bot.
Users can create tasks with a title, due date, reminder time, and status.
The app should let users connect Telegram by starting the bot.
Store each user's Telegram chat ID server-side.
Send one reminder message when a task reaches its reminder time.

Create a bot

  1. Open Telegram and search for BotFather.
  2. Start the bot creation flow.
  3. Choose a clear display name and username for the bot.
  4. Copy the bot token into your secret manager or runtime configuration.
  5. Do not paste the token into Cocoding AI chat, screenshots, or client code.
Telegram BotFather command list
BotFather creates and manages Telegram bot accounts.
Telegram bot management screen
Use BotFather to update bot settings and commands after creation.
TELEGRAM_BOT_TOKEN=
TELEGRAM_DEFAULT_CHAT_ID=
TELEGRAM_WEBHOOK_SECRET=

Capture the chat ID

The generated app needs a way to know which Telegram chat belongs to which user. Ask Cocoding AI to implement one of these patterns:

  • A Connect Telegram button that opens the bot with a user-specific start parameter.
  • A /start command that records the Telegram chat_id against the signed-in user.
  • A manual admin field for a default team chat ID when the app sends team alerts.

Do not hardcode personal chat IDs into source files.

Prompt Cocoding AI

Add a Telegram bot for task reminders.
Use TELEGRAM_BOT_TOKEN on the server only.
Support /start and /help commands.
Send reminder notifications to TELEGRAM_DEFAULT_CHAT_ID.
Show clear setup errors when the bot token is missing.

Test the bot

  1. Message the bot with /start.
  2. Trigger one safe test notification from the app.
  3. Confirm the message appears in Telegram.
  4. Confirm the app logs success or failure.
  5. Ask Cocoding AI to add retry behavior only after the basic test works.
Telegram bot connected confirmation and sample reminder message
A successful Telegram connection should confirm that reminders will arrive in the selected chat.

Optional bot polish

Use BotFather to add:

  • /help command.
  • A short bot description.
  • A square bot profile image.
  • Command descriptions such as start - connect your account.

Troubleshooting

SymptomLikely causeWhat to check
Bot does not answerToken missing or invalidRecreate the token and store it server-side.
Message not deliveredChat ID missingSend /start and confirm the chat ID used by the app.
Commands not visibleCommand list not configuredUse BotFather to set commands.
Webhook failsApp URL is not reachableTest webhook URL after publishing.