Twilio Studio - Make outgoing call make http request on hangup - twilio

I have a Studio Flow where I want to send HTTP requests a lot between different steps in my flow.
At first, I trigger the flow with rest API and use "make outgoing call" widget to call the user. If anything else happens than the user picking up, I want to send a HTTP request to my server what happened.
I have created the first part of my flow to test these HTTP requests:
Whatever I do except for picking up the phone, eg: letting it ring untill the end, immediately hanging up when i get called, making sure my line is busy when i get called, ... None of these events are being sent to my database.
I know the HTTP request widget and my URL to post to is working, because when I attach a HTTP request widget under "Answered", I am getting results in my database.
I have played around with the "TIMEOUT" option in the 'make outgoing call' widget. But I am unsure how to play around this.
If I set it too low (ie: 10seconds), the phone will stop ringing after 10seconds (but the http requests will go through fine). If I set it too high (ie: 60seconds), my phone will have stopped the phone call after +- 20seconds by itself, and no http requests will have gone through.
How do I make sure I catch all actions that happen?
EDIT: An example of a log for a flow where the timeout is set to 60seconds.

Related

Trigger say verb during live call between device client and caller

We have a use case where we need the device client, connected within the browser, to be able to trigger different Say verbs at any given time during the live call between the device client and the caller. Whatever is said needs to be heard for both client and caller and included in the recording.
I set up an API endpoint that takes the CallSid and updates twiml, however, the statement is only heard for the device client and the calls are immediately disconnected. From my understanding, this is intended due to how TwiML works, since there is no other command after Say, so it believes the call is complete.
return await client.calls(callId)
.update({ twiml: '<Response><Say>Ahoy there!</Say></Response>' });
I've considered using a Redirect which would put the caller into a new flow to hear the prompt, however, the device client then wouldn't hear it, and it wouldn't be part of the recording, so that will not work. Using a conference call, the statement is only played for the new call either before they join or after their call ends.
Is there any way to accomplish this?

is threre any configuration to control permission to internet in IOS

Is there any configuration like android user-permission in iOS to control access to internet?
I think all new projects access to internet by default, is that correct?
When I send a request to the internet it returns 0 http-error code, it means I can't access to the internet.
yes, it is correct all the new ios project have access to the internet by default.
A status code of 0 in an NSHTTPURLResponse object generally means there was no response and can occur for various reasons. The server will never return a status of 0 as this is not a valid HTTP status code.
Any http request will first be processed by the operating system, and during that phase you can get an error. Getting an error means that your request never got a response from the server (and with the exception of https requests where certificates were not accepted, most likely didn't reach the server).
If this phase succeeds, then you get eventually a reply from the server. This may take time, you may have to wait 60 seconds. Which is why you do all your internet requests on a background thread. That reply will have a status code (status, not error). The status code is NEVER 0.
By default, iOS doesn't allow http requests, and doesn't allow https requests to unsave servers, so you better use only https unless you have a very good reason. You will need a very good reason to convince Apple to let your app on the app store if you want http requests to succeed. But if you get this wrong, you get an error quite early on.
A status of zero most likely means that a background request didn't finish by the time you read the status, a basic programming mistake. You need to learn how background threads and callbacks work. Without that, you won't be able to use http successfully.
Also google for "Reachability" which can tell you if your app currently has internet access (like when WiFi and Mobile Data are turned off, or in Airplane mode).

Twilio Child Call Status incorrect?

I'm experimenting with Twilio and I'm confused a bit by the ultimate status of my calls.
Here's what I'm doing. I'm making a call to a Twilio Phone Number which is hooked into an application endpoint. The app makes a database record of the call and then uses Twiml to make a secondary call out to another phone. After the call is complete, the call record is updated with data retrieved from Twilio then a secondary call record is created from the call in my account where its parent_call_sid is my original call's sid.
My issue is, if I call the Twilio Number but let the Twiml Dial timeout, the child call status ends up being 'completed' instead of 'no-answer'.
My question is why is this happening? Do I need to configure how I dial out differently in order to receive the appropriate status for my calls?
UPDATE:
This has been resolved. The issue was voicemail picking up before Twilio's default timeout of 30 seconds ended the call, resulting in a 'completed' status. By reducing the timeout Twilio was able to end the call with 'no-answer' before the voice mail picked up.
The issue was the timeout was long enough for the voice mail to pick up, which does not count as no-answer. Reducing the Timeout so that Twilio ends the call before voice mail answers correctly results in a no-answer status.

WebExtension redirect and block websites

I have started simple web extension for firefox which in theory should block access to specific websites based on some response from the remote server. User tries to navigate, new page will not be loaded until confirmation is not received from the remote server. Unfortunately remote "check" server is limited to a few requests in a second for each user so I can't (and it's unnecessary to) check each request made after user navigates to some page. Is there any method to listen for "real" navigation not all those requests and redirect whole tab somewhere before any requests are even made?
I've tried add-on API:
tab events fired after content is already received, which is not nice.
"http-on-modify-request" event is fired for each request separately spamming remote check server.
WebExtensions:
browser.webNavigation.onBeforeNavigate seems like what I need, but I can't neither send check request neither redirect from there and I am not sure I will able to.
"http-on-modify-request" event is fired for each request separately spamming remote check server.
that observer notification gives you a http channel, the channel has a loadInfo property, which has an externalContentPolicyType property which allows you to filter for top level document loads by matching one of the content policy constants.
WebRequest.jsm and browser.webRequest are abstractions over the http observers and provide similar functionality.

TwiML App: If the caller hangs up in the middle of the application process, does Twilio notify the app of a hang up?

I am trying to figure out a way to capture if the caller hangs up in the middle of TwiML instructions. If the caller hangs up (abandons the call) does twilio notify the application of such?
I see the status callback url setting but I just get a "completed" status. I was wondering if the caller was in a middle of a gather and hung up would twilio know the call hung up and report it? Or am I supposed to just see the "completed" status and at that time determine if the call actually successfully completed or not?
Twilio evangelist here.
To my knowledge we don't have a specific way of telling you that a caller hung up during the middle of a <Gather> other than the status callback passing you the CallStatus, which as you points out just tells you that the call was completed, not where within a TwiML document or a call flow the caller was.
If you want to know where within a call flow the call ends (for example the caller hangs up), I'm pretty sure that is something you would need to track in your own application. You could do that by storing the callSid of the phone call along with some meta data that helps your app know where in the flow the call is, and just updating each time Twilio makes a webhook request to your app.
Hope that helps.

Resources