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.inAuthentication
Both endpoints require API authentication via Laravel Passport token:
curl -H "Authorization: Bearer YOUR_API_TOKEN" \
https://api.wacm.in/ai/flowmaker/generateGenerate 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.
/ai/flowmaker/generateRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Required | Natural language description of the flow to generate |
| flow_id | integer | Optional | Existing flow ID to regenerate (optional) |
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
{
"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.
/ai/flowmaker/generate-and-createRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Required | Natural language description of the flow to generate |
| name | string | Required | Name for the new flow (max 255 characters) |
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
{
"success": true,
"data": {
"flow_id": 42,
"redirect_url": "/flowmaker/42/edit"
}
}How It Works
- Prompt Processing — Your natural language prompt is sent to the configured AI model (default: DeepSeek V4 Flash)
- System Prompt — The AI receives a comprehensive system prompt containing all available Flowmaker node types, their settings schemas, and edge routing rules
- JSON Generation — The AI generates a valid
{ nodes: [...], edges: [...] }structure with proper node positioning - 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 keywordincoming_message— Trigger on any messagecatalog_opened— When a contact opens the product catalogabandoned_cart— Cart abandonment eventsorder_created/order_status_updated— Order eventsreservation_created/reminder_due— Reminders module events
Message Nodes
message— Send plain text with variable supportmessage_link— Text with CTA URL buttonquick_replies— Message with up to 3 quick-reply buttonslist_message— Interactive list with sectionstemplate— WhatsApp template messageimage/video/pdf— Media messagescatalog_link— Link to contact's catalogcart_summary— Formatted cart summary
Logic & Data Nodes
branch— Conditional branching on variablesswitch— Multi-way switch on a variablecounter— Rate limiting per contactdatastore— Set custom variableshttp— Make HTTP requests to external APIsopenai— AI processing with vector searchproduct_search— Search product catalog
Management Nodes
assign_agent/assign_group/tag— Contact managementupdate_contact— Update contact fieldsdelay/followup— Time-based schedulingverification_request/verification_verify— OTP verification
Commerce Nodes
commerce_payment_received/commerce_payment_failed— Payment eventscommerce_send_payment_link— Generate payment linkscommerce_subscription_*— Subscription lifecycle eventscommerce_refund_processed— Refund events
AI Configuration
The AI model and parameters can be configured in the WACM dashboard under AI Features:
| Parameter | Type | Required | Description |
|---|---|---|---|
| openrouter_api_key | string | Required | Your OpenRouter API key |
| ai_model | string | Optional | Model ID (default: deepseek/deepseek-v4-flash) |
| temperature | number | Optional | Generation temperature (default: 0.3) |
| max_tokens | integer | Optional | Max tokens for generation (default: 4000) |
Error Responses
{
"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
- AI Flow Builder — Visual flow editor documentation
- Reminders & Reservations — Reminder events trigger flow nodes
- Razorpay Integration — Payment events trigger flow nodes