Scheduling & Triggers
Purpose and Scope
This document covers the scheduling and triggering mechanisms for recipe execution in Automatos AI. Recipes can be executed in three ways: manual on-demand execution, automated cron-based scheduling, and event-driven webhook triggers. For information about the recipe execution process itself, see Recipe Execution. For configuration of retry logic and timeouts, see Execution Configuration.
Schedule Types Overview
Automatos AI supports three execution trigger types for workflow recipes, each designed for different automation scenarios. The schedule type is configured during recipe creation as the fourth step of the wizard and stored in the schedule_config JSONB field of the WorkflowTemplate model (aliased as WorkflowRecipe).
Supported Schedule Types
manual
Ad-hoc execution
User clicks "Execute" or calls API
None
cron
Time-based automation
RecipeSchedulerService checks expression
Cron expression (5-part)
trigger
Event-driven automation
External webhook or Composio event
Webhook URL or Composio app config
Schedule Type Flow - Code Entity Mapping
Sources: orchestrator/api/workflow_recipes.py:34-47, orchestrator/api/workflow_recipes.py:50-126, orchestrator/api/workflow_recipes.py:812-877, orchestrator/core/models/core.py:1-20
Manual Execution
Manual execution is the default schedule type, requiring explicit user action to trigger recipe execution. This mode is suitable for testing, debugging, and workflows that should only run when explicitly invoked.
Configuration
The manual schedule type requires no additional configuration beyond setting type: 'manual' in the schedule_config object.
Execution Methods
Frontend UI:
Navigate to recipe detail page
Click the "Execute" or "Cook" button
Recipe executes immediately with optional input parameters
Backend API:
POST /api/workflow-recipes/{id}/executeRequest body can include input data matching the recipe's input schema
Returns execution ID for tracking progress
UI Components
The manual execution interface displays informational guidance and a disabled test button that becomes active after the recipe is saved:
Sources: frontend/components/workflows/recipe-schedule-config.tsx:164-192
Cron-Based Scheduling
Cron-based scheduling enables time-based automated execution using standard 5-part cron expressions. The system parses the cron expression and executes the recipe at matching times.
Cron Expression Format
Automatos AI uses the standard 5-field cron format:
Field Ranges:
minute: 0-59hour: 0-23day(month): 1-31month: 1-12day(week): 0-7 (0 and 7 both represent Sunday)
Backend Cron Scheduler Service
The _sync_cron_schedule() function synchronizes recipe schedules with the RecipeSchedulerService:
This function is called:
After recipe creation (line 495)
After recipe update (line 623)
During recipe deletion to unschedule (line 667)
Cron Scheduler Architecture
Sources: orchestrator/api/workflow_recipes.py:34-47, orchestrator/api/workflow_recipes.py:495, orchestrator/api/workflow_recipes.py:623, orchestrator/api/workflow_recipes.py:667-672
Quick Pick Templates
The UI provides common cron patterns as quick-pick options:
Every hour
0 * * * *
At minute 0 of every hour
Daily at 9am
0 9 * * *
Every day at 9:00 AM
Weekdays at 9am
0 9 * * 1-5
Monday-Friday at 9:00 AM
Weekly on Monday
0 9 * * 1
Every Monday at 9:00 AM
UI Configuration
The cron scheduling interface provides:
Quick Pick Dropdown - Select from predefined schedules
Manual Expression Input - Enter custom cron expression with field labels
Next Runs Preview - Visual list of upcoming execution times
Validation Feedback - Real-time error display for invalid expressions
Sources: frontend/components/workflows/recipe-schedule-config.tsx:195-263
Webhook Triggers
Webhook triggers enable event-driven recipe execution through HTTP POST requests. The system supports two trigger sources: custom webhooks and Composio app integrations.
Webhook URL Generation
Each recipe with trigger-based scheduling receives a unique webhook_id (UUID hex string) generated during recipe creation or update.
Webhook ID Assignment Logic
The webhook URL format is:
Webhook ID Generation and Persistence
The webhook URL is displayed in the frontend for custom webhook integrations. External services can POST to this endpoint with JSON payloads that become the recipe's input_data.
Sources: orchestrator/api/workflow_recipes.py:426-429, orchestrator/api/workflow_recipes.py:542-549
Trigger Source Types
Sources: frontend/components/workflows/recipe-schedule-config.tsx:25-28, frontend/components/workflows/recipe-schedule-config.tsx:108-111
Custom Webhook Integration
For custom webhooks, the UI provides:
Webhook URL Display - Read-only input showing the unique webhook endpoint
Copy Button - One-click copy to clipboard with visual feedback
Usage Documentation - Code example showing POST request format
The webhook body is validated against the recipe's input schema before execution.
Sources: frontend/components/workflows/recipe-schedule-config.tsx:268-298, frontend/components/workflows/recipe-schedule-config.tsx:381-394
Composio App Triggers
Composio integration enables recipes to be triggered by events from 250+ connected apps:
Supported Apps (Sample):
GitHub (new issue, new PR, status change)
Slack (new message, new channel)
Gmail (new email, label change)
Jira (new ticket, status update)
Notion (new page, database update)
Linear (new issue, status change)
Salesforce (new lead, opportunity update)
HubSpot (contact created, deal stage change)
Configuration Fields:
trigger_config.app- Selected Composio app nametrigger_config.trigger- Specific event type from the appExternal configuration link to Composio dashboard
The Composio configuration interface shows:
Sources: frontend/components/workflows/recipe-schedule-config.tsx:329-378
Configuration Interface
The scheduling configuration is the fourth and final step in the recipe creation wizard. It provides a tabbed interface for selecting and configuring the schedule type.
Wizard Step Integration
The wizard tracks the current step and validates that users can only proceed if required fields are filled. The schedule step (index 3) always allows proceeding since manual execution requires no configuration.
Sources: frontend/components/workflows/create-recipe-modal.tsx:20-25, frontend/components/workflows/create-recipe-modal.tsx:318-328
Schedule Type Selection
The type selection interface uses a three-column card layout with icons and descriptions:
Sources: frontend/components/workflows/recipe-schedule-config.tsx:134-161
Form State Management
Schedule configuration uses React Hook Form's context to manage state:
Changes are reactive and immediately reflected in the preview panel, which displays schedule badges and complexity calculations.
Sources: frontend/components/workflows/recipe-schedule-config.tsx:90-98, frontend/hooks/use-recipe-form.ts:1-262
Backend Integration
When a recipe is saved, the schedule configuration is transformed from the frontend form format into the backend API payload format, and triggers are automatically registered with external services if needed.
Form to API Transformation
The transformFormToApiPayload function in use-recipe-form.ts handles the conversion:
Form to API Transformation Flow
The transformation logic ensures:
Empty cron expressions are omitted
Empty trigger_config objects are omitted
Only relevant fields are included based on schedule type
Webhook IDs are automatically generated for trigger types
Sources: frontend/hooks/use-recipe-form.ts:79-88
API Payload Structure
The backend expects schedule_config as a structured object:
Sources: frontend/hooks/use-recipe-form.ts:90-102, orchestrator/api/workflow_recipes.py:416-418
Webhook ID Generation
For trigger-based schedules, a unique webhook_id is generated during recipe creation or update if not already present:
This webhook_id serves as a unique identifier for webhook endpoints and trigger subscriptions.
Sources: orchestrator/api/workflow_recipes.py:416-418, orchestrator/api/workflow_recipes.py:528-531
Automatic Trigger Registration
When a recipe with Composio triggers is created or updated, the _auto_register_trigger() function automatically registers the trigger subscription with the Composio API.
Trigger Auto-Registration Process - Code Entity Flow
The function returns the composio_subscription_id on success, or None if no registration was performed (custom webhooks or errors).
Sources: orchestrator/api/workflow_recipes.py:50-126, orchestrator/api/workflow_recipes.py:490-492
TriggerSubscription Model
The TriggerSubscription table (defined in core/models/composio.py) tracks active trigger registrations:
id
Integer
Primary key
entity_id
Integer
FK to composio_entities.id
trigger_name
String
Composio trigger name (e.g., "GITHUB_NEW_ISSUE")
callback_url
String
Webhook endpoint URL (typically /api/composio/webhook)
agent_id
Integer
Optional FK to agents.id
workflow_id
Integer
FK to workflow_templates.id (WorkflowRecipe)
composio_subscription_id
String
Composio's subscription ID (returned from their API)
is_active
Boolean
Whether subscription is active (default True)
TriggerSubscription Lifecycle
The subscription links the recipe to the external trigger source and stores the callback URL where Composio will deliver events.
Sources: orchestrator/api/workflow_recipes.py:28, orchestrator/api/workflow_recipes.py:106-115, orchestrator/api/workflow_recipes.py:129-137, orchestrator/api/workflow_recipes.py:607-620
Custom Webhooks vs Composio Triggers
The system distinguishes between two trigger sources:
Custom Webhooks:
No external registration required
Only need
webhook_idstored inschedule_configEndpoint:
POST /webhooks/recipe/{webhook_id}Payload becomes recipe
input_data
Composio Triggers:
Require registration via Composio API
Create
TriggerSubscriptionrecordCallback URL:
POST /api/composio/webhookComposio forwards events to the callback
Sources: orchestrator/api/workflow_recipes.py:52-56
Trigger Subscription Cleanup
When recipes are updated or deleted, the _cleanup_trigger_subscriptions() function deactivates old trigger subscriptions to prevent orphaned webhooks.
Cleanup Function Implementation
Update Flow:
When schedule_config is modified in update_workflow_recipe():
Line 609: Register new trigger with
_auto_register_trigger()Line 611-620: If new subscription created, cleanup old subscriptions
Line 614-619: Re-activate the newly created subscription (cleanup may have caught it)
Delete Flow:
Sources: orchestrator/api/workflow_recipes.py:129-137, orchestrator/api/workflow_recipes.py:607-620, orchestrator/api/workflow_recipes.py:675
Schedule Storage and Execution
Database Storage
The schedule_config is stored as a JSON field in the workflow_recipes table:
Type: JSON/JSONB column
Structure: Exact match to API payload format
Indexing: The
typefield can be indexed for filtering recipes by schedule type
Related tables:
workflow_recipes: Stores the recipe definition andschedule_configtrigger_subscriptions: Tracks active Composio trigger registrationsrecipe_executions: Records each execution instance
Database Schema Relationships
Sources: orchestrator/api/workflow_recipes.py:26-29
Schedule Execution Flow
Complete Execution Flow by Schedule Type
Sources: orchestrator/api/workflow_recipes.py:783-880, orchestrator/api/workflow_recipes.py:37-56
Recipe Execution Endpoint
The POST /api/workflow-recipes/{recipe_id}/execute endpoint creates a RecipeExecution record and launches an async task via execute_recipe_direct().
Execute Endpoint Implementation (workflow_recipes.py:812-877)
Execution Flow - Code Entity Mapping
Sources: orchestrator/api/workflow_recipes.py:812-877, orchestrator/api/recipe_executor.py:572-922
Execution Status Tracking
The RecipeExecution model (defined in core/models/core.py) tracks execution state:
id
Integer
Primary key (auto-increment)
execution_id
String
Unique execution identifier (exec-{12-char-hex})
recipe_id
Integer
FK to workflow_templates.id
workspace_id
UUID
Workspace isolation (FK to workspaces.id)
status
String
pending, running, completed, failed
current_step
Integer
Current step number (0-indexed, increments during execution)
input_data
JSONB
Input parameters passed to execution
step_results
JSONB
Array of step execution results (compact summaries)
output_data
JSONB
Final output and summary
error_message
Text
Error details if status='failed'
started_at
DateTime
Execution start timestamp (set when status → running)
completed_at
DateTime
Execution completion timestamp
total_duration_ms
Integer
Total execution duration in milliseconds
triggered_by
String
User email, 'webhook', or 'cron'
quality_score
Float
Post-execution quality assessment (0.0-1.0)
created_at
DateTime
Record creation timestamp
updated_at
DateTime
Record last update timestamp
Execution State Transitions
Frontend components (e.g., ExecutionKitchen, RecipeStepProgress) poll the RecipeExecution record via GET /api/workflow-recipes/executions/{execution_id} to display real-time progress.
Sources: orchestrator/core/models/core.py:600-650, orchestrator/api/recipe_executor.py:617-620, orchestrator/api/recipe_executor.py:699-700
Preview Integration
The schedule type is displayed in the recipe preview panel with visual badges:
manual
Play
Primary
"Manual"
cron
Clock
Primary
"Scheduled"
trigger
Webhook
Primary
"Triggered"
The complexity score calculation includes schedule type as a factor:
Manual: +0 points
Cron: +5 points
Trigger: +10 points
Sources: frontend/components/workflows/recipe-preview-panel.tsx:31-35, frontend/components/workflows/recipe-preview-panel.tsx:56-59
Key Configuration Fields
schedule_config Object Structure
Field Descriptions:
type
Always
Schedule execution mode
cron_expression
type === 'cron'
5-part cron string (minute hour day month weekday)
webhook_id
type === 'trigger'
UUID hex for webhook endpoint identification
trigger_config.source
type === 'trigger'
Either 'composio' or 'custom'
trigger_config.trigger_name
Composio triggers
Canonical trigger name (e.g., "GITHUB_NEW_ISSUE")
trigger_config.trigger
Composio triggers
UI shorthand for trigger name (alternative field)
trigger_config.app
Composio triggers
App name (e.g., "github", "slack")
Default Values
When a new recipe is created, the default schedule configuration is:
The webhook_id is generated automatically when the user selects type: 'trigger' and saves the recipe.
Sources: frontend/components/workflows/create-recipe-modal.tsx:95-99, orchestrator/api/workflow_recipes.py:416-418, orchestrator/api/workflow_recipes.py:58-62
Backend Validation
The backend validates schedule_config structure using the WorkflowTemplate.validate_schedule_config() method (defined in core/models/core.py):
Validation Points in API
Validation occurs before committing new or updated recipes to the database. Invalid configurations result in HTTP 400 responses with detailed error messages.
Sources: orchestrator/api/workflow_recipes.py:465-468, orchestrator/api/workflow_recipes.py:595-600
Summary
Automatos AI provides flexible scheduling options for workflow recipes:
Manual Execution - Simple on-demand triggering via UI or API
Cron Scheduling - Time-based automation with standard cron expressions and next-run preview
Webhook Triggers - Event-driven execution via custom webhooks or Composio app integrations
The configuration interface is integrated as Step 4 of the recipe creation wizard, with reactive UI updates, validation, and preview capabilities. Schedule configuration is stored as structured JSON and used by backend services to determine execution timing and triggers.
Last updated

