art0071
art0071

Reputation: 11

Twilio - How to play a message on the forwarding number before forwarding the call?

IMPORTANT I am new to Twilio so it needs to be IN STUDIO FLOW

I want to create the following:

A line number, let's say 741-SUPPORT (just an example), where people can call. When somebody calls, I want them to listen some text (I used Say/Play Function) and then, forward their call to my number.

When I receive the call, I want to listen to a message that announces me that this call comes from that line, and allows me to press 0 to accept de call, or any other number to reject it. In case that I accept, both calls get connected. Otherwise, the caller should be able to leave a message.

I have multiple businesses and would like to be able to answer them the phone call accordingly.

I know how to say a message for the customer calling, but I am not sure how to play a message on my phone before the call is connected.

Upvotes: 0

Views: 554

Answers (2)

philnash
philnash

Reputation: 73029

You are asking to perform a call whisper when you connect the call to your device. Sadly, Studio doesn't directly support whispers.

To implement this, you will need to use some TwiML and another Studio Flow.

First, create your flow that will alert you of the call and ask you to enter 0 to continue. You can do this using the Gather widget to both say the message and wait for your input. Attach a Split based on widget to the user pressed keys transition from the Gather widget. Set the variable to test as the gather widget's Digits parameter and create a transition for when the digit is equal to "0". For the equal to "0" transition, connect a Say widget with the message "Connecting you now". For the no condition matches transition, you want to hangup the call. There isn't a hangup widget, but we can use TwiML for this instead so hold for the next instructions.

In the Twilio console, open up the TwiML Bins section and create a new TwiML Bin. This one we can call "Hangup" and it will end that call whisper. Enter the following TwiML:

<Response>
  <Hangup/>
</Response>

Save that, grab the URL and go back to your Studio Flow for the call whisper. Add a Redirect widget and redirect to your hangup TwiML Bin.

We're almost there, we just need to add another TwiML Bin that will kick off the call whisper from your original Studio Flow for the incoming call.

In your call whisper flow, click the trigger and copy the webhook URL. Now, create a new TwiML Bin which will Dial your phone number and perform the whisper. The TwiML should be:

<Response>
  <Dial>
    <Number url="YOUR_CALL_WHISPER_STUDIO_FLOW_WEBHOOK_URL">YOUR_PHONE_NUMBER</Number>
  </Dial>
</Response>

Save that TwiML Bin and open your original Studio Flow. After the Say/Play widget you've already used, add a Redirect widget and enter the URL of the TwiML Bin you just created.

The overall flow is, the incoming call comes to your Studio Flow, which reads the caller a message and then redirects to your TwiML which dials your phone number and, in turn, connects you to the call whisper Studio Flow. Once you accept the call, by pressing 0, the flow ends and the calls are connected. If you press anything else, you will hang up and the call will drop from the other end.

Upvotes: 2

Tazim Karim Madre
Tazim Karim Madre

Reputation: 49

CheckOut this Link for full tutorial

If you want to know in short than listen, twilio allows some external api request to any server. So first we will make a small server which has a package from twilio called TwiML which allows playing music from any url or music file. and we will expose this server. to know how to do this you can use the above link.

Once we make that server we will paste the url of exposed server here as shown in image.

enter image description here

Upvotes: 0

Related Questions