Skip to content

datalust/seq-app-telegram

Repository files navigation

Datalust.Seq.App.Telegram

Send events and notifications from Seq to Telegram via the Bot API.

This codebase is an early preview. It contains code ported generatively from other Seq apps hand-written by Datalust and external contributors. We welcome feedback and bug reports (which we'll always respond to personally!).

Getting started

1. Create a Telegram bot with @BotFather and copy the bot token.

2. Get the chat id for the target chat, group, or channel. For public channels you can use @channelname; for private chats, use the numeric chat id.

3. Install the app in Seq under Settings > Apps, using the Datalust.Seq.App.Telegram package id.

Visit the Seq documentation for detailed information about installing and configuring Seq Apps.

Settings

Property Description Template? Default
Bot token The bot's API token, obtained from @BotFather.
Chat ID The Telegram chat to send messages to — a numeric chat id or @channelname. Yes
Message body The template used to build the message body. If left blank, a default template is used. Yes See below
Parse mode How to format the message body: HTML uses Telegram-supported HTML tags; PlainText sends unformatted text. HTML
Time zone An IANA time zone name used when formatting dates and times, e.g. Australia/Brisbane. Etc/UTC
Date/time format A .NET date/time format string, e.g. yyyy-MM-dd HH:mm:ss. o (ISO-8601)
Silent notification When enabled, messages are delivered silently — recipients receive a notification with no sound.
Message thread ID Unique identifier for the target message thread (topic) of a forum supergroup.

Settings marked Template? support the Seq template language, so event properties and expressions can be included dynamically.

Templates

The default message template formats events in HTML with log level indicators, timestamps, message text, properties, exception details, and a link back to the event in Seq. Alert notifications include result tables and contributing event links.

Custom templates use the Seq template language. Event and notification properties can be inserted by surrounding them with braces:

Error in {Environment}!

Templates support:

  • Built-in Seq event properties including @Level, @Message, @Exception, @Timestamp, and @Id,
  • First-class event properties like Environment in the example above,
  • Seq functions such as ToString(), Coalesce(), Substring(), and IndexOf(),
  • Conditionals with {#if expr}...{#end} and iteration with {#each e in expr}...{#end},
  • InTimeZone() to convert timestamps to the configured time zone,
  • UriEncode() to safely embed values in URLs.

Messages longer than 4096 characters are automatically truncated to fit Telegram's message size limit.

Development

The src/Datalust.Seq.App.Telegram.SmokeTest project is a console application that enables local/interactive app debugging. Configure it using environment variables with the SEQ_APP_SETTING_ prefix, e.g.:

SEQ_APP_SETTING_BOTTOKEN=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
SEQ_APP_SETTING_CHATID=@mychannel

Tests can be run with:

dotnet test

Acknowledgements

This app is based on https://github.com/datalust/seq-app-mail.

About

Send events and notifications from Seq to Telegram via the Bot API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Contributors