Skip to content

feat(telegram): expose apiRoot config for custom Bot API server #28535

@alan-purring

Description

@alan-purring

Is your feature request related to a problem?

OpenClaw's Telegram channel hardcodes outbound Bot API calls to api.telegram.org. grammY natively supports a custom apiRoot via its constructor options, but OpenClaw doesn't expose this in channel config.

This blocks several legitimate use cases:

  • Running a Telegram Bot API server locally for higher upload limits (up to 2GB) and faster file access
  • Self-hosted Bot API for privacy-sensitive deployments
  • Testing/development with mock Bot API servers

Describe the solution you'd like

Add channels.telegram.apiRoot (string, optional) that passes through to grammY's Api constructor as apiRoot. When unset, behaviour is unchanged (defaults to https://api.telegram.org).

{
  channels: {
    telegram: {
      apiRoot: "http://localhost:8081",
      botToken: "123:abc",
    }
  }
}

This should also work with multi-account configs:

{
  channels: {
    telegram: {
      accounts: {
        main: {
          botToken: "123:abc",
          apiRoot: "http://localhost:8081",
        }
      }
    }
  }
}

Implementation notes

grammY already supports this - it's a first-class option:

const bot = new Bot("token", {
  client: { apiRoot: "http://localhost:8081" }
});

The change should be minimal - read the config value and pass it through to the Bot/Api constructor. Env fallback TELEGRAM_API_ROOT would be nice but not essential.

Describe alternatives you've considered

  • /etc/hosts redirect + TLS interception: works but fragile and requires disabling certificate validation
  • Webhook-only workarounds: functional for inbound but don't cover outbound API calls

Additional context

Telegram officially supports self-hosted Bot API servers (tdlib/telegram-bot-api) and documents this as the standard way to lift file size limits and reduce latency. grammY's docs cover the client-side config under Bot API.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions