Decision modes
Choose between two decision types:- AI-Powered: AI interprets user intent from conversation
- Function (Custom Code): Run your own routing logic - business rules, data checks, API calls, etc.
Configuration
Common parameters
id: Unique node identifierconditions: List of possible paths with labels and descriptions
AI-powered mode
decision_type: Set to"ai"(default)provider_model_name: AI model to use for decision makingllm_temperature: Model creativity, 0.0-1.0 (default: 0.0)llm_max_tokens: Maximum tokens for response (default: 10000)
Function mode
decision_type: Set to"function"function_id: ID of the deployed Kapso Function to execute
How it works
AI-powered mode
- Analyzes conversation: Reviews recent WhatsApp message history
- Evaluates conditions: Uses AI to match user intent against condition descriptions
- Returns label: Chooses the best matching condition label for routing
- Routes workflow: Uses the label to follow the matching outgoing edge
- Fallback: Uses first condition if AI evaluation fails
Function mode
- Executes function: Calls your deployed Kapso Function with current workflow state
- Your logic runs: Function executes your custom logic - check data, call APIs, apply rules, etc.
- Returns decision: Function returns JSON with
next_edgeset to a condition label - Routes workflow: Uses the returned label to follow the matching outgoing edge
- Updates variables: Optionally updates workflow variables if function returns
vars
Function decision contract
When using function mode, your function receives the standard execution payload plus anavailable_edges array containing all possible edge labels from your conditions.
Request payload
Response format
Your function must return JSON withnext_edge set to one of the labels from available_edges:
Example function
Accessing WhatsApp data
When your flow is triggered by a WhatsApp message, usewhatsapp_context to access conversation data:
Routing by button ID
Common pattern: route based on which button the user clicked.id values to match your condition labels for direct routing.

