Skip to main content
When a user replies to or quotes an earlier message on Telegram, the referenced text is folded into the agent turn as a compact quoted block so the agent honours the referent. Tapping Reply on the bot’s own message now carries the referenced text β€” so a bare β€œdo the second one” resolves correctly:

Quick Start

1

Start the bot β€” context is always on

2

Inspect the resolved quote programmatically


How It Works

The adapter resolves the referenced text inbound, then prompt_text renders it above the new text before the message reaches the agent. prompt_text whitespace-collapses the referenced text and truncates anything over 500 characters with an ellipsis. With no quote it is identical to the plain text. Behavioural rules:
  • Always-on. No YAML or Python flag β€” the feature is default behaviour on Telegram.
  • Best-effort. Any missing field or error falls back to today’s behaviour β€” the turn is never dropped just because resolution failed.
  • Context, never control. Quoted content is injected as context only, never as a control frame β€” consistent with allow_control on BotMessage.
  • Runs behind the gate. MESSAGE_RECEIVED sees content = prompt_text (the rendered turn including the quoted block). Redacting content in the hook is authoritative β€” the separately-resolved quote is cleared so unredacted quoted text can’t leak past.
  • Works in the standalone bot and the gateway. Both praisonai bot and praisonai gateway render prompt_text before dispatch.

Platform Support

Quoted reply resolution is wired on Telegram in this release.

Common Patterns

Do nothing β€” it just works. Start the bot and reply/quote context is folded in automatically.
Redact quoted secrets before the agent sees them. The MESSAGE_RECEIVED hook receives the rendered turn, so scrubbing event_data.content covers a secret that appeared in the quoted message, not just the new text.
Inspect msg.quoted in a custom hook or plugin. The resolved reference exposes the referenced text and its author.

Best Practices

The [In reply to: "…"] block is unambiguous β€” the agent honours the referent without extra system-prompt scaffolding.
MESSAGE_RECEIVED sees the rendered turn β€” redact or deny there, not by peeking at msg.quoted in the agent tools.
It comes from whoever sent the referenced message. It is context, never a control frame.
If a client doesn’t send the quote span, the adapter falls back to reply_to_message.text / caption; if neither is present, the turn goes through unchanged.

Implicit Mentions

The same reply gesture that admits the message under mention_only

Inbound Message Gate

The hook sees the rendered turn, including the quoted block

Bot Gateway

Gateway agents render prompt_text before dispatch too

Control Trust

Why quoted content is context, not control