api/src/ai/tools/trigger-flow/prompt.md
Execute flows programmatically. This tool allows you to trigger manual flows, pass data to flows, and chain flows together for complex automation.
flows tool to get the full definitiontrigger: "manual" are designed to be triggered via UI or this tool$trigger.body{
"flowDefinition": {}, // FULL flow object from flows.read
"flowId": "uuid", // Flow ID to trigger
"collection": "name", // Collection context
"keys": ["id1"], // Item IDs (required if flow needs selection)
"method": "POST", // GET or POST (default: GET)
"data": {}, // Optional payload data
"query": {}, // Optional query parameters
"headers": {} // Optional headers
}
For flows with requireSelection: true or undefined:
{
"flowDefinition": {
"id": "abc-123",
"trigger": "manual",
"options": {
"collections": ["products", "orders"],
"requireSelection": true,
"fields": [
{
"field": "reason",
"name": "Reason",
"meta": { "required": true }
}
]
}
},
"flowId": "abc-123",
"collection": "products",
"keys": ["prod-1", "prod-2"], // REQUIRED
"data": {
"reason": "Bulk update" // Required field
}
}
For flows with requireSelection: false:
{
"flowDefinition": {
"id": "xyz-456",
"trigger": "manual",
"options": {
"collections": ["reports"],
"requireSelection": false
}
},
"flowId": "xyz-456",
"collection": "reports",
"keys": [], // Optional when requireSelection: false
"data": {
"type": "monthly"
}
}
Flows with webhook or operation triggers:
{
"flowDefinition": {
"id": "webhook-flow",
"trigger": "webhook",
"options": {
"collections": ["*"] // or specific collections
}
},
"flowId": "webhook-flow",
"collection": "any_collection",
"method": "POST",
"data": {
"custom": "payload"
},
"headers": {
"X-Custom-Header": "value"
}
}
The tool validates:
requireSelection !== false// Step 1: Get flow definition
flows.read({ filter: { name: { _eq: "Export Items" }}})
// Step 2: Trigger with selection
{
"flowDefinition": { /* from step 1 */ },
"flowId": "export-flow-id",
"collection": "products",
"keys": ["1", "2", "3"],
"data": {
"format": "csv",
"email": "[email protected]"
}
}
// For flows that process all items
{
"flowDefinition": {
/* flow with requireSelection: false */
},
"flowId": "batch-process",
"collection": "orders",
"keys": [], // Empty when not required
"data": {
"status": "pending",
"date_range": "last_30_days"
}
}
// Trigger a flow from another flow
{
"flowDefinition": {
/* operation trigger flow */
},
"flowId": "child-flow",
"collection": "notifications",
"data": {
"parent_result": "{{ $last }}", // Data from parent flow
"step": 2
}
}
The triggered flow receives:
$trigger.body - The data parameter you send$trigger.query - The query parameter$trigger.headers - The headers parameter$trigger.collection - The collection context$trigger.keys - The selected item IDs$accountability - User/permission context"*" in collections means any collection is acceptedoptions.fields for required inputsreturn optionaccountability settingrequireSelection - check explicitly1. Read flow definition using flows tool
2. Check trigger type:
- manual → Check requireSelection
- webhook/operation → Keys optional
3. Validate collection in flow.options.collections
4. If requireSelection !== false → keys required
5. Check flow.options.fields for required data fields
6. Trigger with all validated parameters