Twilio developer evangelist here.
When you create a call using the Twilio REST API it will create a call between Twilio and the To
number. The From
number in this case must either be a Twilio number or a number you have verified with Twilio.
Now, as an example, you can use that call to say or play messages to the call recipient. We do this by providing TwiML, or by providing a URL that will respond to a webhook and return TwiML. TwiML is a subset of XML that contains instructions for what Twilio should do with a call. For example:
@client = Twilio::REST::Client.new(account_sid, auth_token)
call = @client.calls.create(
to: options[:to],
from: TWILIO_NUMBER,
twiml: "<Response><Say>Ahoy there!</Say></Response>"
)
In this case the entire call is dealt with in only one leg, between Twilio and the call recipient.
In order to connect the call recipient to another number you need to create a second call leg. You can do this with the <Dial>
TwiML verb like this:
@client = Twilio::REST::Client.new(account_sid, auth_token)
call = @client.calls.create(
to: options[:to],
from: TWILIO_NUMBER,
twiml: "<Response><Dial>#{options[:from]}</Dial></Response>"
)
Let me know if that helps at all.