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.
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.
This is called, Call Forwarding. The article below provides all the different ways to accomplish this task
Setting Up Call Forwarding
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.
It comes with the Trigger widget, which will initiate your flow when the trigger (in this case, an Incoming Call) is fired.
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.
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
Related
I am working on a project (in python socketio) in which authorized agents will be in agents room waiting for customer call, when a customer come he/she will make a call request(video call) than a notification will be sent to all the available agents to accept the call. I am new to programming, tried but make logic for this. Need your help
When I send a request from a Decentralized Application I don't want to appear metamask popup every time.
Please help me how can I avoid metamask popup every time.
You'll get confirmation every time you spend ethereum / gas.
The only way you won't get that confirmation is when you call a contract method marked as view using call() instead of send().
In this case the wallet will compute locally the result since there is no need to modify anything in the blockchain.
I have been asked to try and get something working in our slack environment for our campus locations to use. The goal is to have a user input the location which would initiate the API call to the other system and return some basic high level system health stats.
I am familiar with how to setup webhooks to slack, just not sure if it's possible to do this or not with slack.
The slack API (https://api.slack.com/) is fairly complex to get set up, but it will do what you want once you get there. It has a web API that you can register to receive hooks from when things appear in messages or chats, for example, and thus you can trigger things to run when people say certain things, for example.
If I understand correctly, you want a user to input a location on slack, and based on their input to make an API call to a different service.
You have several options to get the input from the user:
You can create a bot that the user can chat with
You can create a shortcut or workflow that users can use to fill some kind of form
You can allow for interactions on your application's home page
All these options will get slack to send a payload to some endpoint you define. You will have to set up some basic back end to handle this and call your external APIs from.
I'm currently working on a similar project and recommend using some serverless, fast setup. I have opted for Lambda and API gateway for this. The experience is:
The user goes to the app home page and presses a button
The user gets a form to fill
On form submission, slack sends a payload to an endpoint set via API gateway
API gateway summons a lambda function
The function parses and validates the payload, and ultimately makes a request to my external API
I just implemented call forwarding based on the following Twilio tutorial:
https://www.twilio.com/docs/voice/tutorials/call-tracking-python-django
The call forwarding works, however there are about 3 seconds of "static sounds" before the phone that is dialing the number starts hearing the phone ringer.
Why is there such a delay in forwarding the call, how can this be resolved for a production level application? Calls are made over US phone networks, so did not expect delay issues.
This is the function implementing the forwarding:
# views.py
# View used by Twilio API to connect callers to the right forwarding
# number for that lead source
#csrf_exempt
def forward_call(request):
"""Connects an incoming call to the correct forwarding number"""
r = VoiceResponse()
r.dial('+12324567891')
return HttpResponse(r)
Twilio developer evangelist here.
It appears that you are both reading data from and then saving data to a database before you respond with the TwiML to tell Twilio to forward the call. To get the quickest forwarding you should return TwiML as quick as you can.
Perhaps you can test the same forwarding without hitting the database and see if there is a difference. If there is, then I can see you need to read the database to get the number to forward to, but perhaps you could set up the saving of a new Lead to be done in a background job rather than block the response with it.
Another thing to try is to set answerOnBridge="true" on your .
Let me know if that helps at all.
You can use celery and register forward call task with delay
Background
I'm attempting to implement call screening for my twilio app - i.e. a person presses a key to accept a call. I have seen a couple of examples of this in action (e.g. How to use twilio to guarantee a live answer or voicemail?) however the given answers for the case of forwarding a call to multiple numbers uses a round robin method.
The question
Is there a way to have everyone called at the same time and the first person that gets through the challenge speaks and all other calls disconnect?
Why?
I would like to do this because an incoming caller will need to potentially wait for quite some time if the call is only answered by the last person in the round robin.
Twilio Evangelist here,
When you receive your initial call (let's call it the customer) ask the them for some information using <Gather>, or play them some holding music, whatever you think works best:
<Response>
<Play loop="0">/my_music.mp3</Play>
</Response>
Then, use the REST API to initiate 3 outbound calls to what we'll call the agents. You need to be mindful of Twilio's rate limit. Each of these call would have TwiML along these lines:
<Response>
<Gather numDigits="1" action="/accepted">
<Say>Incoming call from +X YYY ZZZZ ZZZZ</Say>
</Gather
<Response>
Now, as soon as one of the agents presses a key (you may of course want to add options to reject etc) they will be redirected to the action URL. On your sever, you need to respond to the first agent with:
<Response>
<Dial>
<Conference>some-unique-room-name</Conference>
</Dial>
</Response>
You then need to make a request to the REST API and change the customers inbound call (who is still listening to music for example) and use the above TwiML to put the customer into the same conference room as the agent.
When any of the subsequent agents decide to accept the call, they are redirect to the /accepted URL, but because your application already knows that customer has been connected to another agent, you can just play them a message saying the call is already being responded to.
There are ways you can expand on this. For example using the <Queue> TwiML verb to handle multiple incoming calls more easily.
You may also want to take a look using a 'whisper' with the url attribute of the <Number> verb. This allows you to add an extra TwiML document that would only be executed on the agents side. Although you use multiple <Number> verbs only the first agent to answer will hear the whisper.
<Response>
<Dial>
<Number url="/whisper">+AGENTNUMBER</Number>
</Dial>
</Response>
The /whisper TwiML can contain a <Gather> asking the agent to accept the call. Once the call reaches the end of a TwimL document, it connects them to the calling Customer. Otherwise you can use <Hangup> to reject.
There is Python code for most of this on the links provided. I'm afraid I'm not much of a Python coder, but I'm guessing the TwiML helps?
Good luck!
Here's the TwiML:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Dial>
<Number>415-123-4567</Number>
<Number>415-321-7654</Number>
<Number>415-456-7890</Number>
</Dial>
</Response>
This will dial all the numbers at once and drop the call from the others when one answers.