ComfyUI Extension: ComfyUI-telegram-bot-node
ComfyUI custom nodes for Telegram bot integration
Custom Nodes (0)
README
ComfyUI Telegram Bot Custom Nodes
This package provides custom nodes for ComfyUI that enable Telegram bot integration, allowing you to create workflows that can receive messages from Telegram and send responses back.
Features
- Telegram Listener: A node that connects to a Telegram bot and listens for incoming messages
- Save to Telegram: A node that sends messages back to Telegram chats
Installation
Method 1: ComfyUI Manager (Recommended)
- Install ComfyUI Manager
- Go to Manager → Install Custom Nodes
- Search for "Telegram Bot" and install
Method 2: Manual Installation
-
Clone this repository into your ComfyUI custom nodes directory:
cd ComfyUI/custom_nodes/ git clone <repository-url> ComfyUI-telegram-bot-node cd ComfyUI-telegram-bot-node
-
Install the required dependencies:
# On Linux/Mac: ./install.sh # On Windows: install.bat
-
Restart ComfyUI
Important: Make sure the final directory structure looks like:
ComfyUI/
├── main.py (or comfyui_main.py)
├── custom_nodes/
│ └── ComfyUI-telegram-bot-node/
│ ├── __init__.py
│ ├── telegram_nodes.py
│ ├── requirements.txt
│ └── ... (other files)
└── ... (other ComfyUI files)
Method 3: Manual Dependency Installation
If the install scripts don't work, manually install the dependencies:
pip install python-telegram-bot==20.7
Setup
Creating a Telegram Bot
- Open Telegram and search for
@BotFather
- Start a chat and send
/newbot
- Follow the instructions to create your bot
- Save the bot token provided by BotFather
Getting Your Chat ID
- Start a chat with your bot
- Send any message to your bot
- Visit:
https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
- Look for the
chat.id
field in the response
Usage
Telegram Listener Node
This node listens for incoming Telegram messages and outputs:
- message_text: The text content of the received message
- chat_id: The chat ID where the message came from
Inputs:
bot_token
: Your Telegram bot token from BotFathertimeout
: How long to wait for a message (in seconds)
Save to Telegram Node
This node sends messages back to Telegram chats.
Inputs:
bot_token
: Your Telegram bot token from BotFatherchat_id
: The chat ID to send the message to (usually from Telegram Listener)message
: The message text to send
Output:
status
: Status message indicating success or failure
Example Workflow
- Add a Telegram Listener node
- Configure it with your bot token
- Connect the
message_text
output to your text processing pipeline (e.g., to a prompt input) - Process your data (generate images, run text through AI, etc.)
- Add a Save to Telegram node
- Connect the
chat_id
from the listener to thechat_id
input of the sender - Connect your processed result to the
message
input - Run the workflow - it will wait for Telegram messages and respond automatically
Notes
- The bot will only respond to text messages (not images, files, etc.)
- Each Telegram Listener node runs its own bot instance
- The nodes handle async operations internally, so they work seamlessly with ComfyUI's execution model
- Chat IDs are preserved between the listener and sender nodes to enable proper responses
Troubleshooting
- Make sure your bot token is correct
- Ensure the bot has been started by sending
/start
in the chat - Check that the required dependencies are installed
- Verify that your firewall allows the connection to Telegram's servers
Development
Running Tests
The project includes comprehensive unit tests to ensure reliability:
# Run all tests
make test
# Run tests with verbose output
make test-verbose
# Run tests with coverage report
make test-coverage
# Using the test runner directly
python run_tests.py
# Run specific test module
python run_tests.py --specific telegram_nodes
Code Quality
# Install development dependencies
make install-dev
# Run linting
make lint
# Format code
make format
# Run all checks
make check-all
Test Coverage
The test suite covers:
- Node class structure validation
- Input/output type checking
- Error handling and validation
- Integration between nodes
- Project structure compliance
- ComfyUI Manager compatibility
License
MIT License