Create a Telegram Bot and Get Chat ID

Create a Telegram Bot:

  1. Open Telegram and start a chat with @BotFather.
  2. Send /newbot, follow the instructions, and record the bot token (e.g., 123456789:AAF...).

BotFather

Obtain the Chat ID:

  1. Add the bot to a group or send it a direct message.
  2. Send a test message, then retrieve the chat ID using:
curl https://api.telegram.org/bot<your_bot_token>/getUpdates
  1. In the JSON response, find "chat":{"id":<chat_id>} (e.g., 123456789 or -123456789 for groups).
  2. Alternatively, use @GetIDsBot to get the chat ID easily.

Test the Bot:

Send a manual test message to verify setup:

curl -X POST "https://api.telegram.org/bot<your_bot_token>/sendMessage" -d "chat_id=<your_chat_id>&text=Test message"