You're dealing with three numbers in this picture. One is your Twilio number from where the call is made '+14159341234'
, then, you have the two numbers you'd like to call and connect.
Let's be clear, you won't hear your Twilio number ring, it's at Twilio and it's kind of virtual.
The code you have so far, when you run it, uses your Twilio number :from => '+14159341234'
to make a call :to => '+18004567890'
.
So, what happens when people at :to => '+18004567890'
answer? Twilio's system (the platform) makes a request to :url => 'http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient'
from where is served some XML, some TWIML. You can actually see what is served if you go with your browser to http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient
To do what you want to do, to dial another number instead of playing music, you need to change that url to some place from where you serve this kind of TWIML:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Say>Hello. Please wait.</Say>
<Dial>+12223334444</Dial>
</Response>
If you don't have your public server from where you can serve XML, you can use a native TwiML bin
, that you create in your Twilio account console here: https://www.twilio.com/console/runtime/twiml-bins .
Once you create your TwiML bin, under properties for the bin, you'll have a URL to put in place of http://twimlets.com/holdmusic?Bucket=com.twilio.music.ambient
, something like https://handler.twilio.com/twiml/EH7e58b64f8488ff8c022bf83c910fb49b
.
P.S. You might want to also google twilio click to call
and/or twilio conference
as other way to connect two phones.