Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions apps/docs/providers/communications/telegram.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ Roomote user. `/new` starts a fresh conversation instead of continuing the
current one, opening a new topic when Telegram supports it; in a plain private
chat the request joins that chat's conversation.

While a private-chat Fast turn is running, Telegram shows its native
**Thinking** status. Roomote refreshes the temporary draft for long turns and
starts filling that draft with the response when generation takes long enough
to stream. The completed response is always sent as a normal message so it
remains in the conversation. Roomote keeps activity active across intermediate
replies while more work remains, and a final reply clears it naturally.
While a private-chat Fast turn is running, Telegram shows a non-empty
**Roomote is working...** native draft, then replaces it with response text as
generation continues. The completed response is always sent as a normal message
so it remains in the conversation. Roomote keeps activity active across
intermediate replies while more work remains, and a final reply clears it
naturally.
Telegram does not support native drafts in group chats, so groups use
Telegram's standard typing status and receive completed replies instead.

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions packages/sdk/src/server/lib/fast-agent-telegram-activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ import { createFastAgentTypingActivity } from './fast-agent-typing-activity';
export const FAST_AGENT_TELEGRAM_DRAFT_REFRESH_MS = 25_000;
export const FAST_AGENT_TELEGRAM_TYPING_REFRESH_MS = 4_000;
export const FAST_AGENT_TELEGRAM_REASSERT_DELAY_MS = 500;
// Telegram allows 40 draft updates per 30 seconds; stay just above its 750ms floor.
// Pace draft updates independently of model token cadence.
export const FAST_AGENT_TELEGRAM_STREAM_INTERVAL_MS = 800;
const FAST_AGENT_TELEGRAM_THINKING_TEXT = 'Roomote is working...';

function isTelegramPrivateChatId(channelId: string): boolean {
const parsed = Number(channelId);
return Number.isSafeInteger(parsed) && parsed > 0;
}

/**
* Uses Telegram's native Thinking draft in private chats. Groups do not
* support drafts, so they retain Telegram's ordinary typing action.
* Uses a non-empty Thinking draft in private chats, then replaces it with
* streamed response text. Groups retain Telegram's ordinary typing action.
*/
export function createFastAgentTelegramActivity({
provider,
Expand Down Expand Up @@ -56,7 +57,10 @@ export function createFastAgentTelegramActivity({
await provider.sendMessageDraft({
...replyTarget,
draftId: draftId!,
text: draftText.slice(0, TELEGRAM_MAX_MESSAGE_LENGTH),
text: (draftText || FAST_AGENT_TELEGRAM_THINKING_TEXT).slice(
0,
TELEGRAM_MAX_MESSAGE_LENGTH,
),
});
lastDraftWriteAtMs = Date.now();
return;
Expand Down
Loading