comfyui
Seamlessly integrate ComfyUI AI workflows into your Drupal site with dynamic forms, intelligent dependency management, secure media handling, and Layout Builder support.
Alpha Release Notice
This module is currently in alpha development and has only been tested on limited workflows. While functional, it may have bugs and incomplete features. Use with caution in production environments and please report any issues you encounter.
Overview
This module transforms your Drupal site into an AI content generation platform by bridging Drupal and ComfyUI, the powerful node-based AI interface. Create interactive workflow forms that allow users to generate AI content directly from your Drupal site with:
- Intelligent dependency resolution (custom nodes & models)
- Dynamic field mapping to ComfyUI workflow parameters
- Secure, tokenized media handling with native Drupal integration
- Professional output processing and results management
- Layout Builder support for custom form interfaces
Key Features
Workflow Management
- Workflow Entities - Create reusable ComfyUI workflows as Drupal entities with version management
- Dynamic Field Mapping - Map Drupal fields to ComfyUI workflow nodes and parameters with full field type support
- Node Definition Discovery - Automatically parses workflows to identify all nodes, inputs, outputs, and types
- Layout Builder Integration - Build custom workflow interfaces with drag-and-drop field blocks
- Multiple Display Modes - Form mode (interactive UI), API mode (headless/programmatic), batch processing
- Queue Processing - Handle long-running workflows with Drupal's queue system for async execution
Dependency Management
-
Custom Node Discovery
- Automatically detects required custom nodes from workflows
- Dynamically fetches repositories from ComfyUI Manager database (cached)
- Conflict resolution for node overrides
- Manual override for private/unlisted nodes
-
Model Discovery & Mapping
- Automatically identifies all model dependencies (checkpoints, LoRAs, VAEs, ControlNets, upscalers, etc.)
- Dynamically parses ComfyUI Manager model database (cached for performance)
- Automatic download URLs and installation paths
- Smart path detection for correct installation locations
- Multi-source support (HuggingFace, CivitAI, etc.)
- Easy mapping UI for manual model configuration
- JSON API Export - All dependency data accessible via JSON:API for automated startup scripts and environment provisioning
Media Handling & Security
-
Native Drupal Media Library Integration
- Full integration with Drupal's media module for centralized asset management
- Generated content stored as media entities with rich metadata
- Reusable media across multiple workflows and content types
- Comprehensive media browser with grid preview
-
Dual-Mode Media Browsing
- Select from existing media library or upload new
- Thumbnail previews with image resolution display (e.g., 1920×1080px)
- User-authored filtering (restrict to current user's uploads)
- Native Drupal media library browser with inline search and filtering
-
Image Proxy & Streaming
- Tokenized image proxy with HMAC-SHA256 validation
- Serve input images from Drupal filesystem with secure token verification
- Stream output images directly from ComfyUI
- Support for PNG, JPG, GIF, WebP with automatic CORS headers
- Cache-based access control with configurable expiration
-
Secure Filename Protection
- 32-character random hash prefixes instead of sequential filenames
- Prevents enumeration attacks on generated content
- Automatic injection into SaveImage nodes
- Audit trail for prompt ID to filename mapping
-
Auto-Save on Completion
- Generated media auto-saved as Drupal media entities after workflow completion
- Configurable enable/disable per-workflow
- Preserves workflow context, prompt ID, and metadata
- User-controlled save/discard options
Author Feedback & Quality Control
-
Built-in Feedback Collection
- Thumbs up/down rating system for generated media
- Optional comment field for detailed feedback
- Feedback form appears immediately after generation in results UI
- Works with both auto-save and manual save modes
-
Quality Insights
- Track author satisfaction with generated results
- Collect actionable feedback on AI output quality
- Stored directly on media entities for easy filtering and analysis
- Admin-configurable: enable/disable feedback collection globally
-
Smart Save Flow
- Auto-save mode: "Save Feedback" button to update existing media
- Manual mode: "Save Image and Feedback" to create media with feedback
- Form-based editing: feedback fields available in media edit form
- No feedback required - users can skip if desired
Advanced Workflow Control
-
Dynamic Node Bypass (NEW - Production Ready)
- Enable/disable entire node groups via Boolean form fields
- Automatically rewires workflow to skip bypassed nodes
- Handles cascading node dependencies with intelligent iterative rewiring
- Type-agnostic: works with ANY custom node or input/output combination
- Map Boolean fields to either node groups or individual nodes
- Perfect for: conditional processing, A/B testing, performance tuning
- This is the only known implementation of dynamic workflow rewiring through ComfyUI's API
-
Smart Seed Management
- Random Seed Widget with Fixed/Random/Use Last modes
- Reproducible AI generation with seed tracking
- Persistent seed history for replicating results
-
Generic Output Node Detection
- Pattern-based detection for SaveImage, PreviewImage, custom nodes, and variants
- Automatic recognition of image, video, and text outputs
- Supports SaveImage_NoWorkflow and other custom implementations
-
Field Validation
- Ensure data integrity with configurable validation rules
- Pre-submission validation feedback
Optional Security
- ComfyUI-Login submodule support for Bearer token authentication
- Secure API communication for public/multi-user deployments
How It Works
- Upload Workflow - Import ComfyUI workflow JSON and API JSON files
- Discover Node Definitions - Parse workflow to identify all nodes and their types
- Discover Dependencies - Identify custom nodes and models (optional, for DevOps)
- Create Drupal Fields - Add fields to your workflow entity (manage fields interface)
- Configure Mappings - Map Drupal fields to workflow nodes and define bypass controls
- Build Forms - Use Layout Builder to create custom interfaces
- Generate Content - Users trigger AI generation with optional node bypass options
- Auto-Save Results - Generated content saved to Drupal media library with optional author feedback (thumbs up/down and comments)
- Display & Reuse - Results can be displayed, reused in other workflows, or shared
Perfect For
- Content creators building AI-powered websites
- Developers integrating AI workflows into client projects
- DevOps teams managing ComfyUI deployments with automated dependency installation
- Artists and designers creating AI content management systems
- Agencies offering AI content generation services
- Site builders providing AI tools to users without technical complexity
Requirements
- Drupal 11 (tested on Drupal 11.x)
- Media module (core, required) - For native media library integration, asset management, and feedback collection
- Layout Builder (core module, required) - For building workflow forms
- Access to a ComfyUI server instance (local or cloud hosted)
- Optional: Key module (for ComfyUI-Login authentication)
- Optional: ComfyUI-Login custom node (for secure API authentication)
Getting Started
- Ensure Media and Layout Builder modules are enabled (both core)
- Download and enable the module
-
Configure your ComfyUI server connection at
/admin/structure/comfyui-workflow/settings - Create your first workflow entity at
/admin/structure/comfyui-workflow - Upload your ComfyUI workflow JSON and API JSON files
-
REQUIRED: Click "Discover Node Definitions"
- Parses the workflow to identify all nodes and their input/output types
- Required before field mapping is available
- Must be done once per workflow update
-
Re-edit the workflow form after uploading JSON files
- This refreshes the form to show newly discovered nodes
- Required step before proceeding to field configuration
-
Create Drupal Fields (in Manage Fields interface)
- Add fields to your workflow entity matching your workflow inputs
- Text fields for prompts, Number fields for seeds, Media fields for images, Boolean fields for bypass controls, etc.
- This must be done BEFORE you can map them to workflow nodes
-
Configure Field Mappings
- Map your newly created Drupal fields to ComfyUI workflow nodes
- Mark fields as input (user edits) or output (workflow produces)
- Define bypass mappings:
- Map Boolean fields to node groups (enable/disable entire groups)
- Map Boolean fields to individual nodes (enable/disable specific nodes)
-
OPTIONAL: Discover Dependencies (for DevOps/Startup Scripts)
- Click "Discover Custom Nodes" - Dynamically fetches from ComfyUI Manager (cached)
- Click "Discover Models" - Dynamically parses model lists and fetches metadata (cached)
- Access dependency data via JSON:API for automated environment setup
- Not needed for end-user form generation, primarily for infrastructure provisioning
-
Use Layout Builder to add:
- ComfyUI Dynamic Field Blocks for inputs (media, text, numbers, toggles, etc.)
- ComfyUI Form Container Block for execution button and results display
-
OPTIONAL: Configure Media Feedback Settings
- Visit
/admin/structure/comfyui-workflow/settings - Enable "Media Feedback" to allow authors to rate and comment on generated results
- Feedback is collected immediately after workflow execution
- Can be edited later in the media entity form
- Visit
- Publish and let users generate AI content!
Workflow Configuration Overview
Understanding the workflow configuration flow helps you set up your workflows correctly:
Core Workflow (Required)
- Upload Workflow Files (workflow.json + workflow_api.json)
- Discover Node Definitions (REQUIRED - unlocks field mapping)
- Re-edit the workflow form (refresh to show nodes)
- Create Drupal Fields (in entity Manage Fields interface)
- Configure Field Mappings (connect Drupal fields to workflow nodes, define bypasses)
- Build Form UI (use Layout Builder to arrange fields and controls)
Optional: Dependency Management (for DevOps)
If you want to automate ComfyUI environment setup (installing custom nodes and downloading models):
- Discover Custom Nodes (dynamically fetches from ComfyUI Manager, cached for performance)
- Discover Models (dynamically parses manager database, cached for performance)
- Export via JSON:API (access data for startup scripts at
/jsonapi/comfyui_workflow/comfyui_workflow/{uuid})
This is optional and primarily useful for infrastructure automation, not for basic workflow execution.
Quick Example: Conditional Image Generator
Setup Steps:
- Add your ComfyUI URL in Settings
- Upload a complex image generation workflow (workflow.json + workflow_api.json)
- Discover Node Definitions (REQUIRED)
- Re-edit the workflow form (refresh)
- Create Drupal fields in Manage Fields:
- Text: "positive_prompt"
- Media: "input_image"
- Number: "seed"
- Boolean: "enable_upscaling" (for bypass control)
- Boolean: "enable_advanced_processing" (for bypass control)
- Configure Field Mappings:
- Map text/media/number fields to workflow nodes
- Set "enable_upscaling" to bypass upscaler node group
- Set "enable_advanced_processing" to bypass quality enhancement nodes
- Use Layout Builder to arrange fields and add Form Container Block
- OPTIONAL: Discover dependencies if you need automated setup
End Result: Users can now:
- Select or upload images from media library with preview
- Enter prompts and configure seed
- Toggle processing options (upscaling on/off, advanced features on/off)
- Generate images with only the workflow steps they need
- Results auto-save to media library
Security: ComfyUI-Login (Optional)
For public or multi-user deployments, enable the optional
ComfyUI-Login integration:
- Install ComfyUI-Login as a custom node in your ComfyUI instance
- Retrieve your Bearer token from ComfyUI startup logs
- Enable the
comfyui_loginsubmodule in Drupal - Store your token in the Key module
- Configure the token in ComfyUI Integration settings
All API requests will automatically include Bearer token authentication.
Development Roadmap
- Workflow Default Values - Set ComfyUI node defaults for all workflows
- Chainable Workflows - Visual workflow chaining (BPMN/n8n-style) for agentic AI
- Complete API Submodule - Full REST API with OAuth2 authentication
- Multiple Endpoints - Queue and process across multiple ComfyUI instances
- External Provider Support - Runpod.io, Vast.ai, etc. with auto-startup
- Dynamic Output Blocks - Place image/video/text outputs anywhere in Layout Builder
- Field Workflows - Trigger AI generation for any content field (translations, images, etc.)
- Advanced Caching - Cache warming and intelligent token invalidation
Maintenance & Support
This module is actively maintained with dedicated sponsorship support.
For issues, feature requests, and documentation, please submit issues in the queue.
Partnership Opportunities: Interested in sponsorship, custom development, or specific features? Contact the maintainer to discuss collaboration opportunities.
Bug reports, testing feedback, and community contributions are welcome!
Maintained by Alexander Renfert