Back to Eliza

Telegram Connector

packages/docs/connectors/telegram.md

2.0.17.9 KB
Original Source

Telegram Connector

Connect your agent to Telegram for private chats and group conversations using the @elizaos/plugin-telegram package.

Prerequisites

Configuration

NameRequiredDescription
TELEGRAM_BOT_TOKENYesBot token from @BotFather
TELEGRAM_API_ROOTNoBase URL for Telegram Bot API (allows overriding the default endpoint)
TELEGRAM_ALLOWED_CHATSNoJSON-encoded array of chat IDs authorized to interact with the bot
TELEGRAM_TEST_CHAT_IDNoChat ID used by the test suite for validation

The connector auto-enables when botToken, token, or apiKey is truthy in the connector config and enabled is not explicitly false.

Configure in ~/.eliza/eliza.json:

json
{
  "connectors": {
    "telegram": {
      "botToken": "your-telegram-bot-token"
    }
  }
}

Disabling

To explicitly disable the connector even when a token is present:

json
{
  "connectors": {
    "telegram": {
      "botToken": "your-telegram-bot-token",
      "enabled": false
    }
  }
}

Setup

  1. Open Telegram and message @BotFather.
  2. Use /newbot to create a new bot and copy the bot token.
  3. Add the token to connectors.telegram.botToken in your config.
  4. Start your agent -- the Telegram connector will auto-enable.

Features

Environment Variables

When the connector is loaded, the runtime pushes the following secret from your config into process.env for the plugin to consume:

VariableRequiredDescription
TELEGRAM_BOT_TOKENYesBot token from @BotFather
TELEGRAM_API_ROOTNoOverride the default Telegram Bot API base URL
TELEGRAM_ALLOWED_CHATSNoJSON-encoded array of authorized chat IDs

Full Configuration Reference

All fields are defined under connectors.telegram in eliza.json.

Core Fields

FieldTypeDefaultDescription
botTokenstringBot token from BotFather
tokenFilestringPath to file containing bot token (alternative to inline)
namestringAccount display name
enabledbooleanExplicitly enable/disable
capabilitiesstring[] or objectCapability flags. Object form supports inlineButtons: "off", "dm", "group", "all", or "allowlist"
dmPolicy"pairing" | "allowlist" | "open" | "disabled""pairing"DM access policy. "open" requires allowFrom to include "*"
allowFrom(string|number)[]User IDs allowed to DM
groupPolicy"open" | "disabled" | "allowlist""allowlist"Group join policy
groupAllowFrom(string|number)[]User IDs allowed in groups
historyLimitinteger >= 0Max messages in context
dmHistoryLimitinteger >= 0History limit for DMs
dmsobjectPer-DM history overrides keyed by DM ID. Each value: {historyLimit?: int}
textChunkLimitinteger > 0Max characters per message chunk
chunkMode"length" | "newline"Long message splitting strategy
mediaMaxMbnumber > 0Max media file size in MB
configWritesbooleantrueAllow config writes from Telegram events
replyToMode"off" | "first" | "all"Reply threading mode
linkPreviewbooleanEnable/disable link previews
timeoutSecondsinteger > 0500grammY request timeout
proxystringProxy URL for Telegram API requests
markdownobjectTable rendering: tables can be "off", "bullets", or "code"
commandsobjectnative and nativeSkills command toggles

Streaming Configuration

FieldTypeDefaultDescription
streamMode"off" | "partial" | "block""partial""partial" sends incremental message edits. "block" waits for full response. "off" disables streaming
blockStreamingbooleanDisable streaming entirely
blockStreamingCoalesceobjectCoalescing settings: minChars, maxChars, idleMs
draftChunkobjectDraft chunking settings (see below)

Draft chunk controls how partial streaming messages are split:

FieldTypeDescription
draftChunk.minCharsintegerMinimum characters before sending a draft
draftChunk.maxCharsintegerMaximum characters per draft chunk
draftChunk.breakPreference"paragraph" | "newline" | "sentence"Where to prefer breaking drafts

Actions

FieldTypeDescription
actions.reactionsbooleanSend reactions
actions.sendMessagebooleanSend messages
actions.deleteMessagebooleanDelete messages
actions.stickerbooleanSend stickers

Reaction Notifications

FieldTypeDescription
reactionNotifications"off" | "own" | "all"Which reactions trigger notifications
reactionLevel"off" | "ack" | "minimal" | "extensive"Reaction response verbosity

Custom Bot Commands

Define custom entries in the Telegram bot command menu:

json
{
  "connectors": {
    "telegram": {
      "customCommands": [
        { "command": "status", "description": "Check agent status" },
        { "command": "help", "description": "Show help message" }
      ]
    }
  }
}

Group Configuration

Per-group settings are defined under groups.<group-id>:

FieldTypeDescription
requireMentionbooleanOnly respond when @mentioned
toolsToolPolicySchemaTool access policy
toolsBySenderobjectPer-sender tool policies (keyed by sender ID)
skillsstring[]Allowed skills
enabledbooleanEnable/disable this group
allowFrom(string|number)[]Allowed user IDs
systemPromptstringGroup-specific system prompt

Topic Configuration

Per-topic settings are defined within a group under groups.<group-id>.topics.<topic-id>:

FieldTypeDescription
requireMentionbooleanOnly respond when @mentioned
skillsstring[]Allowed skills
enabledbooleanEnable/disable this topic
allowFrom(string|number)[]Allowed user IDs
systemPromptstringTopic-specific system prompt

Webhooks

For production deployments, use webhooks instead of polling:

json
{
  "connectors": {
    "telegram": {
      "webhookUrl": "https://your-domain.com/telegram/webhook",
      "webhookSecret": "your-webhook-secret",
      "webhookPath": "/telegram/webhook"
    }
  }
}

When webhookUrl is set, webhookSecret is required.

Network and Retry

FieldTypeDescription
network.autoSelectFamilybooleanAuto-select IPv4/IPv6
retry.attemptsintegerMax retry attempts
retry.minDelayMsintegerMinimum retry delay
retry.maxDelayMsintegerMaximum retry delay
retry.jitternumberJitter factor

Heartbeat

json
{
  "connectors": {
    "telegram": {
      "heartbeat": {
        "showOk": true,
        "showAlerts": true,
        "useIndicator": true
      }
    }
  }
}

Multi-Account Support

The accounts field allows running multiple Telegram bots from a single agent:

json
{
  "connectors": {
    "telegram": {
      "accounts": {
        "bot-1": { "botToken": "...", "groups": { } },
        "bot-2": { "botToken": "...", "groups": { } }
      }
    }
  }
}