Triggers

Triggers let your workflow server notify the Ebbot platform when something happens in the integrated system. A trigger defines a subscription type in the manifest and registers runtime routes that dispatch events to the workflow engine.

How Triggers Are Discovered

The workflow server scans a module (usually named fns) for functions decorated with @workflow_trigger from integrations_sdk.triggers. Each decorated function becomes a trigger in the generated manifest.

Define a Trigger

Triggers register HTTP routes on the FastAPI app and use dispatch(subscription_id, payload) to send events to subscribers.

from fastapi import FastAPI
from pydantic import BaseModel
from integrations_sdk.triggers import workflow_trigger


class HookData(BaseModel):
    messageId: str
    message: str


@workflow_trigger(
    description="Message received",
    result=HookData,
    installInstructions="Docs on point, README magic",
    docs="How the hook_trigger trigger works",
)
def hook_trigger(dispatch, app: FastAPI):
    @app.post("/hook-trigger/{subscriptionId}")
    def hook_trigger(subscriptionId: str, data: HookData):
        dispatch(subscriptionId, data)

Key points:

  • description, docs, and installInstructions are surfaced in the manifest.

  • result is the Pydantic model or JSON schema for the dispatched payload.

  • The inner FastAPI route is where you parse inbound events and call dispatch.

Connection Env and Subscription Options

Triggers can read env/secrets from the connection or from the subscription itself. This drives the subscription schema in the manifest and ensures the platform collects the right data at install time.

Connection Env and Secrets

Subscription Options and Secrets

Notes:

  • connectionEnv / connectionSecrets pull from the connection.

  • triggerOptions / triggerSecrets are collected per subscription.

  • getEnv(subscription_id) resolves the correct values for that subscription.

Trigger Lifecycle Hooks

Use TriggerEvents to run logic when a subscription is created. This is useful for provisioning remote webhooks or storing derived configuration.

If the hook raises an exception, the subscription creation is rolled back.

Multiple Triggers on One Endpoint

Use with_triggers when several triggers share a route and you want to dispatch by trigger name.

Subscription Schemas in the Manifest

When you set connectionEnv / connectionSecrets or triggerOptions / triggerSecrets, the trigger's subscriptionSchema is included in the manifest so the Ebbot platform knows which values are required to install the subscription.

Runtime Behavior

At runtime, the workflow server:

  • Resolves the subscription by ID.

  • Validates incoming payloads with your Pydantic models.

  • Dispatches events to the engine for each subscription.

If required env or secrets are missing, dispatching fails with a validation error rather than sending incomplete data.

Last updated

Was this helpful?