Execute custom JavaScript functions in your flow
id
function_id
save_response_to
{ execution_context: { vars: {}, // Flow variables system: {}, // System info (flow_id, started_at, etc) context: {} // Channel info (phone_number, etc) }, flow_events: [], // Recent flow events (last 10) flow_info: { id: "flow_123", name: "Customer Support", step_id: "current_step_456" }, whatsapp_context: { // Only if WhatsApp flow conversation: {}, messages: [] } }
return new Response(JSON.stringify({ vars: { user_score: 85, validated: true }, next_edge: "success" // Optional: suggest next flow path }))
from kapso.builder.flows.nodes import FunctionNode node = FunctionNode( id="validate_email", function_id="func_email_validator_123" )
node = FunctionNode( id="calculate_score", function_id="func_score_calculator_456", save_response_to="user_score" )
# Calculate user score score_node = FunctionNode( id="calc_score", function_id="func_calculate_user_score", save_response_to="score_data" ) # Process payment based on score payment_node = FunctionNode( id="process_payment", function_id="func_payment_processor", save_response_to="payment_result" ) # Connect them flow.add_edge("calc_score", "process_payment", "next")
next
Was this page helpful?