Edit Message Image 🔽
Swap the image in a Telegram message without resending the whole thing
- bot
- IMAGE
- trigger
- message
- message_id
- trigger
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
editMessageMediaonly 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 themessage_idoutput 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") andformat- 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_idfrom the wrong chat/bot. Themessage_idhas 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_idconsistent between the send and edit nodes - they're separateINTwires, and it's easy to grab one from the wrong Telegram Bot node.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| bot | TELEGRAM_BOT | Telegram bot instance | |
| chat_id | INT | Unique identifier for the target chat | |
| message_id | INT | Unique Identifier of the message to edit | |
| IMAGE | IMAGE | the image(s) to send | |
| caption | STRING | Media caption, 0-1024 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. | |
| show_caption_above_media | BOOLEAN | false | Pass True, if the caption must be shown above the message media |
| file_name | STRING | image | the file name for this media |
| format | COMBO | image format | |
| as_file | BOOLEAN | false | Pass True to send the media as file without compression |
| triggeropt | * | Optional trigger to enforce execution order |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| message | DICT | — |
| message_id | INT | — |
| trigger | * | — |