nexmo: forward to application and callers number - vonage

We have 3 options to connect to get inbound call.
Forward to Phone
Forward to application
Forward to SIP
Forward to Phone: When we call LVN then provided number gets call and callers number is seen in incoming call.
Forward to application: When we call LVN, then it goes to answer URL webhook. From answer url webhook, we provide connect ncco to call to my number. This time I am seeing LVN number in incoming call.
So is there any way in "Forward to application" method, that we will be able to see callers number in incoming call.

Yes you can forward the number of the incoming call by dynamically generating the NCCO when the call comes in and setting the from field in the connect action.
There are some examples in different coding languages available on the Nexmo developer portal and check the NCCO reference on connection actions for exact examples but in a nutshell set the "from field at the same level as the action and endpoint fields in the NCCO response to contain the "to" number that is in the GET parameter of the incoming webhook to your answer_url.
Hopefully that makes sense, good luck :)

Related

Twilio Rest API / Node Js call status no working

I'm creating a tool that can automatically call someone when I click a button.
So far, I've tested three solutions: The first one was using the rest API call, the second one was using node js SDK that is available in the Twilio console using the function & assets feature, and the last one was using Twilio Studio feature.
All of them are not giving me the satisfaction of creating something that can be used in production.
The main problem is the call status given to the StatusCallback url parameter.
For example:
if you set a timeout value by default or something higher than the duration of the ringing time, it will send you a completed status. The timeout value needs to be smaller than the maximum number of ringtone that your carrier set by default if you want to receive a no-answered status.
If your phone is on "airplane mode" and you make a call to it using Twilio, the statusCallback will be sent to the URL as "completed".
If you make the same phone call and imagine that the user rejects the call by clicking on the red phone instead of the green phone, the statusCallback will send you a completed status.
So it's been a week since I've coded a NodeJS solution using Twilio Functions, making POST requests using Postman, and also creating a flow to test it using Twilio Studio. Every time that I've tried those three solutions, with the three same scenarios described above, I've never been able to obtain a real valuable/informative status that can help me to resend the call until someone answers or, based on the status, send an SMS to the person to inform him that we have tried to call him and that he either was not available or rejected the call.
Has one of you already tested that and maybe succeeded in having anything else than a "completed" status? That is no use in case you need to handle those cases.
Thank you for your help.

Does Twilio provide any APIs or services that can detect if call has been placed on hold by the receiver?

I'm placing a call from my React Native application using Twilio and the outbound call works fine. Now I want to create something that will detect when I am put on hold by the receiver. The idea here is to make my app hold for me and get back to the caller once the hold has ended.
I searched the twilio docs and services but could not find any thing regarding this use case. How would I go about doing this?
Twilio developer evangelist here.
Unfortunately, there is no mechanism to make this happen, even if there were something in the SIP signaling from the carrier, such as a re-INVITE.
In the world of SIP, putting a call on hold often involves sending a re-INVITE with different media parameters, such as saying a=sendonly in the session description. Even if this were passed end-to-end through the PSTN to Twilio, we do not generate webhooks to inform the customer’s app of this fact.
There are some good SO questions about placing a Twilio call on hold and retrieving it later--the Enqueue verb might be helpful.

How to handle uber like scenario in twilio

I have an uber like scenario, where a customer can call a driver, how to handle such call in twilio. My initial attempts were as follows,
client.calls
.create({
url: 'https://handler.twilio.com/twiml/EXXXXXXXXXXXXXXXXXXXXXX',
from: '+18XXXXXXXXX', // customer
to: '+12XXXXXXXXX' // Driver
})
.then(call => console.log(call.sid))
.catch(e => console.log(e))
Here, the url returns the following twiml.
<Response>
<Dial>+12XXXXXXXXX</Dial>
</Response>
I have created a twimlBin(url in client.calls.create() function) which simply dials the driver's number. The problem is that I dont understand how wether the call is made by the client.calls.create() function or the twimlBin. Also no such tutorial is present, to handle such situation.
Thanks in advance
Twilio developer evangelist here.
In the case of a customer calling a driver, your customer would call a Twilio number and that Twilio number would forward onto the driver's number. So, you don't need to create the call using the REST API yourself, the call will be initiated by the customer.
So, you will need a Twilio number for this. Once you have a Twilio number, you will need to set the number's handler for incoming calls. You can point that to the TwiMLBin that you've created as it will do for this first use case. Save the number and call your Twilio number, it will dial you through to the driver's number.
However, you will find that the driver's phone will show the customer's number. For privacy reasons you likely don't want that. This feature is known as masked calling.
To mask the customer's number you can add a callerId attribute to your <Dial>, like this:
<Response>
<Dial callerId="{YOUR_TWILIO_NUMBER}">+12XXXXXXXXX</Dial>
</Response>
Now when your customer calls the driver, the call will be forwarded to the driver and they will see the Twilio number.
This is great for our simple use-case here, but if you want to mask numbers for a number of drivers, then there's a bunch of work to do. Thankfully, masking numbers is such a common scenario, Twilio built a product to handle that for you. Check out Twilio Proxy and the Twilio Proxy quick start for a tutorial on how to use it to mask numbers.

Nexmo API: Is there any method or API to cancel ongoing outbound or inbound call in Nexmo?

I want to disconnect an ongoing call from my server based on some circumstances. Is there any Nexmo API through which I can do the same?
Got answer to my query. Bit of more searching and study found my answer.
I can modify in-progress call by making a PUT call to below URL.
https://api.nexmo.com/v1/calls/:uuid
where UUID is uuid of call.
have to give action = 'hangup'

Webhooks are not fired. API nexmo

I use the nexmo api to redirect all call to a virtual us number to a real number.
To implement i use this request :
https://developer.nexmo.com/api/developer/numbers#update-a-number
With params below:
moHttpUrl : an url (https) on my server which respond 200 OK
country : US
misdn : the us virtual number
voiceCallbackType : tel
voiceCallbackValue : the real forward
voiceStatusCallback : an url (https) on my server which respond 200 OK
(The data is well recorded, i can see it on nexmo backoffice)
Problem : when i call the us number with my phone, the redirection is ok. I stay on line 10 seconds and stop the call.
At the moment nexmo should call my voiceStatusCallback but do nothing.
Furthermore i have no idea on which informations are passing with the webhook.
Thx for your help.
It looks like your problem is related to https, the simple call forwarding is part of our deprecated voice API and as such that only supports SHA-1 certs on https, so I'm imagining this is your problem.
https://help.nexmo.com/hc/en-us/articles/115005461928
There are 2 options, either use http for your callback (not great I know) or take a look at our new Voice API which will give you a lot more control, if you want to do a simple call forward you would just need to host a JSON file on a URL somewhere that contains a connect action see https://developer.nexmo.com/api/voice/ncco#connect You will then get a whole bunch of call event webhooks such as when the call starts, is answered and ends.
Rgds
Sam
Nexmo Developer Advocate

Resources