{
"type": "context",
"context": {
"task": {
"type": "steps",
"version": "v1alpha",
"id": "contact-form-with-branching",
"tool": {
"name": "submit_contact_info",
"description": "Submit contact form information with conditional routing"
},
"steps": [
{
"id": "COLLECT_NAME",
"goal": "Collect the user's name",
"instructions": [
"Ask the user for their name.",
"Once you have their name, call the submit_contact_info tool with the user_name parameter."
],
"inputs": [
{
"name": "user_name",
"type": "string",
"description": "The user's name",
"required": true
}
],
"on": {
"enter": [
{"action": "say", "text": "Welcome! Let's collect your contact information. Step 1 of 3."},
{"action": "set", "name": "local.steps_completed", "value": 0}
],
"submit": [
{"action": "save"},
{"action": "inc", "name": "local.steps_completed"}
]
},
"next": [{"id": "COLLECT_EMAIL"}]
},
{
"id": "COLLECT_EMAIL",
"goal": "Collect the user's email address",
"instructions": [
"Ask the user for their email address.",
"Once you have their email, call the submit_contact_info tool with the user_email parameter."
],
"inputs": [
{
"name": "user_email",
"type": "string",
"description": "The user's email address",
"required": true
}
],
"on": {
"enter": [{"action": "say", "text": "Great! Step 2 of 3."}],
"submit": [
{"action": "save"},
{"action": "inc", "name": "local.steps_completed"}
]
},
"next": [{"id": "COLLECT_TIME"}]
},
{
"id": "COLLECT_TIME",
"goal": "Collect the user's preferred contact time",
"instructions": [
"Ask the user for their preferred contact time.",
"Once you have their preference, call the submit_contact_info tool with the contact_time parameter."
],
"inputs": [
{
"name": "contact_time",
"type": "string",
"description": "The user's preferred contact time",
"required": true,
"enum": ["morning", "afternoon", "evening", "night"]
}
],
"on": {
"enter": [{"action": "say", "text": "Almost done! Step 3 of 3."}],
"submit": [
{"action": "save"},
{"action": "inc", "name": "local.steps_completed"}
]
},
"next": [
{
"if": "contact_time == 'morning' || contact_time == 'afternoon'",
"id": "SCHEDULE_CALL"
},
{
"if": "contact_time == 'evening' || contact_time == 'night'",
"id": "SEND_EMAIL"
},
{
"id": "SEND_EMAIL"
}
]
},
{
"id": "SCHEDULE_CALL",
"goal": "Confirm phone follow-up for daytime contact preference",
"instructions": [
"Inform the user that we'll call them during business hours (morning or afternoon).",
"Thank them for providing their information.",
"Call the submit_contact_info tool to complete this step."
],
"inputs": [],
"next": []
},
{
"id": "SEND_EMAIL",
"goal": "Confirm email follow-up for evening/night contact preference",
"instructions": [
"Inform the user that we'll send them an email since they prefer evening or night contact.",
"Thank them for providing their information.",
"Call the submit_contact_info tool to complete this step."
],
"inputs": [],
"next": []
}
]
}
},
"tool": {
"type": "function",
"function": {
"name": "contact_form_branching_workflow",
"description": "Multi-step workflow with conditional branching",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}
}
}