To create a webhook that responds to changes in date or time of an event in Outlook, you'll need to use Microsoft Graph API's webhooks feature along with Outlook's event resource. Here's a step-by-step guide to help you achieve this:
Register an app on Azure Active Directory (Azure AD):
Replace your-webhook-listener-url.com/outlook with the actual URL where you'll handle incoming notifications, and set an appropriate expirationDateTime.
Replace {access_token} with a valid access token obtained using the client ID, tenant ID, and client secret from step 1.
Handle incoming notifications:
Set up a listener at the specified notificationURL to receive and process incoming notifications.
When a change in event date or time occurs, Microsoft Graph will send a POST request to your listener with the updated event details in the JSON body.
Renew the subscription:
Before the subscription expires (as specified in the expirationDateTime parameter), make a PATCH request to the subscription's @odata.id URL to renew it.
Here's an example of how to renew a subscription using curl:
After making this API call, Microsoft Graph will start sending notifications to the specified notificationURL whenever an event is updated, including changes to the event date or time. Make sure to handle these incoming notifications at the specified URL and renew the subscription before it expires to continue receiving updates.
User
How to I make sure invitees can update the date/time of an event in outlook?
Assistant
To allow invitees to update the date/time of an event in Outlook, you need to set the IsOrganizer property to false when creating or updating the event. This indicates that the event is not organized by the creator, allowing invitees to modify the event details, including the date and time.
Here's how you can achieve this using Microsoft Graph API:
Create an event with IsOrganizer set to false:
When creating an event, set the IsOrganizer property to false in the JSON body:
Replace {event_id} with the actual ID of the event you want to update.
By setting the IsOrganizer property to false, invitees will be able to update the event details, including the date and time, using their own Outlook client or Microsoft Graph API. However, the organizer (the event creator) will still receive notifications and can approve or reject the changes made by the invitees.
When inviting the user via the API, can I specify the "Can Edit" permission? If so, how?
Assistant
Yes, you can specify the "Can Edit" permission (also known as "IsOrganizer" or "IsOrganizer set to false") when inviting users via the Microsoft Graph API. This allows invitees to modify the event details, including the date and time. Here's how you can achieve this:
Create an event with attendees and set "Can Edit" permission:
When creating an event, you can specify the "Can Edit" permission for each attendee using the isOrganizer property in the attendees array. Set isOrganizer to false for attendees who should have the "Can Edit" permission.
In this example, organizer@example.com is the event organizer, and attendee1@example.com and attendee2@example.com are attendees with the "Can Edit" permission.
Update an existing event with attendees and set "Can Edit" permission:
If you want to allow invitees to update the date/time of an existing event, you can update the event with the desired attendees and set the property to for those attendees.
User
Thanks :)
Assistant
You're welcome! I'm glad I could help.
User
In the Event Update webhook, can I only respond to changes in date or time, not all event updates?
Assistant
Unfortunately, Microsoft Graph API's webhook (subscription) for events does not support filtering notifications to only changes in date or time. When you create a subscription for events, you will receive notifications for all updates to the events, including changes in date or time, attendees, subject, location, and other event properties.
To handle this, you can implement a listener for the webhook notifications and filter the updates based on your requirements. When you receive a notification, you can compare the updated event with the previous version to determine if the date or time has changed.
Here's a high-level overview of how you can implement this:
Store the latest version of the events you are interested in when you receive a notification.
When a new notification arrives, compare the updated event with the stored version.
If the date or time has changed, process the update accordingly.
Here's a JSON Patch example to help you identify changes in date or time:
In this example, the start and end properties contain the updated date and time values. You can use this information to determine if the date or time has changed.
While you cannot filter webhook notifications to only changes in date or time, you can implement custom logic in your listener to handle the updates based on your requirements.
Replace {event_id} with the actual ID of the event you want to update.
By setting the isOrganizer property to false for the desired attendees, you grant them the "Can Edit" permission to modify the event details, including the date and time. The organizer will still receive notifications and can approve or reject the changes made by the attendees.