Event when a user is completing a todo or other task - microsoft-graph-api

I would like to use tasks instead of email for part of our system.
I know how to create a task with MS Graph but what I am looking for is a way to run an azure function whenever a user is completing the task I sent.
Is there something I can listen to in Graph or Azure and fire the azure function with parameters from the task (user, job etc...)
Any idea?

Microsoft Graph API allows you to subscribe to changes to all tasks in a specific task list for the following endpoint
/me/todo/lists/{todoTaskListId}/tasks
You can't get notification for tasks of other users.
But I'm not sure if the received notification contains details whether the task was completed etc.
The second option is to use a delta function call for todoTask to track changes in the todoTask resource
GET /me/todo/lists/{id}/tasks/delta
GET /users/{id|userPrincipalName}/todo/lists/{todoTaskListId}/tasks/delta
But you need to call delta periodically to get set of changes.
Resources:
Change notification
Create subscription
TODO task delta

Related

How to make external api call more efficient

I’m building a shipment tracking system. I have an external service that I can make an API call to get the shipment status. Whenever a shipment status changed, I wanna get notified.
What would be the most efficient way to call the external api to check the status of the shipments? Imagine I have 1 million shipments to track.
You should try to set up a webhook from the external service to your server. When a shipment changes status, the external API should call an endpoint on your server. This is a very common practice for use cases like yours where statuses change and you need to be notified.
Otherwise, you'll just have to poll the API periodically. I'd suggest fitting your calls to the expected pattern of status updates (e.g. if a shipment typically takes a minimum of 2 days to update, then wait 2 days before checking for a status update)

Webhooks v/s polling for all users drives' within an Org (multi-tenant) - MS Graph

We are going to have a multi-tenant application that is going to be scanning files for each user per organization for multiple orgs. We would like to get notification if any user uploads/changes a file in the drive. There are at-least 2 options to retrieve those: either store delta link for each user and poll periodically to get the change or subscribe using webhooks to get notification on change. If we have 10k+ users, I am not sure if the first option is feasible. For the latter one, my only concern with webhook is do I have to register for each user separately? ie., does the resource need to be /users//drive/root or should it just be /drive/root? Since there is a limitation of no. of webhooks per app/tenant, I am not sure if creating webhooks for each user is a right approach.
Please advise.
The limitation applies to the users/groups objects (i.e. if you wanted to subscribe to users/groups being updated), not to the drives.
Yes, you need to subscribe to each drive individually, and to renew the subscriptions individually as well. If you want to save the number of roundtrips, you can group those operations in a batch.
You can also combine the delta + webhooks: do the initial sync with delta and store the token, register your webhook. And then trigger querying the delta link upon receiving a change notification. This way you get the best of both features and avoid regularly polling delta when there might not be any change.

Twilio en queued calls not coming through to agent phone

I am using Twilio Studio to configure an IVR system and was successfully able to do that. Now I am trying to create a queue with few agents so that the calls are not missed. I was able to create a Task Router and create a queue under that, as follows.
I have added two agents to the queue as follows
Now when I make a call, I can hear the music, but the calls are not coming through to the phone. Not sure what I have to do now
Twilio developer evangelist here.
The task workflow goes something a little like this:
Call comes into queue -> Task created -> Task is pending -> Workflow finds Worker -> Reservation created -> Reservation accepted -> Call is routed to worker
From what I can tell, you've done everything but accept the reservation for your worker.
To do that you need to set the Assignment Callback URL for your Workflow. Then, when the reservation is created for a worker Twilio will send a webhook (HTTP request) to that URL. Your application can then accept the reservation and dequeue it immediately, or do a bunch of other things. I recommend you read through the documentation on Task Lifecycle: workflows and assignment for an overview followed by how to Handle Assignment Callbacks for how to put that into action and produce your assignment callback handler.
The simplest thing you can respond with is the dequeue instruction which will connect the call to your worker's contact_uri. That would look like this:
{ "instruction": "dequeue" }
Let me know if this helps at all.

Redirecting a twilio task to a new TwiML after task/reservation timeout

Currently using Twilio TaskRouter to build a telephony call center to route the calls.
My target was:
When a task kept pending for a certain time(i.e: no workers are available for reservation), redirect it to voicemail
When a task is reserved but the the worker didn't response to it, redirect it to voicemail
My Current Implementation was:
Specify both task timeout and reservation timeout
When task timeout / reservation timeout callback is triggered, query the Redirect Instruction reservation api to redirect it to a TwiML of recording voicemail.
But the problem was:
When a task is in pending status, no reservation was created so that I could not access the reservation to perform a redirect
When a reservation is timed out, trying to perform a redirect would receive an execption from Twilio saying that the reservation was nolonger available for redirecting
Twilio developer evangelist here.
There's two issues here, as you've said at the end. You're either trying to move a reservation that doesn't exist or redirecting a reservation that isn't available to redirect.
I think you can achieve your goals by using the workflow instead.
First up, consider the task side of things. You give a task a timeout. When it does timeout the normal behaviour for a task is to move to the next queue that it matches in the workflow.
I'd suggest setting up a final queue that has one permanently available worker object (but not real person) in it. When you get an assignment callback for a reservation for a task in that queue then you can use the redirect assignment to send the call to some TwiML that returns a <Record> to take a message. Your TwiML application can also call the REST API to accept the reservation.
That works for tasks that are never assigned from the initial queue to a worker. For the reservation timeout side of things, consider this.
When a reservation times out, the task goes back into its original queue for assignment again. The task remains under the same original timeout that we defined for it above, so will eventually move to our voicemail queue when the task itself times out. This has the same effect for the caller, as they never know when a reservation is assigned as they'll just be experiencing the wait music in the queue they are in.
Does that make sense at all?

send email automatically at specific date

I'm implementing an email reminder to remind the student of returning the books before expired date.
I know Window Service can achieve that but since the machine will have restriction for installing the Window Service, so is there any other ideas?
You don't need a Windows service to perform background tasks, just use Windows scheduled tasks. You can write an exe or batch file and schedule it as frequently as you like.
If the server won't let you run scheduled tasks, you can always create the task as an action in a MVC controller and create a scheduled task on another machine that calls your action.

Resources