Create a chat flow
create_flowCreate a chat flow. It is ALWAYS created inactive (isEnabled false): it answers no one until someone turns it on with set_flow_active, so write it, read it back with get_flow, and let the user decide. There is no isEnabled input. A flow with no keywords and no connectionIds on a MESSAGE_RECEIVED trigger would answer every message on every account once on — build the trigger narrow. Writing also needs chat enabled for the organization and an ADMIN or OWNER role in it, and a new flow counts against the plan's flow limit (403 CHAT_FLOW_LIMIT_REACHED) — the same refusals a person gets in the app. Needs the organization's "Let AI assistants create and edit chat flows" setting (mcpFlowsEnabled; only the organization's OWNER can switch it on, in Settings → Organization → General → AI Assistants; without it the api answers 403 MCP_FLOWS_DISABLED) and a connection authorized with the flows permissions — one authorized before they existed must remove PostRite from the assistant and add it again.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"name": "<name>",
"triggerType": "<triggerType>",
"triggerConfig": "<triggerConfig>",
"graph": "<graph>"
},
"name": "create_flow"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | The flow's name, shown in the app (1 to 200 characters) | |
| graph | Yes | The flow's graph: { entryNodeId, nodes (1 to 100 nodes), edges }, validated by the same schema the app's flow builder saves with. Every node has a unique `id` (letters, digits, - and _) and a `type`; `position` {x, y} is optional (the builder lays out a graph that has none). Node types and their fields (? = optional): SEND_MESSAGE {text (≤1000), attachments?: [{type: image|video|audio|file, url (≤2048), name? (≤255), mimeType? (≤120), size?, mediaId?, external?}], links?: [{id (≤40), label (≤20), url (≤2000)}]}; WAIT {seconds (integer ≤82800)}; WAIT_FOR_REPLY {quickReplies?: [{id (≤40), label (≤20)}], timeoutSeconds? (integer ≤604800)}; CONDITION {kind: HAS_TAG|ATTRIBUTE_EQUALS|CHANNEL_IS|WITHIN_BUSINESS_HOURS, key? (≤80), value? (≤200)}; ADD_TAG|REMOVE_TAG {tag (≤60)}; SET_ATTRIBUTE {key (≤80), value (≤500)}; REPLY_TO_COMMENT {texts[]}; ASK_INPUT {inputKind: email|phone|text, attributeKey (≤80), timeoutSeconds? (integer ≤604800)}; HANDOFF {note? (≤280)}; END. An edge is { from, to, fromHandle? }; `fromHandle` picks the branch: "next" (or omitted) on most nodes, "true"/"false" out of a CONDITION (it needs both), a quick reply's id or "timeout" out of WAIT_FOR_REPLY, "invalid" or "timeout" out of ASK_INPUT. A question is the SEND_MESSAGE that leads into a WAIT_FOR_REPLY: the reply buttons (quickReplies) are offered with that message, and each button becomes a branch. A circular menu is allowed; a run stops after 50 steps. On update_flow, a graph replaces the whole stored graph — send every node and edge, not a patch. | |
| triggerType | Yes | What starts the flow: MESSAGE_RECEIVED | FIRST_MESSAGE | COMMENT_RECEIVED | STORY_REPLY | STORY_MENTION | REFERRAL | MANUAL | ENTRY_POINT. The flow is inactive until set_flow_active turns it on. | |
| connectionIds | No | The connected messaging accounts (platform connection IDs, from list_platform_connections) this flow answers on. Empty or omitted means EVERY messaging account in the organization — say so to the user before turning the flow on. | |
| triggerConfig | Yes | What starts the flow, read per triggerType. Fields (? = optional): matchMode?: CONTAINS|EXACT|STARTS_WITH|ANY, keywords?[], platformPostIds?[], postId?, ref? (≤120). matchMode and keywords narrow a MESSAGE_RECEIVED trigger (no keywords = every message); platformPostIds narrows COMMENT_RECEIVED to those posts (absent = every post on the account, organic ones included); ref is the REFERRAL value of the ig.me / m.me link. Send {} for a trigger that needs no narrowing — the matchMode default applies. | |
| organizationId | No | Organization to act in — an id from list_organizations. Required when this connection was authorized for more than one organization; omit it when there is only one. | |
| cooldownMinutes | No | Minutes before the same contact can start this flow again (0 to 10080); omitted keeps the api default. | |
| maxRunsPerContactPerDay | No | How many times one contact can start this flow in a day (1 to 20); omitted keeps the api default. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | ||
| name | No | ||
| graph | No | ||
| runCount | No | ||
| createdAt | No | ||
| isEnabled | No | true = live: it answers real contacts | |
| updatedAt | No | ||
| triggerType | No | ||
| connectionIds | No | The accounts it answers on; empty = every messaging account | |
| isGraphBroken | No | The stored graph no longer parses; rewrite it with update_flow | |
| triggerConfig | No | ||
| cooldownMinutes | No | ||
| lastTriggeredAt | No | ||
| runCountLast7Days | No | ||
| maxRunsPerContactPerDay | No |