0
votes

When a user calls my number, I wish to have Twilio <Say> something to them while <Dial>ing another number, the issue is, I can only seem to get it to do one or the other (I.E. Say, then dial (Delaying the dial), or, dial, then say (Not saying until the call is over)). What I want is either of the following (First one would be preferable, although answers to do both would be the best (In case I need the opposite one in the future/someone Googling)):-

  1. Initiate the call to the new number AND start saying "Lorem ipsum...", if the say finishes first then silence until the call is picked up, if the phone number picks up first, let the say finish then transfer them/combine the calls.

  2. Initiate the call to the new number AND start saying "Lorem ipsum...", if the say finishes first then silence until the call is picked up, if the phone number picks up first, cut the say command off and instantly transfer/combine the calls.

Thanks!

1

1 Answers

0
votes

Twilio evangelist here.

There is no way to do this using just Twiml as Twilio processes Twiml sequentially so its going to finish the <Say> before moving on to the <Dial>.

You could combine Twiml with the REST API to do this however. In the same HTTP request where your generating the TwiML with the in it, you would also make a call out to the REST API to have Twilio start an outbound phone call.

Twilio would <Say> what you want to Caller A while dialing Caller B. When Caller B answers, put them into a conference. Once Caller A finishes listening to the <Say> put them into the same conference.

This way, regardless of who gets their first, Caller A or Caller B, either will wait for the other. You can use the StatusCallback parameter to detect if Caller B never answers and in that scenario redirect Caller A out of the conference.

Hope that helps.