Nodes/ComfyUI Telegram Suite/Edit Message Image 🔽
ComfyUI Node

Edit Message Image 🔽

Swap the image in a Telegram message without resending the whole thing

By SwissCore92·Created about a year ago·Updated 2 months ago· 9
Edit Message Image 🔽
  • bot
  • IMAGE
  • trigger
  • message
  • message_id
  • trigger
chat_id
message_id
caption
parse_mode
show_caption_above_mediafalse
file_nameimage
format
as_filefalse

You sent an image to Telegram with Send Image(s) 🔽, then re-ran the sampler and got a better result. You could send a second message - or you could replace the media in the existing one. That's what this node does: it edits an image message in place, so your chat reads like one evolving render instead of a pile of retries.

It's part of the ComfyUI Telegram Suite pack's edit family, sitting alongside Edit Message Caption, Edit Message Video, and Edit Message Audio. The shape of the workflow is always the same: SendImage gives you a message_id, this node consumes it.

How it works

Under the hood it calls Telegram's editMessageMedia API: the old image is swapped for a new one, keeping the message (and its position in the chat) intact. The node converts your IMAGE tensor to bytes with Pillow in the chosen format (PNG/WEBP/JPG), attaches it to the request, and hands the updated message back.

Two Telegram rules decide whether an edit is even allowed, and they explain most "why won't it edit" moments:

  • A bot can only edit messages it sent itself.
  • Media edits via editMessageMedia only work within 48 hours of the message being sent.

After the window closes you can't swap media anymore - you'd resend instead.

Inputs and outputs that matter

  • bot, chat_id - same wiring as every node in this pack: from a Telegram Bot 🔽 node.
  • message_id - the identifier of the message to edit. Plug in the message_id output of the Send Image node that created it.
  • IMAGE - the replacement image.
  • caption, parse_mode - new caption (or keep it; an empty caption clears it).
  • show_caption_above_media - caption above the media instead of below.
  • file_name (default "image") and format - how the replacement is encoded on upload.
  • as_file (default False) - send the edit as a document instead of a photo, which skips Telegram's compression.

Outputs: message (the updated message as a DICT), message_id (an INT - the id stays the same across an edit), and a trigger passthrough.

Installation

Shared with the whole pack:

cd ComfyUI/custom_nodes
git clone https://github.com/SwissCore92/comfyui-telegram-suite.git
cd comfyui-telegram-suite
pip install -r requirements.txt

or install "ComfyUI Telegram Suite" via ComfyUI Manager and restart. Add your bot tokens and chat IDs to ComfyUI/user/default/telegram-suite/config.json, restart again. Light dependencies (httpx, colorama, numpy, pillow), no model files.

Troubleshooting

  • "message to edit not found" - the message wasn't sent by this bot, or you're passing a message_id from the wrong chat/bot. The message_id has to come from a message this same bot sent in this same chat.
  • Edits silently do nothing after a day - the 48-hour media-edit window. Resend instead.
  • "Telegram bot token ... was not found" - the config template still has placeholder values; fill in real tokens and chat IDs.
  • Keep chat_id consistent between the send and edit nodes - they're separate INT wires, and it's easy to grab one from the wrong Telegram Bot node.
CategoryTelegram Suite 🔽/edit

Inputs (11)

NameTypeDefaultDescription
botTELEGRAM_BOTTelegram bot instance
chat_idINTUnique identifier for the target chat
message_idINTUnique Identifier of the message to edit
IMAGEIMAGEthe image(s) to send
captionSTRINGMedia caption, 0-1024 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.
show_caption_above_mediaBOOLEANfalsePass True, if the caption must be shown above the message media
file_nameSTRINGimagethe file name for this media
formatCOMBOimage format
as_fileBOOLEANfalsePass True to send the media as file without compression
triggeropt*Optional trigger to enforce execution order

Outputs (3)

NameTypeDescription
messageDICT
message_idINT
trigger*