Skip to main content
GET
/
api
/
get-flows.php
Get Flows
curl --request GET \
  --url https://api.example.com/api/get-flows.php
{
  "success": true,
  "nodes": [
    {
      "id": 123,
      "parent_id": {},
      "node_type": "<string>",
      "content": "<string>",
      "options": [
        {}
      ],
      "metadata": {},
      "order_position": 123,
      "children": [
        {}
      ]
    }
  ]
}

Overview

Retrieves all flow nodes in a hierarchical tree structure for the classic (flow-based) bot mode. This endpoint returns the complete conversation flow with all nodes, options, and branching logic.

Request

No parameters required.
curl https://your-domain.com/api/get-flows.php

Response

success
boolean
required
Indicates if the request was successful
nodes
array
required
Array of flow nodes organized in a tree structure
id
integer
Unique node identifier
parent_id
integer | null
ID of parent node, or null for root nodes
node_type
string
Type of node:
  • "message" - Bot sends a message
  • "question" - Bot asks a question and expects a response
  • "menu" - Multiple choice options
  • "end" - Conversation endpoint
content
string
Message text or question content
options
array
Available options for menu nodes (each option can branch to child nodes)
metadata
object
Additional node configuration (validation rules, actions, etc.)
order_position
integer
Display order for sibling nodes
children
array
Nested array of child nodes (recursive structure)

Success Response Example

{
  "success": true,
  "nodes": [
    {
      "id": 1,
      "parent_id": null,
      "node_type": "message",
      "content": "¡Bienvenido! ¿En qué puedo ayudarte?",
      "options": [],
      "metadata": {},
      "order_position": 1,
      "children": [
        {
          "id": 2,
          "parent_id": 1,
          "node_type": "menu",
          "content": "Por favor elige una opción:",
          "options": [
            {"label": "Agendar cita", "value": "1"},
            {"label": "Consultar información", "value": "2"},
            {"label": "Hablar con un operador", "value": "3"}
          ],
          "metadata": {},
          "order_position": 1,
          "children": [
            {
              "id": 3,
              "parent_id": 2,
              "node_type": "question",
              "content": "¿Cuál es tu nombre completo?",
              "options": [],
              "metadata": {
                "validation": "text",
                "required": true
              },
              "order_position": 1,
              "children": []
            }
          ]
        }
      ]
    }
  ]
}

Error Response Example

{
  "success": false,
  "error": "Error al obtener flujos"
}

Node Types

TypeDescriptionHas OptionsExpects Response
messageBot sends informationNoNo
questionBot asks for user inputNoYes
menuMultiple choice selectionYesYes
endConversation terminationNoNo

Error Handling

Status CodeDescription
200Flow tree retrieved successfully
500Internal server error

Implementation Details

The endpoint:
  1. Calls FlowBuilderService->getFlowTree() to retrieve all nodes
  2. Builds a hierarchical tree structure from flat database records
  3. Includes all node relationships (parent-child)
  4. Preserves ordering using order_position
  5. Returns nested structure suitable for tree rendering
Source: api/get-flows.php:11-12

Usage

This endpoint is used by:
  • Flow builder UI to display and edit conversation flows
  • Classic bot mode (botMode: "classic") to process conversations
  • Flow preview and testing functionality
The flow tree is only used when the bot is in classic mode. In AI mode (botMode: "ai"), the RAG system handles conversations instead.

Build docs developers (and LLMs) love