Skip to main content

Telegram ExecModule

Overview

TelegramModule connects ValkyrAI workflows to the Telegram Bot API through the native map I/O ExecModule ABI. Workflow Studio discovers it as TelegramModule; the bot token resolves only from an encrypted IntegrationAccount.

The initial production operation set covers bot, chat, member, file-metadata, message, pin, and callback workflows:

  • get_me, get_chat, get_chat_administrators, and get_chat_member
  • get_file
  • send_message, edit_message_text, and guarded delete_message
  • pin_chat_message and unpin_chat_message
  • answer_callback_query

Read-only operations can retry transient Telegram failures. Message sends, edits, deletes, pins, unpins, and callback answers run once so an ambiguous timeout cannot duplicate or repeat a side effect.

Usage

  1. Create a bot through Telegram BotFather and keep the generated bot token private.
  2. Add the bot to the intended chat or channel and grant only the permissions required by the selected operations.
  3. Store the bot token in the encrypted apiKey field of an IntegrationAccount.
  4. Set the account status to READY and bind it through ExecModuleConfig.authConfig.integrationAccount.
  5. Run get_me, then get_chat, to verify the bot identity and destination before a mutation.
  6. Use a numeric chat ID for private chats and groups or a public @channelusername where Telegram accepts one.
  7. Reconcile Telegram state before repeating any write after an ambiguous connection failure.

Workflow input cannot provide a bot token or arbitrary provider endpoint. Production routing is fixed to api.telegram.org over HTTPS.

Inputs

NameTypeRequirementDefaultDescription and constraints
operationstringRequiredNoneOne of the 11 documented operations.
chatIdstringChat/message operationsNoneNumeric chat ID or public @username, maximum 128 characters.
messageIdpositive integerEdit/delete/pin/unpinNoneTelegram message identifier.
userIdpositive integerget_chat_memberNoneTelegram user identifier.
fileIdstringget_fileNoneOpaque provider file ID, maximum 1,024 characters.
callbackQueryIdstringanswer_callback_queryNoneOpaque callback-query ID, maximum 1,024 characters.
textstringSend/edit; optional callbackNone1–4,096 characters for messages and at most 200 for callback answers.
parseModestringOptional send/editnonenone, HTML, or MarkdownV2.
replyMarkupobject or JSON stringOptional send/editNoneInline or reply keyboard fields, 128 KiB maximum and eight nesting levels.
messageThreadIdpositive integerOptional sendNoneForum topic/thread identifier.
replyToMessageIdpositive integerOptional sendNoneMessage to reply to.
disableNotificationbooleanOptional send/pinfalseRequests silent delivery or pin behavior.
protectContentbooleanOptional send/editfalsePrevents forwarding and saving where Telegram supports it.
showAlertbooleanOptional callbackfalseShows callback text as an alert.
callbackUrlHTTPS URLOptional callbackNoneClient URL Telegram should open after the callback answer.
cacheTimeintegerOptional callback0Callback caching window in seconds, 0–86,400.
confirmDeletebooleandelete_messagefalseMust be true before the delete request is sent.

replyMarkup accepts only inline_keyboard, keyboard, remove_keyboard, force_reply, resize_keyboard, one_time_keyboard, selective, input_field_placeholder, and is_persistent at the top level. Credential-like nested keys, excessive arrays, deep nesting, and oversized text fail before a provider request.

Outputs

NameTypeWhen presentDescription
statusstringAlwayssuccess or error.
operationstringAlwaysNormalized operation name.
attemptsintegerAlwaysTotal provider attempts.
httpStatusintegerProvider respondedLast Telegram HTTP status.
dataobject, array, or booleanSuccessTelegram's normalized result value.
idintegerIdentity/chat resultSafe convenience identifier.
messageIdintegerMessage resultTelegram message_id.
fileId / filePathstringFile metadata resultOpaque file ID and provider-relative path; bytes are not downloaded.
resourceStatusstringMember resultTelegram membership status.
countintegerArray resultNumber of returned administrators.
errorobjectFailureSafe code, redacted message, optional HTTP status, and retryable flag.

The bot token and token-bearing request path never enter outputs. Provider error descriptions pass through ValkyrAI's sensitive-data redaction policy.

IntegrationAccount Requirements

SettingRequirement
ProviderTelegram bot created through BotFather
Chat accessBot added to the intended private chat, group, supergroup, or channel
PermissionsRead/admin/message/pin/delete permissions limited to selected operations
apiKeyBot token in an encrypted SecureField
passwordLegacy encrypted bot-token fallback only; prefer apiKey
accountIdOptional organizational label; not used as a chat ID
statusREADY or legacy unset status; CLOSED and ERROR fail closed

Bot creation, token rotation, revocation, chat installation, privacy-mode configuration, and admin promotion belong to the platform IntegrationAccount lifecycle and Telegram administration. Workflow inputs never handle credentials.

Configuration

{
"version": "1.0.0",
"authConfig": {
"authStrategy": 1,
"integrationAccount": "integration-account:telegram-operations-bot"
},
"retryPolicy": {
"maxAttempts": 3,
"backoffStrategy": "EXPONENTIAL",
"initialDelayMs": 1000,
"maxDelayMs": 60000,
"jitter": false
},
"executionConfig": {"timeoutMs": 30000},
"payloadConfig": {
"parameters": "{\"operation\":\"get_chat\",\"chatId\":\"-1001234567890\"}"
}
}

The integration-account value is symbolic. Persisted workflows use the generated relationship rather than a plaintext bot token.

Operations

OperationTelegram behaviorSide effect
get_meReads the authenticated bot identity.Read-only; safe retries.
get_chatReads one chat's current metadata.Read-only; safe retries.
get_chat_administratorsReturns current non-bot and bot administrators.Read-only; safe retries.
get_chat_memberReads one user's membership and permissions.Read-only; safe retries.
get_fileResolves file metadata and provider-relative path.Read-only; safe retries; does not download bytes.
send_messageSends one bounded text message with optional markup.Creates a message; single attempt.
edit_message_textReplaces text and optional markup for one message.Mutates a message; single attempt.
delete_messageDeletes one message after explicit confirmation.Destructive; single attempt.
pin_chat_messagePins one message with explicit notification behavior.Mutates chat state; single attempt.
unpin_chat_messageUnpins one message.Mutates chat state; single attempt.
answer_callback_queryAnswers one inline-keyboard callback.User-visible response; single attempt.

Errors and Failure Modes

CodeTypical causeRetryableResolution
VALIDATION_ERRORMissing/invalid ID, message, URL, markup, token format, or deletion guard.NoCorrect input; no unsafe provider request was sent.
UNSUPPORTED_OPERATIONUnknown operation.NoSelect a documented operation.
INTEGRATION_ACCOUNT_REQUIREDNo bound account.NoBind a Telegram IntegrationAccount.
INTEGRATION_ACCOUNT_NOT_READYAccount is closed or in error.NoRepair or replace the account.
CREDENTIAL_MISSINGBound account has no decryptable token.NoReconnect or rotate the bot token.
TELEGRAM_API_400Invalid request, inaccessible chat, or unsupported combination.NoCorrect the safe provider detail and re-read chat state.
TELEGRAM_API_401Invalid or revoked bot token.NoRotate and update the IntegrationAccount.
TELEGRAM_API_403Bot blocked, removed, or missing chat permission.NoRepair chat membership and permissions.
TELEGRAM_API_404Chat, message, user, callback, or file is absent.NoRe-read with the same bot identity.
TELEGRAM_API_429 / 5xxTelegram rate limit or transient provider failure.Yes for readsHonor retry_after; reconcile writes before repeating them.
NETWORK_ERRORTimeout, DNS, TLS, or connectivity failure.Yes for readsVerify connectivity and provider state.
PAYLOAD_TOO_LARGERequest exceeded 128 KiB.NoReduce message markup or inputs.
RESPONSE_TOO_LARGEResponse exceeded 5 MiB.NoNarrow the operation or chat context.

Example

Send one approved production activation update:

{
"operation": "send_message",
"chatId": "-1001234567890",
"text": "Production activation completed and public verification passed.",
"disableNotification": true,
"protectContent": true,
"replyMarkup": {
"inline_keyboard": [[
{
"text": "Open documentation",
"url": "https://valkyrlabs.com/v1/valkyrai/workflow-engine/execmodules/telegram"
}
]]
}
}

Expected result:

{
"status": "success",
"operation": "send_message",
"attempts": 1,
"httpStatus": 200,
"messageId": 42,
"data": {
"message_id": 42,
"text": "Production activation completed and public verification passed."
}
}

Notes

  • Pagination: these Bot API operations do not expose provider page tokens. Administrator arrays are returned as one bounded provider response and remain subject to the 5 MiB response cap.
  • Rate limits: read-only operations retry HTTP 408, 429, 500, 502, 503, and 504 plus Telegram error_code 429/5xx according to RetryPolicy. Numeric Telegram parameters.retry_after is honored. Mutations never retry automatically.
  • API limits: request bodies are capped at 128 KiB, responses at 5 MiB, messages at 4,096 characters, callback text at 200, callback cache time at 86,400 seconds, markup nesting at eight levels, and markup arrays at 500 entries.
  • Idempotency: Telegram's initial send/edit/delete/pin/unpin/callback methods do not accept a universal caller idempotency key. Each write is single-attempt; reconcile by bot identity, chat ID, message ID, or callback state before any retry after an ambiguous failure.
  • Destructive behavior: only delete_message is destructive and requires confirmDelete=true. Telegram also applies age, dice, service-message, and bot-permission limits that can reject deletion.
  • Security: credentials remain in IntegrationAccount SecureFields. Fixed-host routing, strict bot-token validation, bounded identifiers, allowlisted markup, forbidden credential-like nested keys, capped payloads/responses, and redacted provider descriptions prevent arbitrary routing and secret reflection.
  • API behavior: public usernames, private chat IDs, supergroup migrations, forum topics, bot privacy mode, channel administrator rights, callback expiry, and Telegram's evolving Bot API rules can impose constraints beyond local validation.
  • External verification: request construction, normalization, read retry, single-attempt writes, deletion guards, fixed-host routing, redaction, validation, and metadata discovery have deterministic local tests. Live BotFather creation, chat installation, permissions, delivery, callbacks, deletion windows, rate limits, and token rotation require separately authorized Telegram credentials and are not exercised in repository tests.
  • Deferred operations: webhook/long-poll triggers, getUpdates, arbitrary methods, file-byte download, multipart media upload, albums, polls, reactions, stickers, forum-topic administration, invite links, payments, games, passport flows, business connections, and bot-command/menu administration.
  • Functional references: n8n Telegram node source, n8n Telegram operations, and Telegram Bot API.