Skip to content

Flow Triggers

Triggers define how a Flow starts. Each Flow should include a trigger step to accept inputs and kick off execution.

Note: Flows were previously called Apps. Some APIs and UI labels still use App terminology.

Built-in Triggers

  • Form: Collects inputs from a UI form before executing the next step.
  • Peer Message (peer.message): Starts a Flow when a Peer receives a message. The trigger context includes messages derived from the incoming data.
  • Schedule: Starts on a cron schedule you configure.

Tool Webhook Triggers

Installed tools may expose webhook triggers. When you add such a trigger, Cognipeer registers a webhook and provides a unique URL.

  • Outbound: Use the HTTP Request step to send data to external webhooks.
  • Inbound: Enable “Accept Webhook Triggers” in your Flow settings to get a URL; POST payloads to start the Flow.

Execution via API

You can start a Flow with API calls.

  • Execute Flow:

    • POST /v1/flow/execute/:appId
    • Body: { "inputs": { ... } }
    • Auth: Bearer token with apps.run
  • Execute Flow (Public Token):

    • POST /v1/flow/share/execute/:token
    • Body: { ... }

Trigger Context

When a trigger fires, Flow execution receives a context with:

  • _trigger: { type: string, data: any }
  • messages: For peer.message triggers, an array of message objects.
  • Any inputs passed in the request or form fields.

Use these in expressions like { {_trigger.data} } or { {str(messages)} } to feed downstream steps.

Best Practices

  • Always include one trigger step; define nextStepId to continue the Flow.
  • Validate expected payloads for webhook triggers in a Node.js step.
  • For schedules, provide default inputs in settings.

Built with VitePress