{
"type": "context",
"context": {
"task": {
"type": "steps",
"version": "v1alpha",
"id": "contact-form-with-retry",
"tool": {
"name": "submit_contact_info",
"description": "Submit contact form information with email validation"
},
"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."}
],
"submit": [
{"action": "save"}
]
},
"next": [{"id": "COLLECT_EMAIL"}]
},
{
"id": "COLLECT_EMAIL",
"goal": "Collect and validate the user's email address",
"instructions": [
"Ask the user for their email address.",
"The email must contain '@' and '.' to be valid.",
"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 (must contain @ and .)",
"required": true
}
],
"on": {
"enter": [
{"action": "set", "name": "local.email_attempts", "value": 0}
],
"presubmit": [
{
"action": "set",
"name": "local.email_is_valid",
"value_from": {
"type": "cel",
"expression": "inputs.user_email.contains('@') && inputs.user_email.contains('.')"
}
}
],
"submit": [
{
"action": "inc",
"name": "local.email_attempts",
"if": "!local.email_is_valid"
},
{
"action": "say",
"text": "That doesn't look like a valid email address. Please include an '@' symbol and a domain (e.g., [email protected]).",
"if": "!local.email_is_valid && local.email_attempts < `3`"
},
{
"action": "save",
"if": "local.email_is_valid"
}
]
},
"next": [
{"if": "local.email_is_valid", "id": "COLLECT_TIME"},
{"if": "local.email_attempts >= `3`", "id": "ERROR_TOO_MANY_ATTEMPTS"},
{"id": "COLLECT_EMAIL"}
]
},
{
"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": {
"submit": [{"action": "save"}]
}
},
{
"id": "ERROR_TOO_MANY_ATTEMPTS",
"goal": "Handle maximum retry attempts exceeded",
"instructions": [
"Apologize that we couldn't validate their email after multiple attempts.",
"Offer to continue without email or suggest they contact support.",
"Call the submit_contact_info tool to complete this step."
],
"inputs": [],
"on": {
"enter": [
{
"action": "say",
"text": "I'm sorry, but I wasn't able to validate your email address after several attempts. You can contact our support team for assistance."
}
]
}
}
]
}
},
"tool": {
"type": "function",
"function": {
"name": "contact_form_retry_workflow",
"description": "Multi-step workflow with email validation and retry logic",
"parameters": {
"type": "object",
"properties": {},
"required": []
}
}
}
}