Flows in AI Assistants

A flow with the ai_tool trigger is a tool your AI assistant can use in a chat: book a visit, look up an order, take a payment, save a lead. The assistant collects the details the flow needs from the customer, calls the flow, and answers with what the flow tells it.

How a flow becomes a tool

  1. Inputs become questions. Each input with askAi: true (the default) is something the assistant collects before it calls. required inputs must be collected. An enum input limits the answer to its options, and a date input arrives as ISO 8601 text. The input’s description is what the assistant reads, so say what to ask for and in what format.
  2. The description says when. The assistant calls the tool when the chat matches the tool’s description. By default that is the flow’s description.
  3. The answer comes back. With settings.answerMode: "wait" (the default), the assistant waits up to settings.timeoutSec seconds (20 by default, up to 120) and reads the Reply to the AI step’s message before it answers. Keep these flows quick. With "background", the run is queued and the assistant only learns that it started.
  4. Connect it. The flow does nothing until it is given to an assistant with Connect, or in the dashboard.

When you update the flow, its tool picks up the new inputs and answer mode at once. When you delete the flow, its tool is switched off, so the assistant stops calling it.

What the assistant hears back

WhenThe assistant is told
The run finishesThe Reply to the AI step's message. With no message, the flow's result as text
The run reaches a Wait stepThat the flow is in progress and will carry on by itself, plus any Reply to the AI message before the Wait
answerMode is backgroundThat the flow started and the customer should be told it is being handled
A step failsThat the flow failed, to apologise without technical details, and to offer to try again or hand over to a person
The run takes longer than timeoutSecThat the flow took too long, to apologise and offer to try again
The flow is switched offThat this action is unavailable right now
The month's flow runs are used upThat the flow cannot run now, and to say a team member will follow up

Give a Flow to Assistants

Creates the flow’s tool the first time and adds it to each assistant you name. Calling it again reuses the same tool, switches it back on if it was off, and adds it to more assistants. Scope flows:write.

POST/v2.0/flows/{flowId}/connect

Connect Body

ParameterTypeDescription
assistantIdsstring[]Assistant modelIds from GET /v2.0/assistants, up to 10 per call. Leave out to only create the tool
namestringThe tool name the assistant sees: lowercase letters, digits and _. Default: made from the flow name, such as book_a_store_visit. Used only when the tool is first created
descriptionstringWhen the assistant should call it. Default: the flow's description. Used only when the tool is first created
curl -X POST "https://api.sendiee.com/v2.0/flows/6741a2b39d2b4e0011ac1102/connect" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "assistantIds": ["kQ8z3cR7hV2bWa"],
    "description": "Book a visit to the Kesari Loom store when a customer wants to see sarees in person."
  }'
{
  "success": true,
  "data": {
    "tool": {
      "_id": "6741b4c19d2b4e0011ac2201",
      "toolId": "Bv7Kq2Lm9XzR4t",
      "name": "book_a_store_visit",
      "created": true
    },
    "assistants": [
      {
        "modelId": "kQ8z3cR7hV2bWa",
        "name": "Kesari helper",
        "added": true
      }
    ]
  }
}

Connect Result

ParameterTypeDescription
tool._idstringThe tool's id. Disconnect takes it as toolId. Get a flow lists it in assistantTools[].id
tool.toolIdstringThe tool's short id
tool.namestringThe name the assistant sees
tool.createdbooleantrue when the tool was made by this call
assistantsarray[{ modelId, name, added }]. added is false when the assistant already had the tool

Errors

  • 422 NOT_AI_TOOL: only a flow with the ai_tool trigger can be given to an assistant.
  • 403 LIMIT_EXCEEDED: the tool would be new and your plan’s tools are all in use. Remove a tool or upgrade. Reusing an existing tool does not count again.
  • 404 ASSISTANT_NOT_FOUND: one of the assistantIds is not an assistant on this account. Nothing is changed.
  • 400 BAD_ASSISTANT_IDS: assistantIds is not a list.
  • 404 NOT_FOUND: no flow with that id.

Take a Flow Off Assistants

With assistantIds, takes the flow’s tool off those assistants only and keeps it. Without, takes it off every assistant and deletes the tool, which frees a place in your plan’s tool limit. The flow itself stays. Scope flows:write.

POST/v2.0/flows/{flowId}/disconnect

Disconnect Body

ParameterTypeDescription
toolIdstringThe tool's id: assistantTools[].id from Get a flow, or tool._id from Connect
assistantIdsstring[]Assistant modelIds to take it off. Leave out to remove the tool entirely
cURL
# Take it off one assistant, keep the tool
curl -X POST "https://api.sendiee.com/v2.0/flows/6741a2b39d2b4e0011ac1102/disconnect" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "toolId": "6741b4c19d2b4e0011ac2201", "assistantIds": ["kQ8z3cR7hV2bWa"] }'

# Remove the tool from every assistant and delete it
curl -X POST "https://api.sendiee.com/v2.0/flows/6741a2b39d2b4e0011ac1102/disconnect" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "toolId": "6741b4c19d2b4e0011ac2201" }'
{
  "success": true,
  "data": {
    "removed": false,
    "takenFrom": 1
  }
}
{
  "success": true,
  "data": {
    "removed": true
  }
}
  • 400 BAD_TOOL_ID: toolId is missing or not a valid id.
  • 400 BAD_ASSISTANT_IDS: assistantIds is not a list.
  • 404 NOT_FOUND: that tool does not run this flow.

The assistant test chat runs practice runs

When you chat with an assistant in its test chat in the dashboard, the flows it calls run as practice runs. Steps that only read (a sheet lookup, a calendar check, a GET request) run for real, so the answers are real. Steps that send, write or charge are pretended: no message goes out, no row is added, no slot is booked, no payment link is made.

  • Practice runs do not count toward your monthly flow runs.
  • They share the limit of 60 test runs an hour per account. Over it, the assistant is told the flow was not run.
  • They appear in run history with mode: "dry" and startedBy: "preview".

To check a flow on its own, without an assistant, use Test a flow.