Is it possible to detect a call ended in studio?
I have a studio flow that performs a call to a number (this is the first step and it is configured with the make outgoing call widget). The problem is that i am not able to detect if the call ends once the call is connected, the widget itself allows detecting if busy or failed.
I want to know if it is possible to detect call end event so i am able to react to this in my app. Or be able to start an outbound call using call resource api and after the call is connected guide my user through the flow steps (I only have a phone number if that matters)
Thanks.
Studio does not expose the StatusCallback so you are aware of the status of the call. You can build this outside Studio and configure the StatusCallback URL to be alerted to the call state. You can fine more details here, Set StatusCallback on an outbound call.
Related
Is there any way to change what events trigger the status callback? Normally you can use statusCallbackEvent but I can't seem to find a way to make this work for the Voice SDK's leg of the call. It works fine on the call leg of the outbound participant, but not the Voice SDK's call leg. I only get completed status event for this leg (and I also can get ringing from the called action url).
Things I tried without success:
Updating the call using the REST api to set statusCallbackEvent to initiated ringing answered completed when the outbound call starts
Setting statusCallbackEvent as an outbound parameter on the Voice SDK's token (in PHP you can set custom parameters using $clientToken->allowClientOutgoing(...) but it seems normal parameters cannot be modified)
I really wish you could set this on the TwiML Application so that any numbers calling out with that application set will just automatically use your set events. That or let me set the parameters on the client's token.
One way to fix this is just to poll for the information but that is an ugly hack and isn't real time.
Twilio developer evangelist here.
I don't think you can do what you're asking for here, but for good reason.
When you are placing the call from the Voice SDK, that call leg is then between the application and Twilio. You know the call was "initiated", because you started it. There is no "ringing" because Twilio is not a phone and won't ring. You know it is "answered" because a request is made to your voice URL defined by the TwiML app. And finally, you do get the "completed" event.
As you say, you do get the events for the outbound leg of the call from Twilio to another phone number.
I'm trying to set up a Flow with a Send and wait for reply widget (triggered with the REST API), however, the reply doesn't seem to trigger the next widget (handle_welcome...) and instead triggers the Incoming Message for the Flow (handle_incoming...).
Is there a way to set up a Flow so that it knows that the received SMS is a reply and not just a generic Incoming Message?
Here is a screenshot of the flow:
I only have one number set up and that is set to trigger the Studio Flow on an incoming message.
Also, I'm not sure if it makes a difference but I have Concurrent calls trigger enabled.
Make sure that you do not have the phone number associated to Service. I had created a service, associated the number and that seems to have short circuited the flow. I logged a ticket with Twilio and they kindly instructed me to remove it. Once I removed it, the flow worked as expected:
Remove the number (:warning: if this is not required for your service. Else, purchase a new number and use that with your flow)
Click Remove
References
Twilio Studio Rest v2
Twilio Execute Flow
Twilio Send & Respond Widget
To use the REST API trigger with a subsequent wait and reply widget, the phone number you send from can not be associated with a messaging service.
Remove that association and then you will be able to use the flow with both REST API trigger and incoming message trigger.
I have a Twilio Studio flow that uses the "Gather Input from User" during an outbound call.
I have widgets following all possible outcomes, including "No Input".
However, I have discovered that if the user hangs up during this step, the flow ends.
I need to capture the fact that the user hung up, but I can't figure out how.
Any suggestions?
Twilio developer evangelist here.
For an outbound call from the Studio widget there is no way to capture status events as you would for a call normally. There are two workarounds though.
Firstly, if you are recording the call then you can set the recording status callback, which will notify you once the recording is ready and thus the call is over.
Alternatively, you will need to poll the Studio REST API to keep an eye on running executions and when they finish.
I have a use case where I want to forward a call from A to C. Here if the call is already forwarded to some number i.e A to B, then I need to disable the current forwarding(i.e A to B) and then enable the new call forwarding(i.e A to C). But the new forwarding should start only if the disable call worked. I am using twilio webhook call to identify the call status. The approach I have followed is, in the method to which webhook sends response, I am checking the status of call. So when its completed, I try to find the Phone A from my apps database using call_Sid. I am storing call_Sid against the phone number that is to be forwarded. But here is the main problem.
Now when I receive status as completed for disabling I need the number to which I need to forward the call to. How should I get this new number to be passed into this method which handled twilio webhook response.
Please let me know how to achieve this.
hey this issue look like previous one on Twilio call forwarding
someone facing issue with twilio call forwarding and got its solution:
It is not possible to forward calls to a Twilio number and have that number call you back if you've set up call forwarding on your phone.
I'm running into a problem with an app that I'm building that I'm a little stuck on.
I have an iOS app (handles initiating the call via Twilio SDK) that communicates with a Ruby on Rails back-end (handles the Twilio server side implementation) to enable communication between the iDevice and the phone number being called.
The issue I'm having is that when a call is initiated accidentally (user error or misunderstanding how the app works) and the user goes to terminate the call Twilio has already received the request to create the call and it still goes through.
I've tried disabling the TCConnection and the TCDevice using their respective disconnect methods ("disconnect" and "disconnectAll"), but I'm still seeing the call go through (phone number being called still receives the call from the Twilio side of things). I haven't tried anything on the server side of things because I'd like to avoid building a set of "oh &$^$%" protocols if I can avoid it.
Has anyone experienced this before? Does anyone have any suggestions? Is there anyway to terminate calls made accidentally?
Thanks in advance!
Checking back in to share what I've discovered after reaching out to Twilio support in the event anyone finds this in the future.
From Twilio support:
For canceling a call, you can use the REST API to modify the live call and set the Status to "completed", which will cancel a ringing call and end an established call:
https://www.twilio.com/docs/api/rest/change-call-state
So, in short, build some "oh #^%$*" protocols that you can ping as necessary to actively terminate any call that you need to. Not ideal, but the options are limited.