WACM.in Logo
Back to API Overview
REST API

AI Flow API

Generate Flowmaker automation flows from natural language prompts using AI.

Overview

The AI Flow API lets you generate Flowmaker automation flows from natural language descriptions. Describe what you want your flow to do, and the AI generates the complete node and edge structure ready for preview or immediate use.

Base URL

https://api.wacm.in

Authentication

Both endpoints require API authentication via Laravel Passport token:

Authorization Header
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
     https://api.wacm.in/ai/flowmaker/generate

Generate Flow

Generate a flow definition from a natural language prompt without persisting it. Returns the complete nodes and edges arrays for preview in the Flow Builder UI.

POST
/ai/flowmaker/generate

Request Body

ParameterTypeRequiredDescription
promptstringRequiredNatural language description of the flow to generate
flow_idintegerOptionalExisting flow ID to regenerate (optional)
Example Request
curl -X POST https://api.wacm.in/ai/flowmaker/generate \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "prompt": "When someone sends a message with the word hello, reply with a welcome message and ask for their name"
     }'

Response

200 OK
{
  "success": true,
  "data": {
    "nodes": [
      {
        "id": "node_1",
        "type": "keyword_trigger",
        "data": {
          "settings": {
            "keywords": [
              { "id": "kw1", "value": "hello", "matchType": "contains" }
            ]
          }
        },
        "position": { "x": 100, "y": 200 }
      },
      {
        "id": "node_2",
        "type": "message",
        "data": {
          "settings": {
            "message": "Welcome! What is your name?"
          }
        },
        "position": { "x": 400, "y": 200 }
      },
      {
        "id": "node_3",
        "type": "question",
        "data": {
          "settings": {
            "question": "Please enter your name:",
            "variableName": "user_name"
          }
        },
        "position": { "x": 700, "y": 200 }
      },
      {
        "id": "node_4",
        "type": "message",
        "data": {
          "settings": {
            "message": "Nice to meet you, {{user_name}}!"
          }
        },
        "position": { "x": 1000, "y": 200 }
      },
      {
        "id": "node_5",
        "type": "end",
        "data": {},
        "position": { "x": 1300, "y": 200 }
      }
    ],
    "edges": [
      { "id": "e1", "source": "node_1", "target": "node_2", "sourceHandle": "kw1" },
      { "id": "e2", "source": "node_2", "target": "node_3" },
      { "id": "e3", "source": "node_3", "target": "node_4" },
      { "id": "e4", "source": "node_4", "target": "node_5" }
    ]
  }
}

Generate & Create Flow

Generate a flow from a prompt AND persist it as a new Flow record in the database. Returns the flow ID and a redirect URL for the Flow Builder editor.

POST
/ai/flowmaker/generate-and-create

Request Body

ParameterTypeRequiredDescription
promptstringRequiredNatural language description of the flow to generate
namestringRequiredName for the new flow (max 255 characters)
Example Request
curl -X POST https://api.wacm.in/ai/flowmaker/generate-and-create \
     -H "Authorization: Bearer YOUR_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
       "prompt": "Create an abandoned cart recovery flow that sends a reminder 1 hour after cart abandonment, then a discount offer after 24 hours",
       "name": "Abandoned Cart Recovery"
     }'

Response

201 Created
{
  "success": true,
  "data": {
    "flow_id": 42,
    "redirect_url": "/flowmaker/42/edit"
  }
}

How It Works

  1. Prompt Processing — Your natural language prompt is sent to the configured AI model (default: DeepSeek V4 Flash)
  2. System Prompt — The AI receives a comprehensive system prompt containing all available Flowmaker node types, their settings schemas, and edge routing rules
  3. JSON Generation — The AI generates a valid { nodes: [...], edges: [...] } structure with proper node positioning
  4. Validation — The generated structure is validated against the Flowmaker schema

Supported Node Types

The AI can generate flows using any of the 46+ available node types:

Trigger Nodes

  • keyword_trigger — Match incoming messages by keyword
  • incoming_message — Trigger on any message
  • catalog_opened — When a contact opens the product catalog
  • abandoned_cart — Cart abandonment events
  • order_created / order_status_updated — Order events
  • reservation_created / reminder_due — Reminders module events

Message Nodes

  • message — Send plain text with variable support
  • message_link — Text with CTA URL button
  • quick_replies — Message with up to 3 quick-reply buttons
  • list_message — Interactive list with sections
  • template — WhatsApp template message
  • image / video / pdf — Media messages
  • catalog_link — Link to contact's catalog
  • cart_summary — Formatted cart summary

Logic & Data Nodes

  • branch — Conditional branching on variables
  • switch — Multi-way switch on a variable
  • counter — Rate limiting per contact
  • datastore — Set custom variables
  • http — Make HTTP requests to external APIs
  • openai — AI processing with vector search
  • product_search — Search product catalog

Management Nodes

  • assign_agent / assign_group / tag — Contact management
  • update_contact — Update contact fields
  • delay / followup — Time-based scheduling
  • verification_request / verification_verify — OTP verification

Commerce Nodes

  • commerce_payment_received / commerce_payment_failed — Payment events
  • commerce_send_payment_link — Generate payment links
  • commerce_subscription_* — Subscription lifecycle events
  • commerce_refund_processed — Refund events

AI Configuration

The AI model and parameters can be configured in the WACM dashboard under AI Features:

ParameterTypeRequiredDescription
openrouter_api_keystringRequiredYour OpenRouter API key
ai_modelstringOptionalModel ID (default: deepseek/deepseek-v4-flash)
temperaturenumberOptionalGeneration temperature (default: 0.3)
max_tokensintegerOptionalMax tokens for generation (default: 4000)

Error Responses

403Subscription plan limit exceeded (max_flows)
422Validation failed — missing prompt or name
500AI generation failed — invalid response from model
Error Response
{
  "success": false,
  "message": "You have reached the maximum number of flows allowed by your plan."
}

Additional AI Features

Beyond flow generation, the AI module provides these web-based features:

  • Smart Replies — Generate 3 contextual reply suggestions for a contact
  • Chat Summarization — Summarize conversation history and add as internal note
  • Template Generation — Generate WhatsApp message templates from prompts
  • WhatsApp Flow Generation — Generate WhatsApp Flow JSON (forms) from prompts
  • Knowledge Base — Train AI on websites, documents, FAQs, and shop products
  • Sentiment Analysis — Analyze message sentiment
  • Intent Classification — Classify contact intent for routing

Related Endpoints