Skip to main content

Overview

Triggers define how ensembles are invoked. Conductor supports nine trigger types, all configured using the unified trigger: array in your ensemble YAML:
  1. HTTP - Full web routing with path params, CORS, rate limiting, HTML/JSON responses
  2. Webhook - Simple HTTP endpoints for external integrations
  3. MCP - Model Context Protocol tool exposure
  4. Email - Email routing and processing
  5. Queue - Cloudflare Queues message processing
  6. Cron - Scheduled execution with cron expressions
  7. Build - Static generation at build time
  8. CLI - Custom developer commands
  9. Startup - Execute on Worker cold start (initialization)
All triggers use the same configuration pattern:

HTTP Triggers

Full web routing with path parameters, CORS, rate limiting, authentication, and HTML or JSON responses. Use HTTP triggers for building APIs, web pages, and complex web applications.

Basic JSON API

Access: GET /api/users/123 → Returns JSON

Server-Rendered HTML Page

Access: GET /blog/my-post → Returns HTML page

HTTP with Authentication & Rate Limiting

HTTP Request Context

HTTP triggers automatically parse request data and make it available to your ensemble: Cookie Access:
To set cookies in responses, use the cookies operation:
The cookies operation integrates with Location Context for GDPR/CCPA consent-aware cookie management.

HTTP vs Webhook

Rule of thumb: Use http for web routing and pages. Use webhook for receiving webhooks from external services.

Multi-Path HTTP Triggers

Handle multiple related endpoints in a single ensemble using the paths array. This allows one ensemble to serve multiple routes with different HTTP methods and path parameters.
Benefits of Multi-Path Triggers:
  • Organize related endpoints in one ensemble
  • Share authentication and middleware across paths
  • Reduce configuration duplication
  • Keep related business logic together
  • Support RESTful API patterns naturally
Path Parameters:
  • Use :param syntax for dynamic segments (e.g., /users/:id, /posts/:slug)
  • Access via ${input.params.id}, ${input.params.slug}, etc.
  • Works with any HTTP method
Example: Blog API
This single ensemble handles:
  • GET /blog - List all posts
  • GET /blog/:slug - View single post
  • GET /blog/:slug/comments - List comments
  • POST /blog/:slug/comments - Add comment

Complex Website Structure

For full-blown websites with sitemaps, robots.txt, dynamic pages, etc., organize ensembles by route:
Each file is an ensemble with trigger: {type: http}: Example: ensembles/static/robots.yaml
Example: ensembles/static/sitemap.yaml
This approach gives you:
  • ✅ Full control over every route
  • ✅ Each route is testable independently
  • ✅ Easy to add auth, rate limiting per route
  • ✅ Auto-discovery finds all ensembles
  • ✅ SEO-friendly (sitemaps, robots.txt)
  • ✅ Dynamic content from database
  • ✅ AI-powered pages via think agents

Webhook Triggers

Expose ensembles as HTTP endpoints for external services.
You own your webhook paths. You can define any path you want. We recommend using /webhooks/* paths for clarity (e.g., /webhooks/github, /webhooks/stripe).

Basic Webhook

Invoke via HTTP:

Authenticated Webhook

Invoke with authentication:

Webhook Authentication Types

Bearer Token:
HMAC Signature (GitHub-style):
Sender must include:
Basic Authentication:

Async Webhook Execution

For long-running ensembles, return immediately and process in background:
Returns immediately with execution ID:

MCP Triggers

Expose ensembles as Model Context Protocol tools for AI assistants. Conductor automatically generates MCP tool schemas from your ensemble’s inputs definition.

Basic MCP Tool

MCP Endpoints:
  • GET /mcp/tools - List all ensembles exposed as MCP tools (with auto-generated input schemas)
  • POST /mcp/tools/{name} - Invoke an ensemble via MCP protocol
The ensemble becomes available as an MCP tool with auto-generated schema:

Input Schema Generation

Conductor automatically converts your inputs block to MCP’s JSON Schema format:
Becomes:

Authentication Options

Bearer Token (simple or JWT):
If JWT_SECRET is configured in your environment, bearer tokens are validated as JWTs. OAuth (coming soon):

Public MCP Tool

See MCP Integration for complete guide.

Email Triggers

Trigger ensembles via Cloudflare Email Routing. Conductor fully parses RFC822 emails including MIME multipart content and attachments.

Basic Email Trigger

Configure Cloudflare Email Routing to forward to your Worker.

Email Input Fields (RFC822 Parsed)

Conductor parses RFC822 emails and provides structured data to your ensemble: Attachment format:
Example: Processing attachments

Reply with Output

When reply_with_output: true, ensemble outputs are sent back via email:

Queue Triggers

Process Cloudflare Queue messages in batches.

Basic Queue Consumer

Queue Configuration

  • queue - Cloudflare Queue binding name (must match wrangler.toml)
  • batch_size - Maximum messages per batch (default: 10)
  • max_retries - Retry failed messages (default: 3)
  • max_wait_time - Max seconds to wait for batch to fill
Note: To send messages to queues, use the queue operation - see Queue Operation documentation.

Cron Triggers

Schedule ensemble execution with cron expressions.

Basic Cron Trigger

Cron Expression Format

Standard cron syntax (5 or 6 fields):
Examples:
  • "0 0 * * *" - Daily at midnight UTC
  • "0 */4 * * *" - Every 4 hours
  • "0 9 * * 1-5" - Weekdays at 9 AM
  • "0 0 1 * *" - First day of month
  • "0 0 * * 0" - Every Sunday

Cron with Custom Input

Pass data to scheduled executions:
Access in ensemble:

Multiple Cron Triggers

Ensembles can have multiple schedules:

Disable Cron Trigger

Temporarily disable without removing:

Schedule Metadata

Access schedule information in ensemble:

Build Triggers

Run ensembles at build time to generate static content. Build triggers execute during the ensemble conductor build command and are useful for generating documentation, static pages, or pre-computing data.

Basic Build Trigger

Run with: ensemble conductor build

Build with Custom Input

Pass data to build-time executions:
Access trigger metadata in ensemble:

Multiple Build Triggers

Generate different static assets:

Conditional Build

Use enabled to skip builds conditionally:

CLI Triggers

Create custom CLI commands that execute ensembles. CLI triggers are invoked via ensemble conductor run <command> and support options with defaults and validation.

Basic CLI Trigger

Run with: ensemble conductor run generate-docs

CLI with Options

Define command-line options with types and defaults:
Run with:

CLI Options Types

Supported option types:

Access Options in Flow

CLI options are available via ${trigger.options.*}:

Startup Triggers

Run ensembles on Worker cold start, before HTTP routes are registered. Startup triggers are ideal for cache warming, health checks, and initialization tasks.
Cold start semantics: Cloudflare Workers naturally cold start after a few minutes of inactivity. Startup triggers run once per cold start - not on every request.

Basic Startup Trigger

Health Check on Startup

Verify dependencies are available before serving requests:

Startup with Custom Input

Pass static input data to startup ensembles:
Access in ensemble:

Disable Startup Trigger

Temporarily disable without removing:

Performance Considerations

Keep startup triggers fast (under 5 seconds). Cloudflare Workers have a 30-second initialization timeout. While startup triggers run non-blocking via waitUntil(), slow triggers delay background task completion.
Good use cases:
  • Cache warming (KV reads/writes)
  • Health checks (database ping)
  • Configuration loading
  • Metrics initialization
Avoid:
  • Heavy data processing
  • Long-running API calls
  • Complex AI inference
  • Large file operations

Startup vs Cron

If you need predictable timing, use cron. If you need “run once when Worker starts”, use startup.

Multiple Triggers

Ensembles can have multiple triggers of different types:
This ensemble can be invoked via:
  • POST to /webhooks/process
  • MCP tool call data-processor
  • Email to process@example.com
  • Queue message to PROCESS_QUEUE
  • Cron schedule every 6 hours

Trigger Security

Default-Deny Policy

All triggers (except queue and cron) require either:
  • Authentication (auth configuration), OR
  • Explicit public access (public: true)
✅ Valid:
❌ Invalid:

Best Practices

  1. Use environment variables for secrets:
  2. Verify webhook signatures: Use signature auth type for external webhooks
  3. Limit email senders:
  4. Use async for long operations:

Configuration Reference

HTTP Trigger

Webhook Trigger

MCP Trigger

Email Trigger

Queue Trigger

Cron Trigger

Build Trigger

CLI Trigger

Startup Trigger

Response Formats

The format field in the output block controls response serialization and Content-Type headers. Use this for non-JSON responses like CSV, XML, YAML, etc.

Format Types

CSV Export Example

YAML Config Example

iCalendar Event

The extract option specifies which field from the body should be serialized. If not specified, the entire body is serialized.

Triggers vs API Routes

Conductor provides two ways to execute ensembles:

Triggers (This Page)

Triggers are defined in ensemble YAML and provide:
  • Path-based routing with parameters (/users/:id)
  • Per-trigger authentication configuration
  • Rate limiting and CORS settings
  • Auto-discovery from ensemble definitions

API Execute Routes

The /api/v1/execute/* routes provide programmatic access:
API Execution Control: You can control which ensembles are accessible via the Execute API using:
  1. Project-level policy in conductor.config.ts:
  2. Per-ensemble control via apiExecutable:
Key Differences: See Security & Authentication for complete auth documentation.

Next Steps

Security & Auth

API keys, permissions, and authentication

MCP Integration

Expose ensembles as MCP tools

Queue Operation

Queue message processing

Event-Driven

Event-driven patterns