How to play a message for the second caller to hear - twilio

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>

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>
Associate the 2nd TwiML Bin above (the one with the URL) to your Twilio Phone Number by visiting this URL - https://www.twilio.com/console/phone-numbers/incoming, clicking your Twilio phone number the calling party will use to call the agent, and then selecting the TwiML Bin from the drop down box next to Voice & FAX > A Call Comes In and click Save.
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).

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?

Related

Twilio Programmable Voice - How to prevent <Gather> prompt from playing if the call is picked up by an answering machine

We started using Twilio Programmable Voice for appointment reminders, and we are using AMD with the MachineDetection parameter set to "DetectMessageEnd" so we can leave voicemail messages on the recipients answering machine. We are also using a Gather tag in our TwiML to get user input (Ex. "Press 1 to confirm your appointment").
However, we noticed that if the call goes to a voicemail box, the Gather prompts still get triggered. We'd like to be able to prevent this from occurring so the recipient doesn't hear the prompts in their voicemail message.
Is this even possible? Here's an example of our current TwiML:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say voice="Polly.Joanna">
<prosody rate="95%">Hello, you have an appointment tomorrow at 10:30AM</prosody>
</Say>
<Pause length="1" />
<Gather action="https://example.com" timeout="5">
<Say voice="Polly.Joanna">
<prosody rate="95%">Press 1 to confirm your appointment, Press 2 to repeat the message</prosody>
</Say>
</Gather>
</Response>
The AMD AnsweredBy parameter would be used to determine which TwiML you want to return.
If it is a Machine, you would not return the TwiML with the Gather (since it is a machine and you will wait for the DetectMessageEnd event to drop the announcement). If it is a human (AnsweredBy=human), you can use the Gather to get their response around their availability for their appointment.

Twilio call diverting call to personal cellphone answering machine instead of twimlet

I am trying to use twimlbin code to forward calls to the voicemail box for my current twilio number. The goal is to have a call come in, then it is split to call multiple numbers at the same time. If none of the numbers pick up, then forwards it to voicemail where it is emailed to an email address using a twimlet link. Currently this is my setup:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial action="https://twimlets.com/forward?FailUrl=https%3A%2F%2Ftwimlets.com%2Fvoicemail%3FEmail%myemail%2540gmail.com%26Message%3DSorry%2520we%2520are%2520unavailable%252C%2520please%2520leave%2520a%2520voicemail%2520here%2520and%2520let%2520us%2520know%2520what%2520you%2520need%2520and%2520we%2520will%2520get%2520back%2520to%2520you%2520shortly%252C%2520thank%2520you.%26Transcribe%3Dtrue&Dial=true" record="record-from-answer" callerId="+13151234567">
<Number url="https://handler.twilio.com/twiml/EH8253d4550bfdaf385b2b2ac15e0a4392">3155554444</Number>
<Number url="https://handler.twilio.com/twiml/EH8253d4550bfdaf385b2b2ac15e0a4392">7165554444</Number>
</Dial>
</Response>
Currently it routes the numbers properly and the phones receive the call, but when no one picks up, it just goes to the voicemail on the personal phones of the numbers where the call is being forwarded to. Is there a way I can get the twimlet to work with this style of routing in Twilio?
Take a look at this blog.
Outsmart Voice Mail with Human Detection Using Keypress Prompts
https://www.twilio.com/blog/voice-mail-human-detection-studio-functions

Transfer Enqueued Call to Conference Using Twilio

Imagine there is an incoming call currently enqueued via Twilio.
I want to transfer this call a new conference line.
Currently, my app "updates" the call with a redirect URL that responds with the following TwiML.
Unfortunately, it just hangs there, listening to music, and I never enter the conference.
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Conference endConferenceOnExit="true" startConferenceOnEnter="true" waitUrl="http://example.com/music">
{{CallSid}}
</Conference>
</Dial>
</Response>
Note that the {{CallSid}} is dynamically updated with the call identifier (aka Call SID). Also, I have not tried this with a second phone (because maybe it won't connect to the conference line until there is more than one person?)
Twilio developer evangelist here.
First up, your question in parentheses was indeed correct, a conference will not start with one person in, so will just play the hold music until someone else joins.
Secondly, once you added a second call you were still hearing hold music. However, for the <Conference> identifier, you said you were using the CallSid. That identifier is unique per call leg, so each of your calls would have different CallSids and thus would join different conference calls. To first ensure that this is the issue, I would test your code with a static identifier for the conference (<Conference>Test</Conference> for example). If you can get callers talking together like that, then you will need to find a way to identify a conference independent of the individual CallSids and use that as the identifier so that you can join the calls together.
Let me know if that helps at all.

Twilio Conference Call: how to add options menu

Hello to Twilio Developer Evangelists here :)
Is there an easy way to add options menu (not sure if I call it right) to conference call, so all participants have ability to perform some actions by pressing numbers.
At this moment the only way I can see how this can be implemented - add outgoing call with to conference call. But I'm still playing with it, so not sure if this would work...
Thank you!
Twilio evangelist here :)
One way I've done this before is by using the hangupOnStar attribute of the <Dial> verb.
As long as you've not provided an action parameter on the <Dial> verb, if the caller hits * while in the conference room, Twilio will disconnect them from the conference room and execute the next verb in your Twilio document, which could be a <Gather> containing a menu:
<Response>
<Dial hangupOnStar="true">
<Conference>YourConference</Conference>
</Dial>
<Gather action="http://example.com/processConferenceMenu?confName=YourConference" numDigits="1">
<Say>To mute all participants, press one</Say>
<Say>To leave the conference, press two</Say>
</Gather>
</Response>
In the processConferenceMenu endpoint you would process whatever value the caller has input durung the gather and then if needed put then right back into the same conference room.
I've created systems which let users use *6 (the standard self-mute command) without any menu prompts and the lag between when the user leaves and then re-enters the conference muted was barely noticeable.
Hope that helps.

Twilio checking if human representative is on the line

I'm thinking of a scenario where web app with twilio api first makes an outbound call to a customer service number, send digits to get transferred to the agent, and instead of waiting on hold, I would like the web app to detect when human picks up the call and calls the user's phone number. Is there a way to do this?
Twilio evangelist here.
There isn't an automated way to detect that a human has answered the call. You could put a prompt in the phone call that the agent can input in order to indicate that they have answered the call. Something like:
<Response>
<Gather action="process/" numDigits="1">
<Say>Please press one to connect to the incoming call</Say>
</Gather>
</Response>
Hope that helps.

Resources