> ## Documentation Index
> Fetch the complete documentation index at: https://kiro.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Telegram

> Chat with Kiro Crew from Telegram — on your phone, laptop, anywhere. One bot token, no plugins, works behind a firewall.

Telegram is the quickest channel to set up: one bot token, no plugins, and it works from behind a firewall — Kiro Crew reaches out to Telegram, so there's nothing to expose. Replies stream back live with tappable option buttons.

## Setup

### From the dashboard (recommended)

1. Open **Settings → Messaging Channels → Telegram** in the dashboard
2. Message **@BotFather** on Telegram, send `/newbot`, follow the prompts to get a token
3. Message **@userinfobot** to get your numeric user ID
4. Paste the bot token into the dashboard panel
5. Add your user ID to the **Allowed users** list
6. Click **Save** — the gateway restarts and connects

The status badge turns green when connected.

### From the CLI

```bash
# Save token to ~/.kiro/crew/.env
echo "TELEGRAM_BOT_TOKEN=123456789:AA…" >> ~/.kiro/crew/.env
```

In `~/.kiro/crew/config.json`:

```json
{
  "telegram": {
    "enabled": true,
    "allowed_user_ids": [123456789]
  }
}
```

Then: `kirocrew restart`

## Who can reach it

Kiro Crew only talks to the people and places you name.

- Trusted numeric user IDs go in `allowed_user_ids`; an empty list means nobody
- A private chat with an allowed user is always served. If the private chat uses forum topics, each topic is its own session; a message outside any topic keeps the original DM session
- A supergroup's forum topics are served only when `allow_forum` is `true` and the supergroup's chat ID is in `allowed_forum_chat_ids`; an empty list denies every group. Each topic is its own session. A message in the General topic, which has no thread, is denied. `forum_activation` decides when the bot answers inside an allowed topic
- Anyone else is silently dropped and recorded in the audit log

## Commands

| Command | Effect |
|---|---|
| `/new` (or `/start`) | Start a fresh conversation |
| `/compact` | Free up context when it fills |
| `/steer <msg>` | While a reply is generating, fold this message into the current turn |
| `/queue <msg>` | While a reply is generating, hold this message for after the current turn |
| `/session` or `/sessions` | Search and resume a conversation. Add words to search, for example `/sessions billing`; with no words, Kiro Crew lists the ten most recent conversations. |
| `/help` | List commands |

### Messages that arrive mid-turn

When you have resumed a dashboard session with `/sessions` and a message reaches it while a turn is running, Kiro Crew folds the message into the running turn or queues it for the next one. The conversation replies **Steering that session** or **Queued for that session** so you know which happened. Use `/steer` or `/queue` to choose yourself.

## Configuration

| Key | Default | Purpose |
|---|---|---|
| `telegram.enabled` | `false` | Turns the channel on |
| `telegram.allowed_user_ids` | `[]` | Numeric IDs allowed to chat (empty = nobody) |
| `telegram.allow_forum` | `false` | Serve supergroup forum topics as per-topic sessions; also requires the chat ID in `allowed_forum_chat_ids` |
| `telegram.allowed_forum_chat_ids` | `[]` | Numeric supergroup chat IDs allowed to run forum-topic sessions (empty = no groups) |
| `telegram.forum_activation` | `"always"` | When the bot answers inside an allowed topic: `always`, `mention` (its @handle is used or one of its messages is replied to), or `off`. Does not apply to a 1:1 DM |
| `telegram.soft_threshold_pct` | `80` | Context % where the bot suggests `/compact` |
| `telegram.bot_token` | `""` | Token fallback if `TELEGRAM_BOT_TOKEN` isn't set |

Prefer the `TELEGRAM_BOT_TOKEN` env var over `bot_token` — it keeps your secret out of `config.json`.

### Route the Bot API through a proxy

Where `api.telegram.org` is blocked, set `TELEGRAM_API_BASE_URL` in `~/.kiro/crew/.env` to a reverse proxy, then restart the Gateway. The value must be a full method template containing `` and ``:

```text
TELEGRAM_API_BASE_URL=https://tg-proxy.example.com/bot{token}/{method}
```

The URL must use `https`, except for a loopback host (`127.0.0.1`, `::1`, or `localhost`), because the bot token travels in the URL. An invalid value is ignored with a warning in the Gateway log, and the public host is used instead. The Gateway loads `.env` at startup and reads the variable from its environment on every call, so the override applies to every Bot API request once the Gateway has restarted.

## Troubleshooting

| Problem | Fix |
|---|---|
| No reply | Your ID isn't in `allowed_user_ids` or `enabled` is `false` |
| No reply in a supergroup topic | `allow_forum` is `false`, the chat ID isn't in `allowed_forum_chat_ids`, or `forum_activation` is `mention` or `off` |
| `Ignoring TELEGRAM_API_BASE_URL` in logs | The value lacks `` or ``, or uses `http` on a non-loopback host |
| No `Telegram channel started` in logs | Token isn't set or is invalid |
| Slow replies behind a proxy | Set `HTTPS_PROXY` for the gateway process |
