Nodes/Orel's Nodes/Telegram Config Writer
ComfyUI Node

Telegram Config Writer

Set up the bot from inside the graph

By DarkOrel·Created about a month ago·Updated 23 days ago· 1
Telegram Config Writer
    • status
    • config_path
    ◄bot_nameCHBot►
    ◄bot_token►
    ◄chat_nameOrel►
    ◄chat_id►
    ◄write_configtrue►

    The scenario: you want ComfyUI to ping you on Telegram when a run finishes, or let you drive it from your phone. That means the ComfyUI Telegram Suite custom node pack, which wants a config.json with a bot token and a chat ID. Which means SSH-ing into the box to hand-edit JSON.

    This node does that edit from inside ComfyUI, without printing your bot token anywhere you'll paste it.

    What it writes

    It merges an entry into the Telegram Suite config file. Two locations are considered:

    1. {cwd}/user/default/telegram-suite/config.json - where Telegram Suite actually loads from
    2. {ComfyUI user directory}/default/telegram-suite/config.json, if that resolves somewhere different

    If a config already exists at one of them, that's the one it edits. Otherwise it creates the first.

    The format is a JSON object with two maps: bots keyed by bot name, chats keyed by chat name. The merge does exactly two assignments - bots[bot_name] = bot_token and chats[chat_name] = chat_id - on top of whatever was already there. Unrelated bots and chats survive, and running the node twice with the same names updates the same keys rather than piling up duplicates. That's the right behaviour, and it isn't universal: plenty of setup nodes overwrite config files wholesale, which is how you lose a working setup to an experiment.

    Writes go through a temp file in the same directory followed by an atomic replace, so an interrupted write can't leave truncated JSON behind. Then it reads the file back and verifies both entries landed before reporting success.

    Inputs and outputs

    • bot_name (STRING, default CHBot) - the key it writes under.
    • bot_token (STRING, default empty) - your BotFather token.
    • chat_name (STRING, default Orel) - the chat key.
    • chat_id (STRING, default empty) - your chat or group ID. It must be an integer; a string is fine as long as it parses.
    • write_config (BOOLEAN, default true) - set false and nothing is written; it merges in memory and verifies.
    • status (STRING) - a human-readable line plus the config path and a reminder about restarting.
    • config_path (STRING) - the file it used.

    It's an output node, so queueing a prompt runs it - you don't need anything downstream.

    The validation is deliberately light: it requires a bot name, a chat name, a non-empty token with no spaces and at least 20 characters, and a chat ID that parses as an integer. It doesn't try to validate Telegram's token format in detail, which is the right call - a wrong regex would block a valid token forever.

    write_config = false is the useful one. It's a dry run: merge, verify, don't touch the disk. Perfect for confirming the node can see the same config file Telegram Suite will read, before you commit to changing anything.

    Installation

    Two things need to be present, and only one of them is this pack.

    cd ComfyUI/custom_nodes
    git clone https://github.com/DarkOrel/Orels-Nodes.git orels-nodes
    python -m pip install -r orels-nodes/requirements.txt
    

    Then install ComfyUI Telegram Suite separately - it's a different pack, and this node only writes its config file; it doesn't provide the bot. This pack's Dependency Checker can confirm whether it's present (matching comfyui-telegram-suite or ComfyUI-Telegram-Suite, case-insensitively).

    Restart ComfyUI and hard-refresh the browser.

    Gotchas

    The token is a widget, so it's in your workflow JSON. This is the one real caveat, and it's worth stating plainly. ComfyUI serialises STRING widget values into the workflow file - which is embedded in every PNG you save. A bot token typed into this node travels with the graph. Don't post the workflow, don't commit it, and clear the field once the config is written. The status output is scrubbed of the token, and the error paths scrub too, but the widget itself is on you. It's also why this pack's Hugging Face token node takes the opposite approach and refuses a serialised token field entirely.

    Restart after writing. If Telegram Suite already loaded the config at startup, it's holding the old one in memory. The node's own message says this, and it's the number one reason "I set it up and nothing happened."

    Where the file lands depends on your working directory. The primary candidate is relative to cwd, which for a portable ComfyUI install is the ComfyUI folder - but if you launch ComfyUI from somewhere else, the fallback to the user directory is what saves you. If the Suite still isn't picking it up, check config_path against where it expects the file.

    It won't tell you the bot works. A correct config and a functioning Telegram bot are different problems.

    Corrupt JSON is refused, not repaired. If the existing config isn't valid JSON, or doesn't contain bots/chats objects, the node raises and tells you to fix or rename the file. It will not silently rewrite a config it can't parse, which is the conservative choice.

    CategoryOrel's Nodes/Setup

    Inputs (5)

    NameTypeDefaultDescription
    bot_nameSTRINGCHBot—
    bot_tokenSTRING—
    chat_nameSTRINGOrel—
    chat_idSTRING—
    write_configBOOLEANtrue—

    Outputs (2)

    NameTypeDescription
    statusSTRING—
    config_pathSTRING—