Reputation: 21
I tried as follows, but it is not working. How is it possible?
How to add <Say>
inside the <Dial
>?
<Response>
<Say>Hi, This call is from ...</Say>
<Dial>
<Say>Hi, This call is from ...</Say>
<Number
statusCallbackEvent="initiated ringing answered completed"
statusCallback="my_url"
statusCallbackMethod="POST">
+12345678901
</Number>
</Dial>
</Response>
Upvotes: 0
Views: 256
Reputation: 10771
You need to use the Dial verb with Number noun (url parameter) to play a message to the dialed party before the two call legs are connected.
Whisper Page /
I believe you are looking for the Twilio: Voice - https://www.twilio.com/docs/api/twiml/number, the verb's noun.
The Number noun has a URL parameter that points to TwiML to privately play or say information to the called party, or provide a chance to decline the phone call using and . The current caller will continue to hear ringing while the TwiML document executes on the other end.
To set-up a quick example, you can use a couple of TwiML Bins. One will be used as the TwiML source for the Number URL to speak, and the other will forward a call from a Twilio number to another number.
To create a TwiML Bin, go to this URL: https://www.twilio.com/console/runtime/twiml-bins
Click the big red "+" to create a TwiML Bin, give it a Friendly Name, and paste in the code below.
This TwiML will be reference in the second TwiML Bin Below:
<Response>
<Say voice="alice">
Incoming work call. In a hole in the ground there lived a hobbit. Not a nasty, dirty, wet hole, filled with the ends of worms and an oozy smell, nor yet a dry, bare, sandy hole with nothing in it to sit down on or to eat: it was a hobbit-hole, and that means comfort.
</Say>
</Response>
Verify the message at the bottom of the edit box says, "Valid Voice TwiML" and then click Create.
At the top of the screen, save the URL to this TwiML Bin by clicking the Copy Icon and copying it to notepad.
Click Cancel.
Click the big red "+" to create another TwiML Bin, giving it a Friendly Name, and paste in the code below.
Edit the URL (bold) to be the URL you copied to notepad from above, and edit the number you want to call in E.164 format (this is the Agent's Phone Number).
Verify the message at the bottom of the edit box says, "Valid Voice TwiML" and then click Create.
<Response>
<Dial>
<Number url="https://handler.twilio.com/twiml/<replace with your URL>">
+1XXXXXXXXXX
</Number>
</Dial>
</Response>
What happens now is when your Twilio number is called and the Agent answers, they will hear the text above in the first TwiML Bin (while the called party will hear ring back, until the text being read is completed, then both parties will be connected).
Upvotes: 1
Reputation: 3816
Having another <Say>
tag within <Dial>
results in invalid TwiML, which explains why this isn't working.
FYI: You can use the TwiML editor in the console to find out if your TwiML is valid.
Can you explain in more detail what you want to achieve with the two <Say>
elements?
Upvotes: 0