What is the best way to connect two numbers via Twilio, and how to get the pricing for the call before hand? - twilio

I'm trying to establish the recommended way to connect two numbers via Twilio and get the pricing of that call before hand.
The scenario is that a user on my system will call one of his/her contacts. The user's own number is predefined before hand, and they are using a specific sub account.
The way I'm doing it now, is to first call the user's phone, then use a Dial verb to call the target. That way, the user answers first, is announced that we're calling "Contact X" and the contact's phone rings. This avoids a lag which would occur on the contact's phone if I called them first. Is there a better way to do it?
As well, I'd like to establish the cost of the call before hand (the cost per minute). I can use the pricing client to get a cost for specific countries, but how do I determine the SOURCE country? The user might be in the UK or the Middle East, calling a contact in the US. The pricing API lets me see the cost to the UK or US but how does the API call knows which country we're calling from?

Twilio developer evangelist here.
The way you are setting up the call seems fine to me.
As for the cost of the call, you are actually making two outbound calls in this situation, so the costs are that of an outbound call to each country that you are calling to. In the case of a user in the UK that initiates a call in the way you describe to the US, your cost will be an outbound call to the UK and an outbound call to the US.
There is one different way you could set up the call. If you make your system aware that the next call to a number will be forwarded onto the user you want to call, then your user can make an inbound call to the number and you can return TwiML to forward onto the call recipient. That way you would pay for an inbound call leg from the country the user was calling from (the UK, in the example) and an outbound call in the country the user called to (the US in the example).
Let me know if that helps at all.

Related

In Twilio how could I get the usage of only active phones

I was just wondering if there is any endpoint in the Twilio API to get the usage filtered by Active Phone Numbers.
I've been going through the docs but can't seem to find a solution other than checking the calls endpoint for each one of the phone numbers in my account which is not ideal.
If I check the usage endpoint and filter by category phone numbers since the account was opened it says I've had 300 phones so far, but I can't seem to find how many of those are active or not.
Updated
Also, is there a way to filter the usage per phone number? For example I'd like to see the usage for a specific phone number but I don't want to call the Calls endpoint I just want the Usage.
Twilio developer evangelist here.
You can check how many currently active phone numbers you have with the Incoming Phone Numbers resource.
I'm afraid there's no way to separate your usage records by phone number within the one account.
However, you can do this by subaccount. If you are trying to measure different users' usage within your system then the best thing to do is to create subaccounts for each of those users. Your main account can still view usage records for all subaccounts, but the subaccounts can also be viewed individually.
Let me know if that helps at all.

Twilio - Is there a way to bypass voicemail

I have a twilio app that provides an on-call list of phone numbers that our customer's can call and speak to one of our on-support developers.
I need to find a solution that will allow the caller to press a key to bypass the voicemail of a the calling party and be redirected to the next person in the on-call list. Right now, if I call my twilio app using my number and I get the calling party voicemail, I don't have an option to move onto the next person in the call list.
Is there a way to mimic the hangupOnStar feature when a caller gets a person voicemail in twilio?
Thanks,
I had a look into this and unfortunately it does not look like you can nest <Dial> within <Gather> otherwise this might be possible.
What I would recommend is when you receive an inbound call, play a message along the lines of "Please wait a moment while we connect an available developer", then <Enqueue> the call.
At this point your application can start calling the developers and when the line connects ask them to press #, when this happens you can <Dial> the developers call into the queue ID Twilio proved in the last call to you app, and the calls will be bridged. If the developer did not press # then you can assume that it went to voicemail, at which point <Hangup> and initiate a call to the next dev on call.
Hope that helps.

Twilio number to another twilio number call

I am developing contact center using twilio where my application get request from server to call contact center, so my application initiate a request to call contact center (Twilio enabled number) and contact center is twilio soft phone once the contact center accept a call my application initiate another request to call user so contact center person and user will be in conference. In my application From number is also a twilio enabled number. so my question is can I call one twilio enabled number to another twilio enabled number using java?
Twilio developer evangelist here.
I'm not 100% clear on what you're trying to achieve, but it is certainly possible to connect two Twilio numbers in a call. Those numbers will need to either dial onto a Twilio soft phone or a phone number connected to a real phone in order to connect two people.
I'd recommend taking a look at this Java click to call tutorial which should give you an idea of how to connect to one number, then generate the call to another number and give you a start in this.
Let me know if this helps at all.

How do you retrieve a caller ID from from a digital line or a VOIP phone?

On my work place, we have some (PBX)Business Communications Manager 450 Telephone System and some (PBX)BCM50 also. The BCM450 is hybrid, which mean it can use digital lines and at the same time VOIP phones.
Right now, for example a user can have a Nortel Avaya 1120E or a Nortel T7316 Norstar in their desk.
I would like to know if there is a way in which way I can get the phone number of the caller, so I can use that number on a custom software for the company. In other words I want the phone number of the person calling me (maybe the extension if that is the case).
What I'm looking for, is that when a customer calls, the information associated with the telephone number can be seen on the screen programmatically (without input from system operator).
I can see there is someone talking about TAPI API, but i believe this is only for analog lines? Maybe somebody can put me on the right path or maybe somebody can provide an example of how it is done using any programming language.
If the VOIP phones are SIP based then you'd sniff eth. ports of the phones. SIP messages contains caller Id and called Id.
You can google like "SIP sniffer" for source code example...

Twilio Voice: Tracking a user from website to twilio phone call?

I'm trying to see if this is even possible in twilio. I'm hoping maybe someone's had a similar challenge and came up with a creative solution...
Our company has a unique phone number that's only displayed on our website. I've been asked if it's possible to find out not only how many calls we're getting (which is simple enough to track in twilio), but also who's calling. Basically, they want to follow the details of a users activity. From website to phone call.
Theoretically, they'd like something like this:
A user, lets call him John, comes to the website & is assigned a unique id of "12345". The id is stored in a cookie for returning users (this I can already handle).
If John calls the phone number displayed on the website, we...somehow through the use of twilio...know it's user #12345.
We can then create monthly reports stating user #12345 called the phone number 7 times this month for a total of 18 minutes.
There's so many "what if's" that go into this, that I'm just not sure it's even possible, but perhaps someone knows of a creative way this can work? A few things I've considered, but none of them are foolproof:
Tracking a combination of John's geographical location while browsing the website and the time of web browsing, then using twilio voice to track the geographical location & time of the phone call, to make a best guess. The problem is it sounds like twilio voice isn't always great at providing geo location.
Tracking mobile click to calls on the website, then matching the time of the click to the time of the phone call. Several problems with this, including multiple users calling at the same time, and we'd only be tracking those who browsed the website via mobile, then clicked to call.
For mobile click to call, passing the user's id via a phone extension, which twilio then reads (not sure if this is even possible in twilio). But again, this would be limited to mobile users.
So, I'm just not sure if this is even possible. Any idea's on how this could be implemented?
Thanks so much for any help.
Twilio developer evangelist here.
Have you considered making it possible to make the calls through the website itself? If you implemented Twilio Client you would be able to directly track users who called from the website and they'd be able to do so without picking up the phone too. That direct connection would allow you to make the calls more personal too, as you'd know exactly which user was calling.
Check out the tutorial on implementing browser calls in Twilio and let me know what you think.
I can't think of any straightforward ways to connect a user's browsing session to a phone call made with a different device though. You could ask the user to input their ID in order to start the call, using <Gather> to receive the input and tie that call to the user and whether they currently have a live session on the site. That might be an unnecessary barrier to people calling though, so you'd have to weigh up that option.

Resources