TG Edit Message Text ◀️
One message that evolves instead of five that spam
- trigger
- message
- message_id
- trigger
The naughtiest habit a homebrew bot can have is answering in four separate messages: "got it", "generating", "still generating", "here you go". Users scroll. This node fixes that - it rewrites a message the bot already sent, so your bot behaves like one entity with one mouth instead of a chatty pipeline.
How it works
It calls Telegram's editMessageText. Your chat_id plus a message_id and the new text, nothing else. Telegram replaces the content of that bubble in place, for everyone in the chat, and keeps the same message ID - the history doesn't grow, and the timestamps don't lie.
The one rule that trips up every new bot builder: the message ID must come from a sender. Wire it from Send Message's message_id output, not from the Listener's. Bots can only edit their own outgoing messages; trying to edit a user's message is an instant API error, and the Listener's message_id is exactly the incoming user message.
That's the README's own instruction, and it implies the shape of a nice little pattern:
- Send Message:
Generating your image…→message_idoutput - …your sampler does its thing…
- Edit Message Text: same
chat_id, thatmessage_id, new text likeDone in 22s - seed 4857242
One bubble, updated twice. Wire trigger from the sender into the editor if you want the order enforced rather than assumed.
The inputs that matter
chat_id from the Listener, message_id from a sender. text is 1–4096 characters and multiline. parse_mode offers None (plain, and dropped from the request entirely), HTML, Markdown and MarkdownV2.
Pay attention to parse mode here more than anywhere else, because a failed edit is not as harmless as a failed send. The pack retries connection drops and 5xx errors, but a Telegram 400 is treated as permanent and is raised straight out of the node - so an unescaped underscore in MarkdownV2 or an edit that doesn't actually change anything turns into a ComfyUI execution error and stops your Run (Instant) loop until you fix it. Two very ordinary ways to hit this: malformed markup, and editing a message to the text it already contains.
trigger is the optional * input, purely for sequencing.
Outputs
message is the Telegram response DICT for the edited message, message_id is that same ID (so you can chain a second edit, or hand it to another editor), and trigger mirrors the input.
Note what's missing compared to the senders: there's no disable_notification and no protect_content, because editing a message can't notify or un-notify anyone. The original send's settings still apply to it.
Install
There's nothing extra to install - same pack, same dependencies.
cd ComfyUI/custom_nodes
git clone https://github.com/CoolBreeze164/ComfyUI-Autonomous-Telegram-Bot
python -m pip install -r ComfyUI-Autonomous-Telegram-Bot/requirements.txt
python_embeded\python.exe for the pip step on Windows portable. Requires httpx, numpy, pillow, av>=14.2.0; no models. Manager users can search ComfyUI Autonomous Telegram Bot. Restart ComfyUI, then find it under Autonomous Telegram Bot ◀️/edit.
Common issues
message can't be edited/ 400 error - nine times out of ten you're passing the Listener's incomingmessage_idinstead of a sender's. The bot cannot edit the user's message.- Wrong message gets rewritten - editing needs
chat_idandmessage_idto match. If you wired the chat ID of user A and the message ID from user B's reply, Telegram will tell you, loudly, in the error. - "Message is not modified" - Telegram refuses a no-op edit. Don't edit a message to the same content; use the trigger ordering so the send happens once and the edit happens once with different text.
- Nothing appears until the very end - that's you forgetting to connect the trigger chain, and ComfyUI running the edit before the send something raced. The
triggerwire exists precisely to remove that ambiguity. - Rate limits - edits are API calls too. Edits-per-chat are cheap compared to a fresh message, but a bot that rewrites every second will still meet Telegram's throttling.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| bot_token | STRING | Telegram bot token from BotFather | |
| chat_id | INT | Unique identifier for the target chat | |
| message_id | INT | Unique Identifier of the message to edit | |
| text | STRING | Text of the message to be sent, 1-4096 characters after entities parsing | |
| parse_mode | COMBO | Mode for parsing entities in the photo caption. See https://core.telegram.org/bots/api#formatting-options for more details. | |
| triggeropt | * | Optional trigger to enforce execution order |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| message | DICT | — |
| message_id | INT | — |
| trigger | * | — |