Webhooks are not fired. API nexmo - vonage

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

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.

how to create create event URL for voice app?

I tried to create a voice app it demands:
Event URL
https://exampe.com
Answer URL
http://example.com
which domain do I need to use? Its matter which domain I use? they don't know my domain anyway.
The answer and event URLs are callback URLs (webhooks).
This means that when a voice call is created, and some events happens (such as ringing, user answered the call, user rejected the call, user not answering the call, etc.), the voice server will send a structured request to the callback URL you have provided.
From there, you can develop the logic the callback URL to decide what to do when those events happen, similar to the onClickListener on an Android App's button, if you are familiar with that.
The callback URL server should be hosted by you, implementing the exact same interface. You can refer to this page on what is expected.
https://developer.nexmo.com/voice/voice-api/webhook-reference
As for the domain name, you can use whichever you want, as long as it is pointing to the correct route on your backend server.

nexmo: forward to application and callers number

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 :)

Caching response for API.ai Node.js webhook

I have a webhook designed in Node.js for API.ai that interacts with multiple API's to gather information and give response to user.
Since, I am interacting with multiple API's the response time taken is more than 5 secs which is causing the API.ai request to timeout.
To overcome this, I am trying to implement caching into the node.js webhook which saves the response from API's until a certain amount of time. This will remove timeout until the max-age header time is reached.
Edit: What is the best node module that I can use to cache the API responses for subsequest requests.
Note: I am using request node module for http requests but it doesnt seem to provide a way to cache the response.
All of the answers given are reasonable for tackling the cache problem on the request side. But since you specified API.AI and Actions, you might also be able to, or need to, store information while the conversation is in progress. You can do this using an API.AI context.
It may even be that if you limit it to just one remote call for each response from the user, you might be able to fit it in the timeframe.
For example, if you were having a conversation about movie times and ticket ordering, the conversation may go something like:
User: "I want to see a movie."
[You use an API to lookup the nearest theater, store the theater's location in a context and reply] "Your nearest theater is the Mall Megaplex. Are you interested in one there?"
User: "Sure"
[You now already have the theater, so you query for what it is playing with another API call and store it in a context] "There are seven different movies playing, including Star Wars and Jaws. Do those sound interesting?"
User: "No"
[You already have the data in the context, so you don't need another call.] "How about Rocky or..."
In this way you're making the same number of calls (generally), but storing the user's results in the session as you go as opposed to collecting all the information for the user, or all the possible results, and then narrowing them.
Finally decided to use the below module:
https://www.npmjs.com/package/memory-cache
This served my scenario better. Might try using Redis soon when i get some time.

Telegram different between getUpdates and Webhooks

id like to start using telegram bot, i already read the documentation, but still can't get my head, what's the difference between "getUpdates" and "webhooks"
source: telegram docs
can someone explain this in plain language
thanks in advance
The difference between "getupdates" and "webhook" is just like the difference between pull and push!
Using "getupdates" you don't even need to have a sever! You call telegram server prodically by providing bot's token and it will send you new updates if there is any. It means that your bot is always busy calling telegram even if there is just a single update per your 1000 requests!!
Using "webhook", you first notify telegram about your server ip and listening port and your public key. Then telegram will call your sever whenever there is any update.
At last and not the least If you want your bot to be faster you should use webhook.
Two method can get same content, but you can only use one of them at same time.
Webhook is dependent on HTTPS server, usually use in PHP.
If you haven't a web interface, better to choose getUpdates, which doesn't required HTTPS address to receive updates.

Resources