I created this bot to give my friends a possibility to play with my ComfyUI workflows without installing it and without even knowing what ComfyUI is.
With this bot, you can:
- Run your custom workflows in Telegram
- Prompt your users for inputs, aspect ratios, and models they want to use.
- Rerun prompts with different seeds
- View the resulting image (currently supports displaying one image).
Here's how it works:
- You add your workflows to a designated folder.
- Specify the parameters you want to ask the user for, such as prompts, models, and aspect ratios.
- The bot will present all your workflows to the user by name, allowing them to choose the desired workflow.
- It will then ask the necessary questions, run the workflow, and display the resulting image to the user.
So it's a way to share your workflows with people who don't want to learn or install it.
Before starting, ensure you have:
- git and nodejs installed
- A working ComfyUI instance.
- A Telegram bot token (create one using the @botFather bot on Telegram).
Clone the repository and install dependencies:
git clone <repository link> .
npm install
Create a .env
file in the root directory, using .env.example
as a guide. Fill it with your specific settings. Note that in this basic version, the bot grants access only to users specified in the .env
file.
If the user is not in your allow list, they will see their user_id in their start message, so they can tell you to add them
Create the file SD_MODELS.json
in the root directory using SD_MODELS.example.json
as an example
This is the list of models you want to allow your user to play with
The "PATH" should be exactly like in your ComfuUI "Checkpoint" node, the name - as you want it to be displayed to the user
Add your workflows (read below how to do that)
Then, start the bot:
npm start
Note: The default example workflows might not work in your ComfyUI setup, so it's advisable to review and adjust them as needed.
To add a ComfyUI workflow to the bot:
-
Create and export your ComfyUI workflow as a
.json
file. -
Open the workflows folder in your bot, here:
comfyuibot/server/resources/templates/workflows_custom
-
Duplicate any example workflow file.
-
Insert your JSON code within the
return ()
statement (refer to the example workflow for format). -
Update the settings at the top of the file:
title
: Displayed to users in the Telegram bot.description
: Shown below the title.request_user_for
: Defines user choices. Each "command" is a request to the user. You have 3 ocommand options:model
: The bot will ask the user to choose a model from the list inconfig.js
.prompt
: The bot will prompt the user for input.ar
: The bot will ask user for an aspect ratio.
key
: Specifies how to reference user responses in your workflow.
-
Locate in your workflow where to replace options with user responses (use Ctrl+F for searching). Replace default values with user-chosen options (see default workflows for examples).
-
OPTIONAL: Add example images created with this workflow to
comfyuibot/server/resources/img/workflows_custom
. Name the folder exactly like your workflow file. The bot will display the examples to your user together with workflow descrition.
Note: This bot displays only one resulting image. If your workflow outputs multiple images, only the first will be shown.
Feel free to fork, submit pull requests or suggest improvements.