Skip to content
DiscordTwitter

Telegram Bot Setup

This guide walks you through creating a Telegram bot and obtaining the credentials needed to use Telegram components in GrailHub.

  • A Telegram account
  • Telegram app installed on your device (mobile or desktop)
  1. Open Telegram and search for @BotFather (or click this link)
  2. Start a conversation by clicking Start or sending /start

BotFather is the official Telegram bot for creating and managing bots.

  1. Send the command /newbot to BotFather
  2. BotFather will ask for a name for your bot (this is the display name)
    • Example: My Trading Alerts
  3. Next, provide a username for your bot (must end in bot)
    • Example: my_trading_alerts_bot

After creating the bot, BotFather will send you a message containing your bot token. It looks like this:

123456789:ABCdefGHIjklMNOpqrsTUVwxyz

Copy the token and store it securely. You’ll need it when configuring Telegram components in GrailHub.

To send messages, you need the Chat ID of the recipient (yourself, a group, or a channel).

  1. Start a conversation with your bot by searching for its username
  2. Send any message to your bot (e.g., /start)
  3. Open this URL in your browser (replace YOUR_BOT_TOKEN with your actual token):
    https://api.telegram.org/botYOUR_BOT_TOKEN/getUpdates
  4. Look for the "chat":{"id": field in the response. The number is your Chat ID.

Example response:

{
  "ok": true,
  "result": [
    {
      "message": {
        "chat": {
          "id": 123456789,
          "type": "private"
        }
      }
    }
  ]
}

Your Chat ID in this example is 123456789.

  1. Add your bot to the group
  2. Send a message in the group (mention the bot or just send any message)
  3. Use the same getUpdates URL as above
  4. Find the group’s Chat ID in the response (group IDs are typically negative numbers)

Example: -1001234567890

  1. Add your bot as an administrator to your channel
  2. Post a message in the channel
  3. Use the getUpdates URL
  4. The channel ID will appear in the response

Alternatively, for public channels, you can use the channel username with @ prefix:

  • Example: @mychannel

Depending on your use case, you may need to adjust bot settings:

Your bot can receive commands by default. Users send commands like /start, /help, or custom commands you define.

If you want your bot to receive all messages in a group (not just commands):

  1. Send /setprivacy to BotFather
  2. Select your bot
  3. Choose Disable

This allows your bot to see all messages in groups it’s added to.

To enable inline queries (users can type @yourbot query):

  1. Send /setinline to BotFather
  2. Select your bot
  3. Provide a placeholder text

The Notification component sends messages to Telegram:

ConfigDescription
Bot TokenYour bot token from BotFather
Chat IDThe recipient’s Chat ID
Message TemplateThe message content (supports templates)
Parse ModePlain Text, Markdown, or HTML

The Command component listens for bot commands:

ConfigDescription
Bot TokenYour bot token from BotFather
CommandThe command to listen for (without /)
Poll IntervalHow often to check for new messages (seconds)

Here’s a typical workflow for price alerts:

  1. Create a bot using BotFather
  2. Get your Chat ID by messaging your bot
  3. Add a Notification component to your flow
  4. Configure the component:
    • Bot Token: 123456789:ABCdefGHIjklMNOpqrsTUVwxyz
    • Chat ID: 987654321
    • Message Template: 🚨 Price Alert: {{.Symbol}} is now ${{.Price}}
    • Parse Mode: Plain Text
  • Verify your bot token is correct
  • Ensure you’ve started a conversation with the bot first
  • Check that the bot hasn’t been blocked
  • Make sure you’ve sent at least one message to the bot/group/channel
  • The getUpdates response is empty if there are no recent messages
  • Try sending a new message and checking again
  • Verify the bot is a member of the group
  • Check that the Chat ID is correct (group IDs are negative)
  • Ensure the bot has permission to send messages
  • The bot must be an administrator of the channel
  • Use the correct channel ID or username
  1. Never share your bot token - Treat it like a password
  2. Use environment variables - Don’t hardcode tokens in flows
  3. Rotate tokens if compromised - Use /revoke with BotFather to get a new token
  4. Limit bot permissions - Only enable features you need