When I subscribe to a Geolocator.StatusChanged event sink, does Geolocator calls back immediately first event with the current status or I need to get actual status through a Geolocator.LocationState property right after subscription on the callback?
And the same for PositionChanged - does Geolocator calls back immediately after subscription and when location is available?
Related
I'm using an incoming call flow that starts call recording, asks a bunch of questions, gathers responses, at the end of the call: stops recording and sends a sms to caller using send/wait for reply widget. A response is expected and based on what's in the body of the incoming call, it calls a function.
All this works, except, I am not receiving a response back from the caller.
My concurrent call setting =off
incoming trigger = incoming call
the flow is tied to a phone number (voice)
I'm not sure how to get a reply back into the same flow. Do I need to attach something to the message section of the phone number?
Any guidance would be appreciated
A Studio flow execution represents one call, one SMS, or the incoming call trigger from the REST Trigger. As the call initiates your flow, it will terminate when the call ends.
But you can work around this by using a function that gets invoked when the recording is done. This function can then use the Twilio APIs to fetch contextual information from the call and trigger the REST API interface of the same flow (but with a different trigger).
I created a small example that does something similar:
The flow is triggered by a call, starts a recording, and gathers data
There is a recording callback URL that points to my function
// This is your new function. To start, set the name and path on the left.
exports.handler = function (context, event, callback) {
console.log(`Recording ${event.RecordingSid} state changed to ${event.RecordingStatus}.`)
if (event.RecordingStatus === "completed") {
const client = context.getTwilioClient();
return client.calls(event.CallSid).fetch()
.then(call => {
client.studio.v2.flows(<Flow ID>)
.executions
.create({
to: call.from,
from: <YOUR NUMBER>,
parameters: {
RecordingUrl: event.RecordingUrl,
}
})
.then(execution => {
console.log(`Triggered execution ${execution.sid}`)
return callback(null, "OK");
});
})
.catch(callback)
}
return callback(null, "OK");
};
You can find the ID of your flow in the console (or when you click on the root element and check the Flow Configuration):
The REST API triggers a second flow execution that reads the parameter and uses them to send a text message:
I am following this approach to work on hold and resume of a call from the virtual caller's end. It works but I am facing two more issues. FYI, the setup is exactly same.
First:
The first round of Hold, Resume works perfectly. On Hold, I pass the CallSid, then I apply the <Enqueue> TwiMl to the child calls (only one would be here in my case).
client.calls.list({ parentCallSid: callId }).then(calls => {
calls.forEach(call => {
call
.update({ twiml: '<Response><Enqueue>ADMIN_ID</Enqueue></Response>' });
});
});
And on Resume, I update the Sid of the Caller to Dial again from the queue
client
.calls(callId)
.update({ twiml: '<Response><Dial action="/holding"><Queue>ADMIN_ID</Queue></Dial></Response>' })
It works perfectly foe the first round. When I hit the hold for the second time, it says We are sorry, some application error occurred. Good Bye! at the caller end and disconnects. At the receiver end, it goes to playing hold music. What am I doing wrong?
Second:
I see that setting action in the <Dial> keeps it alive and repeats the action TwiMl in my case. But in a normal scenario without any hold, if the receiver disconnects, I as the caller keeps hearing the action repeatably and the call doesn't hang up. Also while on hold, if the caller or callee hangs up the other one just keeps stuck in the current state. Is there any way to fix this with the above setup?
Fixed the issue by using REST API checks for status of the calls.
client.calls.list({ parentCallSid: callId }).then(calls => {
calls.forEach(call => {
if (call.status !== 'in-progress') {
client
.calls(callId)
.update({ status: 'completed' })
}
});
});
F.e. the above code checks if the parent Sid (virtual caller) is disconnected and in that case it disconnects the child call.
I am developing a simple application in C# which
Trigger a call using Twilio
receiver to press * after receiving the call and finish the call after pressing *
Provide the status completed if user pressed * otherwise provide different status.
I was able to make a call but not able to receive the user input Or status, I tried finishOnKey() but that didn't work, and it always provides status as completed. I didn't get much help from Twilio code sample, can someone redirect to correct article or provide the code to accomplish above.
Twilio developer evangelist here.
Once a call is answered successfully, it doesn't matter how the call is finished, the final status it reaches will be "completed". You can see more about Twilio call statuses in this documentation. You can see that the final call statuses could be:
completed: call was answered successfully and then finished
no-answer: Twilio dialled the number but there was no answer before the timeout
busy: Twilio dialled the number but received a busy signal
cancelled: The number was dialled, but the call was then cancelled using the API before answering
failed: the carrier couldn't connect the call
If you are using <Gather> to take the user input, you should ensure you have set the action attribute to a URL in your application. That URL will receive a new webhook request when the user presses a digit. For example:
<Response>
<Gather action="/gather_results" digits="1">
<Say>... your content goes here ...</Say>
</Gather>
</Response>
With the above TwiML a user would only have to press 1 key before the call is moved to the next stage and the webhook '/gather_results'.
The request to the /gather_results endpoint would include a body with a Digits parameter. If the user pressed "*" then the body of the request would include Digits=*, if the user pressed "1" then it would include Digits=1. You could then choose to do whatever you like with those results, including hanging up the call or recording the submitted digits.
Let me know if this helps at all.
I want to use twilio to test our internal phone system, and make sure calls are routing as they should, since our provider is notoriously bad of notifying us to problems.
I'm can initiate a call from twilio, use the "gather" verb to record speech (to ensure we hit the right queue) and then hang up. Everything works fine. Except that the gather ends up taking over 2 minutes to listen to the whole message from our phone system, charging us for 8 15 second gather chunks. I only need the first 15 seconds, but can't figure out how to hangup sooner. Is there a simple way to limit calls to a specific time?
timeLimit, and timeout both don't apply here, since timeLimit only works inside of a dial verb, and timeout only works for pauses in speech during the gather.
Perhaps just set a timer in your code for 15 seconds or so and then use the POST endpoint at /2010-04-01/Accounts/{AccountSid}/Calls/{CallSid} to cancel the call (using the Status=Completed parameter in order to cancel calls even if they are in progress).
If you use their Ruby SDK, and you make a normal call (not a conference call) then you can use the update method:
client = Twilio::REST::Client.new(account_sid, auth_token)
# fetch all in-progress calls between the two numbers
client.calls.list(from: '+11231231234',
to: '+12312311234',
status: 'in-progress').each do |c| #it's supposed to be just one record, but you can play it safe
c.update(status: 'completed')
end
Updating the status to completed should hangup the call if in-progress.
Updating the status to canceled should hangup the call if ringing/queued.
If you know for sure that the call is in-progress and you know the call sid, then you can use:
client = Twilio::REST::Client.new(account_sid, auth_token)
in_progress_call = client.calls(call_sid).fetch
in_progress_call.update(status: 'completed') if in_progress_call.present?
There is some general information in the official docs. Also snippets are available for the other SDKs.
You can find the source code of the update method here for more details.
I am trying to get all the events in a Conference room's calendar with Microsoft graph API, given a startDateTime and endDateTime. I tried the following API's -
1. https://graph.microsoft.com/v1.0/users/{id}/events?startDateTime=2017-03-20T05:00:00.0000000&endDateTime=2017-04-06T21:00:00.0000000
2.https://graph.microsoft.com/v1.0/users/{id}/calendar/calendarView?startDateTime=2017-03-20T05:00:00.0000000&endDateTime=2017-04-06T21:00:00.0000000
The response includes all events with isCancelled=false. How do I fetch events which were Cancelled?
&$filter=isCancelled%20eq%20true also returned empty as there are no events with isCancelled=true in response
By design, when an event is canceled, it is deleted from the calendar. So, there isn't a way today to query list of events that are deleted. We have an item in our backlog for supporting deleted events, but no timeline.
I just tried
https://graph.microsoft.com/v1.0/Users/xx/Calendar/Events/xx/instances
?startDateTime=2020-02-17&endDateTime=2020-03-01&isCancelled=true
and what came back are all the non-cancelled events...
Ditto isCancelled=false
leaving off the &isCancelled=xx parameter returns all the events with the isCancelled attribute set to false for everything.
I was trying to fetch event after getting notification when event cancelled. I am trying with notification resource url and it throws exception:
Microsoft.Graph.ServiceException: Code: ErrorItemNotFound.
What I was expecting that response with notfound status code rather than throwing exception.
My code for fetching event:
var request = new EventRequest(
$"{_graphClient.BaseUrl}/{notification.Resource}",
graphClientApp,
null);
var message = await request.GetResponseAsync();
var response = await message.GetResponseObjectAsync();