On this page
The <Redirect> action transfers control of the call to another URI.
Attributes
The <Redirect> action does not support any attributes.
Body
The body of an action is the content nested within the action. The following is supported
for <Redirect>.
You can use plain text to transfer control to a single URI. For example:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>https://example.com/handler</Redirect>
</Response>
Alternatively, you can specify one or more <Uri> elements. The following example is
equivalent to the previous plain text example.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>
<Uri>https://example.com/handler</Uri>
</Redirect>
</Response>
Using this syntax, you can specify more than one URI. Each <Uri> contains a relative or
absolute URI, and takes no attributes. A <Redirect> can have up to 5 <Uri> elements. You
can't mix plain text and <Uri> elements in the same <Redirect>.
Failover
When a <Redirect> has more than one URI, Enfonica tries each one once, in order, and stops
at the first that succeeds. A phone number's handler URIs fail over the same way: see
Failure handling.
Enfonica tries the next URI only if the one before it fails:
- For
httpandhttpsURIs, a failure is a non-2xx response, a network error, or no response within 10 seconds. A 2xx response that isn't valid VoiceML isn't a failure: the call ends with an error, and Enfonica doesn't try the next URI. - For
telandsipURIs, a failure is a call attempt that fails (acallStatusofFAILED, see<Call>). Busy and no answer aren't failures.
If every URI fails, the call ends.
Relative URIs are resolved against the URI of the current VoiceML document.
Examples
Example 1: Transfer control to a different handler
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>different-handler.php</Redirect>
</Response>
Example 2: Transfer control with a backup handler
If https://example.com/handler fails, Enfonica requests https://backup.example.net/handler.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Redirect>
<Uri>https://example.com/handler</Uri>
<Uri>https://backup.example.net/handler</Uri>
</Redirect>
</Response>
Tips and Tricks
- In addition to
httpandhttpsURIs, you may also redirect totelandsipURIs. This behaves the same as using the<Call>action and can be useful in certain use-cases. - The relative URIs
exampleand./examplebehave the same way. If you are using a colon towards the start of a relative URI (egmy:uri), you may encounter an invalid scheme error. To disambiguate your relative URI, add the./prefix (eg./my:uri). - Make sure your URL is properly XML serialized (eg
&should be serialized as&).