How can I redirect instruction when Reservation status is accepted? twilio - node.js

I am using twilio flex, task router and twilio functions. I want to redirect the live call to the function I've created.
The Scenario is,
User calls the twilio number.
Agent picks up the call from twilio flex dashboard on computer.
When agent ends the call, only agent should disconnected, and call should redirect to the function I've created.
Thank you,

Twilio developer evangelist here.
This is not something I've done, but the first thing that comes to mind is to over-ride the button that ends the call on the agent side. Rather than having it just end the call, it could call out to a Function that redirects the caller to your function.
I don't have any more detail than that right now. I recommend you try something like this and ask a new question if you have specific questions about the code.

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 do I Redirect live Call from Twilio Flex to Twilio Studio IVR?

I am having problem in transferring the live call. What I have to achieve is, Agent can transfer live call to IVR where IVR ask for rating "Please rate this call from 1-5" and then saves the rating via rest API.
Here is the first IVR where call is sent to flex
Here is the second IVR where flex agent should send the call
I know about Assignment Callback to redirect call to new Twiml document like
{
"instruction": "redirect",
"call_sid": "CA123456789",
"url": "http://example.com/assignment_redirect",
}
How can I use this to redirect Call to Twilio studio again, In studio all are widgets.
This is only semi-possible right now.
Studio Flow executions are a bit different from normal webhooks that return TwiML, since they MUST be the first webhook hit by the call. (For voice calls, it is also a best practice to make sure the same Studio Webhook is configured as the secondary handler and call status handler for the phone number in question, which suggests that Studio is a bit more robust in how it operates than a typical TwiML App.)
The workaround is to use the <Dial> verb to create a new call to the Studio Flow that you wish to redirect to. This assumes that each Flow that handles incoming voice has its own phone number(s).
That said, I have been told that a feature request is underway for sometime in 2021 that would allow for different flows to be linked together, so this may change in the future.
I am not exactly sure how you specify a webhook for once the Flex agent is finished with the call -- it looks like you have already done some research into the TaskRouter functionality that enables this. But assuming you can specify a webhook URL (assignment_redirect in your example), all you should need to do is create a TwiML Bin containing your <Dial> verb to the satisfaction survey Studio flow you want to receive the call, and use that TwiML bin as the webhook URL.

NodeJS/Lambda/Lex/Axios - How to make a synchronous call for slot(s)

I've done my research in regards with making a synchronous calls and it is not recommended as it is blocking the thread. But in my case, it's different.
I am making a simple weather checker amazon lex bot. And I have two slots, {city} and {date}. When the client ask the bot "Check the weather", the bot will then ask the client which city they wanted to check. When the user sends back the {city}, there is where my axios from lambda sends a get request to openWeatherMap api.
The problem is, after the clients gave the {city} where he/she wanna check the weather in, the next slot which is the {date} immediately fire without waiting for the axios call to get finished.
And why am I wanted to wait? Because the axios call may return an error and I want to capture it and display immediately to the client so that the process will be ended.
Important: Do not get confuse with {date} slot, I don't really wanted to get the date. I just make it as example, but the concern is to wait for the axios response from the first slot before the following slot will get triggered.

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.

Resources