Redirect
Fetch new VoxML from a different URL.
Redirect
The Redirect verb stops the current VoxML execution and fetches new instructions from a different URL.
Example
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Say",
"text": "Transferring you to a new menu."
},
{
"verb": "Redirect",
"url": "https://example.com/new-menu"
}
]
}Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| url | string | yes | — | URL to fetch new VoxML from |
| method | string | no | POST | HTTP method (POST or GET) |
How It Works
When TryVox encounters a Redirect verb:
- Stops executing any remaining instructions in the current VoxML
- Makes an HTTP request to the specified
url - Expects a new VoxML response
- Begins executing the new instructions
Basic Redirect
{
"verb": "Redirect",
"url": "https://example.com/main-menu"
}Method
Use GET instead of POST:
{
"verb": "Redirect",
"url": "https://example.com/menu?lang=en",
"method": "GET"
}Request Details
TryVox includes call information in the redirect request:
POST request body:
{
"call_uuid": "call_abc123",
"account_id": "acc_xyz",
"from": "+919876543210",
"to": "+911234567890",
"call_status": "in-progress",
"direction": "inbound"
}GET request query parameters:
?call_uuid=call_abc123&account_id=acc_xyz&from=%2B919876543210&to=%2B911234567890Use Cases
Dynamic Routing
Redirect based on business logic:
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Gather",
"input": "dtmf",
"action_url": "https://example.com/route-call",
"say": {
"text": "Press 1 for sales, 2 for support."
}
}
]
}In your route handler, redirect to appropriate menus:
// After receiving input "1"
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Redirect",
"url": "https://example.com/sales-menu"
}
]
}Language Selection
{
"verb": "Redirect",
"url": "https://example.com/menu?language=hindi"
}Time-Based Routing
Redirect to different flows based on business hours:
{
"verb": "Redirect",
"url": "https://example.com/check-hours"
}Your server checks the time and returns appropriate VoxML:
// During business hours
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Redirect",
"url": "https://example.com/business-hours-menu"
}
]
}
// After hours
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Redirect",
"url": "https://example.com/voicemail"
}
]
}Modular Call Flows
Break complex call flows into modular, reusable components:
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Say",
"text": "Welcome to TryVox."
},
{
"verb": "Redirect",
"url": "https://example.com/modules/authentication"
}
]
}After authentication succeeds:
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Redirect",
"url": "https://example.com/modules/main-menu"
}
]
}Stopping Execution
Redirect immediately stops the current VoxML. Any instructions after Redirect are ignored:
{
"voxml_version": "1.0",
"instructions": [
{
"verb": "Redirect",
"url": "https://example.com/new-flow"
},
{
"verb": "Say",
"text": "This will never be executed."
}
]
}Best Practices
- Use
Redirectto keep VoxML responses focused and modular - Avoid infinite redirect loops
- Include call context in redirect URLs when needed
- Use GET for simple redirects, POST for complex state
- Implement redirect URL validation and error handling
- Consider using
Redirectfor A/B testing different call flows
Redirect vs. Other Verbs
Redirect vs. Gather: Use Gather when you need user input. The action_url in Gather works similarly to Redirect but only after collecting input.
Redirect vs. Dial action_url: Dial callbacks happen after the call ends. Redirect happens immediately.
Redirect vs. Record action_url: Record callbacks happen after recording completes. Redirect transfers control immediately.