markj
markj

Reputation: 25

Using Twilio with Python to make a person-to-person call

I have setup a trial Programmable Voice account with Twilio. I am using a Zoiper softphone endpoint. I am attempting to have my client's server initiate a call through Twilio to a live person. I need to actually speak with the person called.

However, in using the tutorial code, Twilio's "url" parameter intercepts the call with it's own voice message:

from twilio.rest import Client

account_sid = 'Axxxx'
auth_token = 'xxxxx'
client = Client(account_sid, auth_token)

call = client.calls.create(
    url='http://demo.twilio.com/docs/classic.mp3',
    to='+15553334929',
    from_='+18334447682'
    )

print(call.sid)

The call recipient hears the the message, but we cannot speak together.

Twilio's own tutorial materials are on how to use either TwilML or the "url" parameter to have the computer automatically work with the call. However, I do not need that. I need to have two live people speak to each other once the server initiates the call through Twilio. Right now, the "url" / TwilML is just standing between the live people.

Upvotes: 0

Views: 1812

Answers (3)

totalhack
totalhack

Reputation: 2598

This blog shows an example that makes an outgoing call and then joins the caller into the call. See the "Start a two-user call from your App" section.

You might also want to take a look at this answer which shows another way to do this with the JS API (the principals should be easily transferable to the python API). Basically it makes two calls and joins them in a Conference.

Disclaimer: I'm not a lawyer and this is not legal advice, but I'm assuming you are familiar with TCPA and have reviewed regulations/requirements related to that. It's possible that your code initiating the outgoing call in an automated fashion (instead of an agent clicking a button manually to initiate a call) changes your level of regulatory exposure.

Upvotes: 1

lizziepika
lizziepika

Reputation: 3300

Twilio developer evangelist here.

Welcome to StackOverflow!

You can do this with Twilio Studio. There in your dashboard, click the + button to make a new flow and call it whatever you wish.

make a new flow + sign

It comes with the Trigger widget, which will initiate your flow when the trigger (in this case, an Incoming Call) is fired.

trigger widget

You only need one widget: the Connect Call To widget. Drag it onto the canvas and connect the dot from that initial Incoming Call trigger to the dot in the upper left corner of that new Connect Call widget. Select Single Number in the right sidebar dropdown and enter whatever number you'd like to forward calls to.

connect widget

Lastly, you'll need a Twilio phone number. Purchase one in the Twilio Phone numbers section of your console.

Scroll down to the Voice & Fax section and select Webhooks, TwiML Bins, Functions, Studio, or Proxy from the initial dropdown. Next to “A Call Comes In” select Studio Flow and choose the flow you just made to connect/relate it to the number. Lastly click Save and tada! If someone calls your Twilio number you just purchased, they will route you to the number you specified in the Twilio Studio flow.

Let me know if this helps at all! :D

Upvotes: 0

Alan
Alan

Reputation: 10771

This is called, Call Forwarding. The article below provides all the different ways to accomplish this task

Setting Up Call Forwarding

Upvotes: 0

Related Questions