Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b4fcd61
Add Telegram auto mode polling and init username fallback
timolins Feb 28, 2026
1b5f789
Expose Telegram resetWebhook API
timolins Feb 28, 2026
b13b46b
Refine Telegram API to longPolling and safer auto mode
timolins Feb 28, 2026
df651f9
Fix: Environment variable cleanup sets `process.env.VERCEL` to the st…
vercel[bot] Feb 28, 2026
58e6b44
Fix lint: replace delete env cleanup with Reflect.deleteProperty
timolins Mar 2, 2026
bb01ba5
Harden Telegram polling tests and polish polling docs
timolins Mar 2, 2026
552d8ad
feat(telegram): add native draft streaming with fallbacks
timolins Mar 2, 2026
6b63e4b
feat(telegram): render markdown/ast via HTML parse mode
timolins Mar 2, 2026
c665401
Merge remote-tracking branch 'origin/main' into codex/telegram-sendme…
timolins Mar 2, 2026
65d2312
fix(telegram): render markdown during draft streaming
timolins Mar 3, 2026
219c235
chore(telegram): fix lint and add changeset
timolins Mar 3, 2026
27c94a6
feat(chat,telegram): align fallback stream config and blockquotes
timolins Mar 3, 2026
53a7149
refactor(telegram): simplify stream option handling
timolins Mar 3, 2026
8f610b8
Merge remote-tracking branch 'origin/main' into codex/telegram-sendme…
timolins Mar 3, 2026
abb3340
Merge branch 'main' into codex/telegram-sendmessagedraft-streaming
haydenbleasel Mar 6, 2026
2f98450
fix(telegram): add comment explaining isDM heuristic for chat ID sign…
haydenbleasel Mar 6, 2026
32bd75b
fix(telegram): fall back to post+edit on mid-stream draft failures
haydenbleasel Mar 6, 2026
1deb830
perf(telegram): defer markdown rendering until draft update interval …
haydenbleasel Mar 6, 2026
7851c47
perf(telegram): defer markdown rendering in post+edit fallback stream
haydenbleasel Mar 6, 2026
d14e1c8
refactor(telegram): simplify createDraftId with optional chaining
haydenbleasel Mar 6, 2026
e9a666d
style(telegram): fix formatting for lint compliance
haydenbleasel Mar 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/chat-stream-options-adapter-fallback.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"chat": patch
---

Pass configured fallback streaming options (`updateIntervalMs` and `fallbackPlaceholderText`) through native `adapter.stream()` calls so adapters can align their fallback behavior with `Chat` streaming config.
5 changes: 5 additions & 0 deletions .changeset/telegram-draft-streaming-polish.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@chat-adapter/telegram": patch
---

Add Telegram `sendMessageDraft` streaming in DMs with post+edit fallback, plus HTML markdown rendering for streamed and posted markdown content.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ See the [Getting Started guide](https://chat-sdk.dev/docs/getting-started) for a
| Microsoft Teams | `@chat-adapter/teams` | Yes | Read-only | Yes | No | Post+Edit | Yes |
| Google Chat | `@chat-adapter/gchat` | Yes | Yes | Yes | No | Post+Edit | Yes |
| Discord | `@chat-adapter/discord` | Yes | Yes | Yes | No | Post+Edit | Yes |
| Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Post+Edit | Yes |
| Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Draft API (DMs) + Post+Edit | Yes |
| GitHub | `@chat-adapter/github` | Yes | Yes | No | No | No | No |
| Linear | `@chat-adapter/linear` | Yes | Yes | No | No | No | No |

## Features

- [**Event handlers**](https://chat-sdk.dev/docs/usage) — mentions, messages, reactions, button clicks, slash commands, modals
- [**AI streaming**](https://chat-sdk.dev/docs/streaming) — stream LLM responses with native Slack streaming and post+edit fallback
- [**AI streaming**](https://chat-sdk.dev/docs/streaming) — stream LLM responses with native Slack/Telegram DM streaming and post+edit fallback
- [**Cards**](https://chat-sdk.dev/docs/cards) — JSX-based interactive cards (Block Kit, Adaptive Cards, Google Chat Cards)
- [**Actions**](https://chat-sdk.dev/docs/actions) — handle button clicks and dropdown selections
- [**Modals**](https://chat-sdk.dev/docs/modals) — form dialogs with text inputs, dropdowns, and validation
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/adapters/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Adapters handle webhook verification, message parsing, and API calls for each pl
| Edit message | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Delete message | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| File uploads | ✅ | ✅ | ❌ | ✅ | ⚠️ Single file | ❌ | ❌ |
| Streaming | ✅ Native | ⚠️ Post+Edit | ⚠️ Post+Edit | ⚠️ Post+Edit | ⚠️ Post+Edit | ❌ | ❌ |
| Streaming | ✅ Native | ⚠️ Post+Edit | ⚠️ Post+Edit | ⚠️ Post+Edit | ⚠️ Draft API (DMs) + Post+Edit | ❌ | ❌ |

### Rich content

Expand Down
4 changes: 3 additions & 1 deletion apps/docs/content/docs/adapters/telegram.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ TELEGRAM_API_BASE_URL=https://api.telegram.org
| Reactions (add/remove) | Yes |
| Cards | Text fallback + inline keyboard buttons/link buttons |
| Modals | No |
| Streaming | Post+Edit fallback |
| Streaming | `sendMessageDraft` in DMs + Post+Edit fallback |
| DMs | Yes |
| Ephemeral messages | No |
| File uploads | Single file (`sendDocument`) |
Expand All @@ -159,3 +159,5 @@ TELEGRAM_API_BASE_URL=https://api.telegram.org
- `Button` and `LinkButton` in card `Actions` render as inline keyboard buttons.
- Telegram callback data is limited to 64 bytes. Keep button `id`/`value` payloads short.
- Other rich card elements (images/select menus/radios) render as fallback text only.
- Native draft streaming (`sendMessageDraft`) is currently available in private chats; groups/channels use post+edit fallback.
- `{ markdown: ... }` and `{ ast: ... }` messages are sent with Telegram HTML parse mode for formatting support; plain strings and `{ raw: ... }` are sent as plain text.
2 changes: 1 addition & 1 deletion apps/docs/content/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Each adapter factory auto-detects credentials from environment variables (`SLACK
| Microsoft Teams | `@chat-adapter/teams` | Yes | Read-only | Yes | No | Post+Edit | Yes |
| Google Chat | `@chat-adapter/gchat` | Yes | Yes | Yes | No | Post+Edit | Yes |
| Discord | `@chat-adapter/discord` | Yes | Yes | Yes | No | Post+Edit | Yes |
| Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Post+Edit | Yes |
| Telegram | `@chat-adapter/telegram` | Yes | Yes | Partial | No | Draft API (DMs) + Post+Edit | Yes |
| GitHub | `@chat-adapter/github` | Yes | Yes | No | No | No | No |
| Linear | `@chat-adapter/linear` | Yes | Yes | No | No | No | No |

Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/docs/streaming.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ await thread.post(stream);
| Teams | Post + Edit | Posts a message then edits it as chunks arrive |
| Google Chat | Post + Edit | Posts a message then edits it as chunks arrive |
| Discord | Post + Edit | Posts a message then edits it as chunks arrive |
| Telegram | Draft API (DMs) + Post + Edit | Uses `sendMessageDraft` in private chats, falls back to post+edit in other chats |

The post+edit fallback throttles edits to avoid rate limits. Configure the update interval when creating your `Chat` instance:

Expand Down
52 changes: 51 additions & 1 deletion packages/adapter-telegram/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,57 @@ const bot = new Chat({
});
```

Features include mentions, reactions, typing indicators, file uploads, and card fallback rendering with inline keyboard buttons for card actions.
Features include mentions, reactions, typing indicators, file uploads, Markdown/AST formatting via Telegram HTML parse mode, Telegram draft streaming in DMs (`sendMessageDraft`) with post+edit fallback elsewhere, and card fallback rendering with inline keyboard buttons for card actions.

## Polling mode

When developing locally, you typically can't expose a public URL for Telegram to send webhooks to. Polling mode uses `getUpdates` to fetch messages directly from Telegram instead — no public endpoint needed.

The `longPolling` option is entirely optional. Sensible defaults are applied when omitted.

```typescript
import { createMemoryState } from "@chat-adapter/state-memory";

const telegram = createTelegramAdapter({
botToken: process.env.TELEGRAM_BOT_TOKEN!,
mode: "polling",
// Optional — fine-tune polling behavior:
// longPolling: { timeout: 30, dropPendingUpdates: false },
});

const bot = new Chat({
userName: "mybot",
adapters: { telegram },
state: createMemoryState(),
});

// Optional manual control
await telegram.resetWebhook();
await telegram.startPolling();
await telegram.stopPolling();
```

### Auto mode

With `mode: "auto"` (the default), the adapter picks the right strategy for you. In a serverless environment like Vercel it uses webhooks; everywhere else (e.g. local dev) it falls back to polling.

```typescript
const telegram = createTelegramAdapter({
botToken: process.env.TELEGRAM_BOT_TOKEN!,
mode: "auto", // default
});

const bot = new Chat({
userName: "mybot",
adapters: { telegram },
state: createMemoryState(),
});

// Call initialize() so polling can start in long-running local processes:
void bot.initialize();

console.log(telegram.runtimeMode); // "webhook" | "polling"
```

## Polling mode

Expand Down
Loading