Basic usage

from kapso.builder.flows import Flow
from kapso.builder.flows.nodes import StartNode, SendTextNode

flow = Flow(
    name="customer_onboarding",
    description="Onboard new customers via WhatsApp"
)

# Add nodes  
flow.add_node(StartNode(id="start_1234"))
flow.add_node(SendTextNode(
    id="send_text_5678",
    whatsapp_config_id="config_123", 
    message="Welcome to our service!"
))

# Connect nodes
flow.add_edge("start_1234", "send_text_5678")

flow.validate()

Constructor

Flow(
    name: str,
    description: str = None
)
  • name: Flow identifier (alphanumeric + underscores)
  • description: Optional description

Methods

add_node()

flow.add_node(node)
Add a node to the flow. Each node needs a unique ID.

add_edge()

flow.add_edge(source, target, label="next")
Connect two nodes by their IDs.
flow.add_edge("start_1234", "greeting_5678")
flow.add_edge("decide_9012", "help_3456", label="needs_help")

validate()

flow.validate()
Check flow structure. Required before deployment.
  • Must have exactly one StartNode
  • All nodes must be reachable from StartNode
  • No duplicate node IDs

Node IDs

Node IDs use format {type}_{timestamp}:
StartNode(id="start_1234567890")
SendTextNode(id="send_text_1234567891", ...)
DecideNode(id="decide_1234567892", ...)