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

TG Edit Message Audio ◀️

Replace the sound in a message the bot already sent

By CoolBreeze164·Created 13 days ago·Updated 2 days ago· 3
TG Edit Message Audio ◀️
  • audio
  • trigger
  • message
  • message_id
  • trigger
◄bot_token►
◄chat_id—►
◄message_id—►
◄caption►
◄parse_mode▾►
◄show_caption_above_mediafalse►
◄file_nameaudio►
◄as_filefalse►

Same idea as the other editors, aimed at audio: post a clip now, replace it later, one message in the history. In practice the use case is a voice/TTS bot where you send a placeholder or a draft take the moment you have something, then drop the final rendered speech into the same bubble once your audio pipeline finishes. It's also the natural end of a "resend, don't spam" reply loop in a group.

What it swaps in

audio is an AUDIO socket - a waveform tensor plus sample rate, not a file - and it takes exactly one item per run; a batch raises Send Audio accepts one AUDIO item (batch size 1). The tensor is written to WAV first, then, if as_file is off, re-encoded through PyAV to MP3. On the wire the media type is audio (MP3) by default, or document (WAV) when as_file is on.

Worth knowing before you reach for it: there's no Voice option here. Send Audio can post Ogg/Opus voice notes, but this editor only offers audio or document. If you want the scrubby voice-note bubble, that decision has to be made at send time - you can't convert an existing message into a voice note with this node.

file_name names the attachment (default audio; the extension is added). caption is 0–1024 characters and parse_mode (None/HTML/Markdown/MarkdownV2) applies to it. show_caption_above_media moves the caption above the player. trigger is the untyped ordering input - connect it from the sender so the edit can't beat the send.

message_id must come from something the bot sent (Send Audio's message_id), together with the matching chat_id. The Listener's incoming message_id is the user's message and will be refused: bots only edit their own.

Outputs

message is the Telegram response DICT for the edited message, message_id is that same ID (so you can chain edits), and trigger mirrors the input. If the request fails all five attempts the pack logs a warning and returns silent blockers instead of an error, so a bad connection skips the replacement rather than stopping Run (Instant) - but note the flip side: a Telegram 400 is treated as permanent and does raise, which means an unsupported media swap or invalid parameters will stop the loop until you fix it.

Install

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

Portable users: python_embeded\python.exe from the portable root. Requirements are httpx, numpy, pillow and av>=14.2.0 - PyAV is the one doing the MP3 encode, its wheels bundle the codecs, and no ffmpeg binary or PATH edit is needed. Manager search: ComfyUI Autonomous Telegram Bot. Restart ComfyUI afterwards; node appears under Autonomous Telegram Bot ◀️/edit.

Common issues

  • "One AUDIO item" error - batch of two. Handle one sound per run; under Run (Instant) that usually means one message per run anyway.
  • Voice note turned into a music file - expected, see above. This node can't produce the voice-note presentation.
  • Audio sounds duller after the edit - MP3 re-encoding at the pack's fixed settings. Flip as_file on to send lossless WAV as a document instead.
  • Edit refused with a permanent error - the message_id isn't the bot's, the chat ID doesn't match, or Telegram won't accept the media type you're substituting. The console line names the method and Telegram's description, which is the fastest clue you'll get.
  • Timing weirdness - chain trigger from sender to editor. Ordering is not guaranteed by graph layout alone.
CategoryAutonomous Telegram Bot ◀️/edit

Inputs (10)

NameTypeDefaultDescription
bot_tokenSTRINGTelegram bot token from BotFather
chat_idINTUnique identifier for the target chat
message_idINTUnique Identifier of the message to edit
audioAUDIOthe audio 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_nameSTRINGaudiothe file name for this media
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*—