Zebflow Docs
trigger.function
Zebflow Docs

trigger.function

Makes this pipeline a function other pipelines call

trigger.function --description TEXT [--parameter TEXT] [--result TEXT] [--schema JSON] [--result-schema JSON] [--example JSON…] → function

Makes this pipeline a function other pipelines call. They call it with function.result.call --function <slug>; the slug is the file's stem (jobs/send-welcome → send-welcome). Answers one key, function: exactly the arguments the caller passed (input.function.<name>, $trigger.<name>); the function's result is what its last node answered (a closing javascript.script.run's script). Declare the contract with --parameter name:type! "doc" / --result name:type! (or full --schema / --result-schema JSON) so callers and the assistant see typed fields. Also the trigger for one-off runs through pipeline_run (| trigger.function | …), where the input argument is what it answers.

Flags

  • --description (required): What this function does and when callers should use it.
  • --parameter: One parameter the function declares, repeated: name:type! plus an optional description. A caller fills it with function.result.call --argument name=value. Example: --parameter columns:string[]! "Source column names."
  • --result: One field of the function's result, repeated: name:type! plus an optional description. Example: --result ok:boolean! "Whether the function succeeded."
  • --schema: The parameters as one full JSON Schema object (instead of --parameter).
  • --result-schema: The result as one full JSON Schema object (instead of --result).
  • --example: Optional JSON example with input and output. Repeat for 1-3 examples.

Examples

A reusable lookup

| trigger.function --description "Find one user by email." --parameter email:string! "Address to look up." --result user:object "The row, or null."

Registered as jobs/find-user; called with function.result.call --function find-user --argument "email={{ $trigger.body.email }}"; the next node reads input.function.email.

Input:

json
{  "email": "[email protected]"}

It answers:

json
{  "function": {    "email": "[email protected]"  }}