Buni.aiDocs
API referenceFlows

Trigger a chatbot flow (sync)

Starts a chatbot project's flow from an external event and waits for the result.

POST/flows/{projectId}/trigger

Starts a chatbot project's flow from an external event and waits for the result.

Requires the flow:trigger scope. Only chatbot projects are accepted: an automation project returns 400 Automation projects must use the automation trigger API, and any other project type returns 400 External API access is not supported for this project type.

The request is checked against the flow's Trigger node: the external trigger must be enabled, a triggerKey you send must match the node's key, and the payload must contain every top-level key of the node's payload schema. A failed check returns 500 with the reasons in error. Send dryRun: true to see the validation result without running the flow.

A chatbot's Trigger node has no editor for the expected payload, so it keeps the default keys event and customerId; send both as top-level fields.

Authorization

AuthorizationBearer <token>

Authorization: Bearer bai_ext_.... Tokens belong to one project and carry scopes: bot:invoke, flow:trigger, automation:trigger.

In: header

Scope: flow:trigger

Path Parameters

projectId*string

The project ID. The token must belong to this project.

Header Parameters

x-idempotency-key?string

Up to 128 characters. A repeat of a key already used for the same project, target and mode returns the original run instead of starting a new one. Longer keys are ignored.

Lengthlength <= 128

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X POST "https://example.com/flows/string/trigger" \  -H "Content-Type: application/json" \  -d '{    "triggerKey": "external_event",    "event": "checkout.started",    "customerId": "cus_123",    "cartTotal": 4900  }'

{  "invocationId": "clx9kb0d10007ab12cd34ef11",  "status": "SUCCEEDED",  "result": {    "messages": [      "Hi Ama, you left 2 items in your cart."    ],    "actions": []  }}