Nodes/ComfyUI Autonomous Telegram Bot/TG Edit Message Text ◀️
ComfyUI Node

TG Edit Message Text ◀️

One message that evolves instead of five that spam

By CoolBreeze164·Created 13 days ago·Updated 2 days ago· 3
TG Edit Message Text ◀️
  • trigger
  • message
  • message_id
  • trigger
◄bot_token►
◄chat_id—►
◄message_id—►
◄text►
◄parse_mode▾►

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:

  1. Send Message: Generating your image… → message_id output
  2. …your sampler does its thing…
  3. Edit Message Text: same chat_id, that message_id, new text like Done 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 incoming message_id instead of a sender's. The bot cannot edit the user's message.
  • Wrong message gets rewritten - editing needs chat_id and message_id to 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 trigger wire 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.
CategoryAutonomous Telegram Bot ◀️/edit

Inputs (6)

NameTypeDefaultDescription
bot_tokenSTRINGTelegram bot token from BotFather
chat_idINTUnique identifier for the target chat
message_idINTUnique Identifier of the message to edit
textSTRINGText of the message to be sent, 1-4096 characters after entities parsing
parse_modeCOMBOMode 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)

NameTypeDescription
messageDICT—
message_idINT—
trigger*—