Skip to main content
defineWorkflowBlockTrigger wires an event handler to a trigger block. The handler runs once for each incoming request to metadata.triggerCallbackUrl, the URL registered with the upstream service during activation. Here you decide whether the event should start a workflow run, and (if so) what outcome data to send into the workflow.

Parameters

block
WorkflowBlock
required
The block returned by defineWorkflowBlock in block.ts.
trigger
function
required
The handler function. Receives the raw req (a standard Request object) and a context object with config (typed from the block’s configSchema) and metadata.metadata provides workflow identity context for the incoming event:
FieldTypeDescription
workflowIdstringID of the workflow this block belongs to.
workflowVersionIdstringID of the active workflow version.
workflowBlockIdstringID of this block instance within the workflow.
uniqueActivationIdstringID of the activation that registered this callback. Matches the value passed to activate.
triggerCallbackUrlstringThe URL incoming events are sent to.
workflowTitlestringHuman-readable title of the workflow.
workflowUrlstringLink to the workflow in the Attio UI.

Example

trigger.ts
import {Workflows} from "attio/server"
import block from "./block"

export default Workflows.defineWorkflowBlockTrigger(block, async (req, {config, metadata}) => {
  const signature = req.headers.get("x-signature")

  if (!verifySignature(signature, config.secret)) {
    // Invalid signature — silently drop the request
    return {type: "no-op"}
  }

  const payload = await req.json()

  if (!payload.eventType) {
    // Event not relevant — skip without starting a run
    return {type: "no-op"}
  }

  // Start a workflow run down the "triggered" branch
  return {type: "outcome", id: "triggered", data: null}
})

See also