defineAction and implemented with defineActionHandler.
Declare an action in the manifest
An action has a name, a label and the inputs it takes.- as a button on record pages, when a layout lists it;
- as a step in workflows;
- as a tool for agents, called by its
name; - as an API route.
type is one of text, long_text, email, number, boolean, json or record. A record input holds the id of a record of the object named in objectId. An output list says what the action returns, so a workflow can use the result in a later step and an agent knows what it got back.
By default an agent must ask before it runs an action. approval: 'auto' marks an action that is safe to run on its own.
Implement the action in server code
The code lives in the module’s./server export. A handler pairs the action’s id with the work:
Handler context (ctx)
- Throw an error to fail the action with a message.
- Throw a
RetryableErrorfor a failure that may pass, such as a rate limit. A workflow then retries the step later: see Retries.new RetryableError(message, retryAfterMs?)can carry the delay a service asked for. - Return plain data to hand a result back.
Related
- Connections and events in a module: talk to an outside service.
- Workflows in a module: run actions in the background.