Path: redb-route/redb.Route.Telegram/TelegramHeaders.cs Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages. License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Telegram/TelegramHeaders.cs ---- namespace redb.Route.Telegram; /// /// Header names written to IExchange by . /// Use these constants to read Telegram metadata inside route processors. /// public static class TelegramHeaders { // ── Update / common ─────────────────────────────────────────────────────── /// Update ID (long). Unique per bot, monotonically increasing. public const string UpdateId = "telegram.updateId"; /// Update type string: "Message", "EditedMessage", "CallbackQuery", etc. public const string UpdateType = "telegram.updateType"; // ── Message ─────────────────────────────────────────────────────────────── /// Telegram message ID (int) within the chat. public const string MessageId = "telegram.messageId"; /// Message type: "Text", "Photo", "Document", "Sticker", etc. public const string MessageType = "telegram.messageType"; /// Raw text of the message (null for non-text messages). public const string Text = "telegram.text"; /// Chat ID (long). Use this to reply via the producer. public const string ChatId = "telegram.chatId"; /// Chat type: "Private", "Group", "Supergroup", "Channel". public const string ChatType = "telegram.chatType"; // ── Sender ──────────────────────────────────────────────────────────────── /// Sender user ID (long). public const string UserId = "telegram.userId"; /// Sender first name. public const string FirstName = "telegram.firstName"; /// Sender last name (nullable). public const string LastName = "telegram.lastName"; /// Sender @username (nullable, without @). public const string Username = "telegram.username"; /// Sender language code, e.g. "ru", "en". public const string LanguageCode = "telegram.languageCode"; // ── Callback query ──────────────────────────────────────────────────────── /// Callback query ID — pass to bot.AnswerCallbackQuery(...). public const string CallbackQueryId = "telegram.callbackQueryId"; /// Callback data string set on the InlineKeyboardButton. public const string CallbackData = "telegram.callbackData"; // ── Web App (mini app) ──────────────────────────────────────────────────── /// /// Payload sent from a Telegram Mini App via WebApp.sendData(...). /// Present only on messages whose is "WebAppData", /// which Telegram delivers only for web app buttons opened from a reply keyboard /// (KeyboardButton.WithWebApp) — inline web app buttons cannot send data back. /// Also written to the exchange body, since such a message carries no text. /// public const string WebAppData = "telegram.webAppData"; /// Text of the reply-keyboard button that opened the mini app (nullable). public const string WebAppButtonText = "telegram.webAppButtonText"; // ── Producer controls ───────────────────────────────────────────────────── /// /// Reply markup to attach to a sent message. /// Set to an InlineKeyboardMarkup or ReplyKeyboardMarkup instance /// from the Telegram.Bot.Types.ReplyMarkups namespace. /// Used by send / document / photo / edit (inline only) modes. /// public const string ReplyMarkup = "telegram.replyMarkup"; /// /// Message ID to reply to in send / document / photo modes. /// Set to an int (or parseable string). When present, the sent message /// will appear as a reply to the referenced message in the chat. /// Wins over the replyToMessageId option. /// public const string ReplyToMessageId = "telegram.replyToMessageId"; /// /// Per-message override for /// in document/photo modes. /// public const string Caption = "telegram.caption"; /// /// Per-message override for in /// answer mode: show the text as a modal alert instead of a toast. /// Accepts bool or string parseable as bool. /// public const string ShowAlert = "telegram.showAlert"; /// /// Per-message override for . /// Values: "HTML", "Markdown", "MarkdownV2". Case-insensitive. /// public const string ParseMode = "telegram.parseMode"; /// /// Per-message override for . /// Accepts bool or string parseable as bool. /// public const string DisableNotification = "telegram.disableNotification"; /// /// Explicit Telegram file_id for the document/photo/download /// producer modes. /// /// On document/photo it means "send this file already hosted on /// Telegram instead of uploading the exchange body"; on download it names /// the file to fetch. Both readings are the same instruction — the file this /// producer call is about — which is why they share one key. /// /// public const string FileId = "telegram.fileId"; /// File name to use when the exchange body is a or byte[]. public const string FileName = "telegram.fileName"; // ── Inbound attachments (set by the consumer / webhook unpack) ──────────── // // Deliberately NOT reusing FileId above: that one is a *producer* instruction // ("send this already-hosted file"), and headers travel with the exchange. A route // that consumes a voice message and then sends a document would otherwise echo the // user's own file back at them — silently, because both sides read the same key. /// /// Kind of the attachment on an incoming message: voice, audio, /// videoNote, video, animation, document, photo, /// sticker. Absent when the message carries no file. /// /// Present alongside ; the pair is what a route needs to /// decide "this is a voice note" and then fetch it via getFile. /// /// public const string AttachmentKind = "telegram.attachment.kind"; /// /// Telegram file_id of the attachment on an incoming message. Pass it to /// getFile to obtain a download path. /// /// Photos arrive as a size ladder; the largest is reported, because a route that wants /// the picture wants the picture, and downscaling is the caller's choice. /// /// public const string AttachmentFileId = "telegram.attachment.fileId"; /// MIME type reported by Telegram for the attachment, when it sends one (nullable). public const string AttachmentMimeType = "telegram.attachment.mimeType"; /// Attachment size in bytes, when Telegram reports it (long, nullable). public const string AttachmentFileSize = "telegram.attachment.fileSize"; /// /// Duration in seconds for time-based attachments — voice, audio, video, video note /// (int, nullable). Lets a route reject a twenty-minute recording before /// downloading it. /// public const string AttachmentDuration = "telegram.attachment.duration"; /// Original file name of a document or audio attachment, when present (nullable). public const string AttachmentFileName = "telegram.attachment.fileName"; /// /// Caption typed alongside the attachment (nullable). Kept out of the exchange body on /// purpose: the body stays "what the user typed as a message", and silently promoting a /// caption to a body would make a captioned photo look like a text command. /// public const string AttachmentCaption = "telegram.attachment.caption"; // ── Producer results (set on the outgoing exchange after publish) ───────── /// /// Set by the producer after a successful send/document/photo/edit /// to the resulting (int). /// Allows downstream steps to edit or delete the message just produced without /// a separate round-trip. /// public const string SentMessageId = "telegram.sentMessageId"; /// /// Set by the download producer to the server-side path getFile reported /// (voice/file_42.oga). Useful for the extension — Telegram does not send a MIME /// type for every attachment kind, but it always names the file it stored. /// /// Deliberately NOT a URL: the download URL embeds the bot token, and a header travels /// with the exchange into logs, audits and dead letters. /// /// public const string FilePath = "telegram.file.path"; /// /// Set by the download producer to the number of bytes actually downloaded /// (long). Not the same as , which is what the /// update claimed before anything was fetched. /// public const string FileSize = "telegram.file.size"; /// /// Set by the download producer to the file's file_unique_id — stable /// across bots and over time, unlike file_id. The identifier to deduplicate or /// cache by; it cannot be used to download anything, which is exactly why it is safe /// to keep. /// public const string FileUniqueId = "telegram.file.uniqueId"; // ── Internal ────────────────────────────────────────────────────────────── /// Returns true if the key is a redb.Route.Telegram internal header. public static bool IsRedbHeader(string key) => key.StartsWith("telegram.", StringComparison.OrdinalIgnoreCase); }