0

From my app, I need to dial in 2 users with say = "hello < name1 > this is FantasticApp. Press 1 to be connected to your buddy < name2 >".

Only after both users answered and pressed 1, they are connected in a call. If user1 answered and accepted first and while waiting for user2, I want to play music to user1.

How can I write this Twiml?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Dora
  • 11
  • 2

1 Answers1

0

Twilio developer evangelist here.

You can do this using the <Conference> part of TwiML. Here's an example using Ruby/Sinatra.

First you build your initial response when the user dials the number:

post '/call' do
  "<Response>
     <Gather action='/next' numDigits='1'>
       <Say>Hello! This is FantasticApp, press 1 to be connected with your buddy</Say>
     </Gather>
   </Response>"
end

Then the /next endpoint will put the caller into a conference to wait for their buddy.

post '/next' do
  "<Response>
     <Dial>
       <Conference waitUrl='/your-awesome-hold-music.mp3'>FantasticApp conference</Conference>
     </Dial>
   </Response>"
end

I hope that helps, let me know if you have any other questions.

philnash
  • 70,667
  • 10
  • 60
  • 88