#20818: feat(telegram): add draftMinInitialChars and initialDraftText config options
channel: telegram
size: S
Cluster:
Telegram Streaming Enhancements
## Summary
Add two new Telegram channel configuration options to improve user experience by showing immediate feedback when a message is being processed:
- `draftMinInitialChars`: Minimum chars before sending initial draft message (default: 30). Set to 0 to send immediately on message receipt.
- `initialDraftText`: Initial draft text to show immediately when processing starts (e.g., "收到了 我想一想🤔……")
This allows bots to acknowledge message receipt before the AI starts generating a response, improving perceived responsiveness.
## Changes
- `src/config/types.telegram.ts`: Add type definitions
- `src/config/zod-schema.providers-core.ts`: Add Zod validation schema
- `src/telegram/bot-message-dispatch.ts`: Read config and pass to draft stream
- `src/telegram/draft-stream.ts`: Support immediate initial text send
## Usage
```json
{
"channels": {
"telegram": {
"draftMinInitialChars": 0,
"initialDraftText": "收到了 我想一想🤔……"
}
}
}
``"
## Testing
- [x] Verified config validation works
- [x] Verified hot reload applies config changes
- [x] Tested in group chat - initial text appears immediately before AI response
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Adds two new Telegram configuration options (`draftMinInitialChars` and `initialDraftText`) to allow immediate acknowledgment when messages are received, improving perceived bot responsiveness.
- Type definitions and Zod schemas correctly added with appropriate validation (`.int().min(0)` for the numeric field)
- Configuration is properly threaded through `bot-message-dispatch.ts` to `draft-stream.ts`
- Default value of 30 chars maintained for backward compatibility
**Issue found:**
- Race condition in `draft-stream.ts` where the initial text send is fire-and-forget, potentially causing the first streaming update to be dropped if it arrives before the initial send completes
<h3>Confidence Score: 3/5</h3>
- Safe to merge with caution - race condition could cause intermittent initial message drops
- Configuration schema and type definitions are solid, and the feature implementation is straightforward. However, the fire-and-forget async pattern for sending initial text creates a timing issue that could cause the first streaming update to be incorrectly debounced. This is a functional bug but not critical - worst case is the initial acknowledgment message gets replaced by the first stream update instead of being edited.
- Pay close attention to `src/telegram/draft-stream.ts` - the race condition in initial text sending needs to be addressed
<sub>Last reviewed commit: f1ab431</sub>
<!-- greptile_other_comments_section -->
<sub>(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#19665: feat(telegram): native sendMessageDraft streaming (Bot API 9.3)
by edonadei · 2026-02-18
83.0%
#19479: fix(telegram): skip redundant final edit in partial streaming mode
by v8hid · 2026-02-17
81.1%
#17953: fix(telegram): prevent silent message loss and duplicate messages i...
by zuyan9 · 2026-02-16
79.9%
#8310: feat(telegram): Add allowBots support for groups (parity with Disco...
by vishaltandale00 · 2026-02-03
78.4%
#19673: fix(telegram): avoid starting streaming replies with only 1-2 words
by emanuelst · 2026-02-18
78.0%
#12936: fix(telegram): omit message_thread_id for private DM chats
by omair445 · 2026-02-09
77.1%
#7058: feat(telegram): add channel_post handler for broadcast channels
by waifu7498173 · 2026-02-02
77.0%
#18678: fix(telegram): preserve draft message when all final payloads are e...
by julianubico · 2026-02-16
76.8%
#22434: feat(telegram): support sending original quality images
by godenjan · 2026-02-21
76.0%
#15864: feat: add deliverOnlyToolMessages config for clean messaging channe...
by gandalf-the-engineer · 2026-02-14
75.9%