Telegram Output¶
The Telegram output allows you to send notifications to Telegram users, groups, or channels. It's one of the most popular output types due to Telegram's rich formatting support, mobile notifications, and ease of setup.
How It Works¶
Relaye provides two methods for setting up Telegram outputs:
- Relaye Notification Bot (Recommended): Uses Relaye's pre-configured Telegram bot
- Bring Your Own Bot (BYOB): Uses your own custom Telegram bot
When a notification is sent to a Telegram output:
- Relaye formats the message according to your template
- The message is sent to Telegram via the bot API
- The bot delivers the message to the configured chat
- Relaye logs the delivery status
Telegram supports rich formatting, images, files, and interactive buttons, making it an excellent choice for detailed notifications.
Setting Up Telegram Output (Recommended Method)¶
Using the Relaye Notification Bot is the quickest way to get started:
- Go to the Outputs section
- Click New Output
- Select Telegram as the output type
- Open Telegram and add @relayebot to your chat or group
- For personal notifications, start a direct chat with @relayebot
- For group notifications, add @relayebot to your group
- For channel notifications, add @relayebot as an administrator to your channel
- Type
/relayelinkin the chat - Click the link provided by the bot (it will take you back to Relaye)
- Give your output a name (e.g., "Team Alerts")
- Click Save
Setting Up Telegram Output (BYOB Method)¶
If you prefer to use your own bot:
- Go to the Outputs section
- Click New Output
- Select Telegram (Bring Your Own Bot) as the output type
- Create a new bot via @BotFather on Telegram
- Get the bot token from BotFather
- Enter the bot token in the Bot Token field
- Add your bot to the chat, group, or channel where you want to receive notifications
- Get the chat ID:
- For personal chats: Use a service like @username_to_id_bot
- For groups/channels: Send a message and check the Telegram API
- Enter the chat ID in the Chat ID field
- Give your output a name
- Click Save
Handling Images and Files¶
Telegram can display images and files sent with notifications. If your input includes images or files, they will be automatically forwarded to Telegram.
In your template, you can reference them like this:
<b>📊 New Report</b>
{{ message }}
{% for file in relaye_files %}
{{ file.original_filename }}
{% endfor %}
Warning
Attached files and images will be sent directly to Telegram as "Document" and "Photo" type. Relaye does not support embedding images/documents directly in the message template.
Testing Your Telegram Output¶
To test your Telegram output:
- Go to the output's details page
- Click Test
- Relaye will send a test notification to your Telegram chat
- Check your Telegram chat to confirm receipt
Common Uses¶
Telegram outputs are frequently used for:
- Alert Notifications: Send critical alerts to on-call teams
- Status Updates: Provide regular system status updates
- Report Summaries: Deliver concise summaries of longer reports
- Monitoring Alerts: Forward monitoring system alerts
- Customer Interactions: Notify team members of important customer events
Troubleshooting¶
Common Issues¶
Bot Not Responding
If your bot isn't delivering messages:
- Verify the bot is in the chat/group/channel
- Check that the bot has permission to send messages
- For channels, ensure the bot is an administrator
- Verify the chat ID is correct
- Check the output logs in Relaye for error messages
Formatting Not Working
If your message formatting isn't displaying correctly:
- Ensure you're using the correct HTML tags
- Verify that all HTML tags are properly closed
- Check for invalid characters in your template
- Use the template preview to test your formatting
Viewing Telegram Logs¶
You can view all outgoing Telegram notifications by:
- Going to the Outputs section
- Clicking on your Telegram output
- Navigating to the Outgoing Logs tab
This will show you all sent notifications, their status, and any error messages.
Best Practices¶
- Keep messages concise and focused on essential information
- Use formatting to highlight important details
- Include links to more detailed information when necessary
- For group notifications, @mention specific users when action is required
- Consider the time of day when sending non-critical notifications
- Use separate chats/groups for different priority levels
- Include context in your notifications (source, severity, etc.)