Skip to content

Telegram: add reply-to context + native reply send#42

Merged
steipete merged 3 commits intoopenclaw:mainfrom
joshp123:feature/quick-updates
Dec 23, 2025
Merged

Telegram: add reply-to context + native reply send#42
steipete merged 3 commits intoopenclaw:mainfrom
joshp123:feature/quick-updates

Conversation

@joshp123
Copy link
Contributor

@joshp123 joshp123 commented Dec 21, 2025

Human written summary:

  • Until now, the telegram bot didn't support native replies. This meant that the bot got confused as to which message it was replying to, and which messages the user was replying to.
  • That was not so nice, and wasn't the best UX. So we codex fixed it!

Here it is in action:
image

Codex written summary:

  • Capture reply-to metadata on Telegram inbound messages and surface it to the agent.
  • Append reply context to the inbound Body for clearer thread awareness.
  • Use Telegram's native reply (reply_to_message_id) for outbound replies.

Details:

  • src/telegram/bot.ts: chain multi-part replies by threading subsequent messages to the last sent message_id.
  • src/telegram/bot.ts: fix verbose gating so reply-context logs actually emit when --verbose is set.
  • src/telegram/bot.ts: add verbose-only reply-context + reply-send logs for debugging.
  • src/telegram/bot.ts: parse reply_to_message, set ReplyToId/ReplyToBody/ReplyToSender, and reply using reply_to_message_id.
  • src/auto-reply/templating.ts: add ReplyTo* fields for templates.
  • src/telegram/bot.test.ts: cover reply-to context mapping.

Testing:

  • pnpm test src/telegram/bot.test.ts

Anonymized log excerpt (from local gateway log, names/IDs redacted; message text preserved):

  • 2025-12-21T14:32:48Z [gws] stream=assistant text=You're replying to your own message: "taps is this thing on?" 🎤
  • 2025-12-21T14:33:05Z [gws] stream=assistant text=You're replying to my message: "Yep, still here! 🎤 24 minutes later and all systems go. What's up?"
  • 2025-12-21T14:33:14Z [gws] stream=assistant text=You're replying to my message: "Got it! I'm ready to test reply mode with you..." (the one with the plan and 🎯)

Latest redacted reply-context logs (successful multi-part send)

{"0":"[gws] → event agent seq=297 clients=0 run=7b959bc6…1ecc stream=assistant aseq=83 text=Got it! So splitting only happens at 4000+ chars, not on `\\n\\n`. Makes sense. Let me test the threading properly by sending a long message that will force a sp…","_meta":{"runtime":"node","runtimeVersion":"22.21.1","hostname":"unknown","name":"clawdis","date":"2025-12-21T15:17:45.705Z","logLevelId":3,"logLevelName":"INFO","path":{"fullFilePath":"file:///Users/josh/code/clawdis/src/logging.ts:2:2610","fileName":"logging.ts","fileNameWithLine":"logging.ts:2","fileColumn":"2610","fileLine":"2","filePath":"src/logging.ts","filePathWithLine":"src/logging.ts:2","method":"console.log"}},"time":"2025-12-21T15:17:45.705Z"}
{"0":"[gws] → event agent seq=298 clients=0 run=7b959bc6…1ecc stream=assistant aseq=84 text=Got it! So splitting only happens at 4000+ chars, not on `\\n\\n`. Makes sense. Let me test the threading properly by sending a long message that will force a sp…","_meta":{"runtime":"node","runtimeVersion":"22.21.1","hostname":"unknown","name":"clawdis","date":"2025-12-21T15:17:45.877Z","logLevelId":3,"logLevelName":"INFO","path":{"fullFilePath":"file:///Users/josh/code/clawdis/src/logging.ts:2:2610","fileName":"logging.ts","fileNameWithLine":"logging.ts:2","fileColumn":"2610","fileLine":"2","filePath":"src/logging.ts","filePathWithLine":"src/logging.ts:2","method":"console.log"}},"time":"2025-12-21T15:17:45.877Z"}
{"0":"telegram reply-send: chatId=REDACTED replyToMessageId=REDACTED kind=text","_meta":{"runtime":"node","runtimeVersion":"22.21.1","hostname":"unknown","name":"clawdis","date":"2025-12-21T15:17:45.881Z","logLevelId":3,"logLevelName":"INFO","path":{"fullFilePath":"file:///Users/josh/code/clawdis/src/logging.ts:2:2610","fileName":"logging.ts","fileNameWithLine":"logging.ts:2","fileColumn":"2610","fileLine":"2","filePath":"src/logging.ts","filePathWithLine":"src/logging.ts:2","method":"console.log"}},"time":"2025-12-21T15:17:45.881Z"}
{"0":"telegram reply-send: chatId=REDACTED replyToMessageId=REDACTED kind=text","_meta":{"runtime":"node","runtimeVersion":"22.21.1","hostname":"unknown","name":"clawdis","date":"2025-12-21T15:17:46.924Z","logLevelId":3,"logLevelName":"INFO","path":{"fullFilePath":"file:///Users/josh/code/clawdis/src/logging.ts:2:2610","fileName":"logging.ts","fileNameWithLine":"logging.ts:2","fileColumn":"2610","fileLine":"2","filePath":"src/logging.ts","filePathWithLine":"src/logging.ts:2","method":"console.log"}},"time":"2025-12-21T15:17:46.924Z"}

@joshp123 joshp123 marked this pull request as ready for review December 21, 2025 14:36
@joshp123 joshp123 force-pushed the feature/quick-updates branch 3 times, most recently from 52e07d8 to 0286af2 Compare December 21, 2025 15:07
if (replyTarget && isVerbose()) {
const preview = replyTarget.body.replace(/\s+/g, " ").slice(0, 120);
logVerbose(
`telegram reply-context: replyToId=${replyTarget.id} replyToSender=${replyTarget.sender} replyToBody="${preview}"`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this might be slightly overkill. but it is hidden behind the verbose logging mode.

@steipete
Copy link
Contributor

Oh love this, thank you!

@steipete steipete force-pushed the feature/quick-updates branch from 0286af2 to f6e8a76 Compare December 23, 2025 01:30
@steipete steipete merged commit 950432e into openclaw:main Dec 23, 2025
5 of 11 checks passed
@joshp123
Copy link
Contributor Author

Awesome, thanks for the merge! 🙏

nongyehong added a commit to nongyehong/openclaw that referenced this pull request Jan 31, 2026
…y support

- Change channel key from `proluofireIm` to `proluofire-im` for consistency
- Add `wsUrl` configuration field for WebSocket connections
- Update documentation to reflect text-only support (media and threads not yet implemented)
- Simplify target format to room IDs (`42` or `openclaw#42`) instead of `@username`/`#groupname`
- Update CLI examples to use `--channel`, `--target`, and `--message` flags
- Add webhook handler registration
Pastorsimon1798 pushed a commit to Pastorsimon1798/openclaw that referenced this pull request Feb 1, 2026
Implements bidirectional Cursor-Liam communication and increases monitoring
frequencies during the first 2 weeks of development.

Evolution Queue Automation:
- Add CURSOR-RESOLUTIONS.md for Cursor to log resolutions
- Create queue-cleanup.sh for automated detection of resolved/stale items
- Archive 18 resolved + 3 cancelled items to EVOLUTION-QUEUE-ARCHIVE.md
- Enhance self-audit.sh with queue integrity checks

Debug Mode (until 2026-02-10):
- Add Evening-Self-Audit cron (6 PM daily)
- Change self-evaluation to Wed+Sun (was Sun only)
- Change Queue-Cleanup to Wed+Sun (was Sun only)
- Add Model-Health-Check cron (10 AM daily)
- Create model-health.sh to test all model endpoints
- Update HEARTBEAT.md with debug mode schedule
- Add Evolution Queue openclaw#42 for reversion reminder

Model Configuration Updates:
- Enable reasoning for glm-4.7-flash, qwen3-vl:4b
- Increase context windows to spec (glm: 198K, qwen: 256K, lfm: 128K)
dgarson referenced this pull request in dgarson/clawdbot Feb 2, 2026
songliu0403-rgb pushed a commit to songliu0403-rgb/openclaw that referenced this pull request Feb 26, 2026
Piboonsak added a commit to Piboonsak/openclaw_github that referenced this pull request Mar 3, 2026
Config changes (openclaw#33):
- Switch primary model to anthropic/claude-sonnet-4-5 (Claude Sonnet 4.6)
- Add model to deploy.sh post-deploy config, update fallback chain

Nginx changes (openclaw#32, openclaw#21):
- Increase /line/ proxy_read_timeout from 120s to 300s for complex agent responses

Docker build (openclaw#39):
- Enable OPENCLAW_INSTALL_BROWSER=1 build-arg to include Chromium in image

Deploy pipeline fix:
- deploy-vps.yml now actually applies nginx config (was only staging to .new)
- Added backup + rollback safety for nginx config changes
- Removed broken nginx path from deploy.sh (was referencing wrong VPS path)

Issues addressed: #9, openclaw#20, openclaw#21, openclaw#22, openclaw#23, openclaw#32, openclaw#33, openclaw#37, openclaw#39, openclaw#42, openclaw#45, openclaw#46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants