The <Leave>
verb is used in conjunction with <Enqueue> to manage control of a call that is in a queue.
When Twilio executes the <Leave>
verb on a call, the call is removed from the queue and Twilio executes the next TwiML verb after the original <Enqueue>.
The <Leave>
verb doesn't support any attributes.
Consider the following scenario: There are several calls waiting in a call queue for a customer support agent. The customer support line closes at 9PM and the callers must be notified that they have been removed from the queue and will have to try again tomorrow.
The original call TwiML might look like this:
1const VoiceResponse = require('twilio').twiml.VoiceResponse;234const response = new VoiceResponse();5response.enqueue({6waitUrl: 'wait.xml'7}, 'support');8response.say('Unfortunately, the support line has closed. Please call again tomorrow.');910console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Enqueue waitUrl="wait.xml">support</Enqueue>4<Say>Unfortunately, the support line has closed. Please call again tomorrow.</Say>5</Response>
Configure wait.xml to play hold music before 9pm:
1const VoiceResponse = require('twilio').twiml.VoiceResponse;234const response = new VoiceResponse();5response.play('http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3');67console.log(response.toString());
1<?xml version="1.0" encoding="UTF-8"?>2<Response>3<Play>http://com.twilio.sounds.music.s3.amazonaws.com/MARKOVICHAMP-Borghestral.mp3</Play>4</Response>
After 9PM, wait.xml dequeues the call and returns call control to the <Say>
block in the original call TwiML: