I am currently experiencing inconsistent behavior when creating a new calendar event via the Graph API.
I am marking an attendee for an event as status: Accepted. When the calendar event is created, I can see this attendee marked as Accepted within Outlook. (see below for sample API request)
However, in the invite that goes out to the attendee (and by extension, the attendee's calendar event), the not status is reflected. The event is awaiting a response.
This creates an inconsistency where, from the perspective of the event organizer, the attendee has "Accepted", but from the perspective of the attendee, the event is pending response.
What is the intended behavior here? Can we expect an update in the future that will make this behavior consistent with the above.
Example API request: To create an event, we're posting to https://graph.microsoft.com/v1.0/me/events with a payload like
{
"subject":"Subject",
"body":{
"contentType":"Text",
"content":"Meeting body"
},
"start":{
"dateTime":"2018-04-13T00:00:00Z",
"timeZone":"UTC"
},
"end":{
"dateTime":"2018-04-13T00:30:00Z",
"timeZone":"UTC"
},
"isAllDay":false,
"location":{
"displayName":null
},
"attendees":[
{
"emailAddress":{
"address":"redacted#gmail.com",
"name":"Test Testington"
},
"type":"required",
"status":{
"response":"accepted"
}
}
]
}
The response status is stored independently in each mailbox/calendar. Each attendee has their own copy of the event. When an update to a meeting is received, the mail server looks up the associated event in the recipient's mailbox using the iCalUId property. Each event in each mailbox is a unique record, only linked by this shared iCalUId.
Everything the recipient knows about an event is provided via the iCal object attached to the meeting invite. There isn't a mechanism to "look up" events on a remote server. So while you're marking the attendee as "Accepted", the remove mailbox has no way of knowing this.
Related
I'm developing a Slack app that posts alert apps to channels. I want this app to check the history of a channel to find messages it has posted earlier so it can respond accordingly. For example, if there's an alert that has not yet "cleared" it will update said alert instead of posting a new message.
The challenge I'm encountering is that it's not clear how I can identify messages that my app has posted. I see that I can search a channel with conversations.history, and that gives me message events. It looks like some messages have a user property. There are also bot_message sub-type messages that have a bot_id property. However, I don't see any way to identify my app ID.
Should every app have an associated bot_id? user ID? If so, where do I get these IDs so I can filter the conversation history?
Update
I tried calling the bots.info method with no bot ID parameter hoping it would give me my bot ID, but it returned no data other than an "OK" status.
Perhaps because Slack has a long history of different APIs, I was misled. Apparently, it's possible for me to find messages my bot previously posted but not how I thought. Here were my misunderstandings and what I've found out when playing with the Slack API tester.
Using conversations.history, you can get a list of messages posted in a channel. The docs say that the history returns an array of message events, and that these have a subtype field. One of the subtypes is bot_message, so my assumption is that messages posted by my bot would have this sub-type. The docs for bot_message has a bot_id, which I don't know for my app, and username, which I don't know what it will match.
However, it turns out when I posted a test message, that the message did not show up as a bot_message; rather it appears in the history without a subtype and has properties which don't seem to match any documentation:
{
"bot_id": "B01HSBYRKUZ",
"type": "message",
"text": "Testing the Slack API; please ignore.",
"user": "U01HDNUJ5EE",
"ts": "1609878469.036400",
"team": "<omitted>",
"bot_profile": {
"id": "B01HSBYRKUZ",
"deleted": false,
"name": "my-bot-name",
"updated": 1608584973,
"app_id": "<omitted>",
"icons": {
"image_36": "...",
"image_48": "...",
"image_72": "..."
},
"team_id": "<omitted>"
}
}
So although it's risky to code against an undocumented format (or maybe I just can't find the right docs?), I can filter these messages by looking to see if there's a bot_profile.app_id that matches my app's ID, which I do know.
you may know id your bot if use context. Example: const {botUserId} = context
When I am doing a POST to me/calendars/[calendar-id]/events with the following payload. It successfully creates the event, and I receive the new event's id:
{
"start": {
"timeZone": "America/Chicago",
"dateTime": "2022-12-23T15:00:00"
},
"end": {
"timeZone": "America/Chicago",
"dateTime": "2022-12-23T18:00:00"
},
"subject": "Please don't delete me!",
"body": {
"contentType": "text",
"content": "I'm just an event in the future, I wonder if I'll send a '#removed' notice?"
}
"isCancelled": false,
"type": "singleInstance"
}
But shortly after that, my webhook is getting hit with this information for that event, indicating that it was just removed:
{
"#odata.type": "#microsoft.graph.event"
"id": [that-event-id]
"#removed": {
"reason": "deleted"
}
}
When I go and look on my Outlook calendar, the event still seems to be present, and if I GET it, isCancelled is false.
This is only happening for events created over a year ago, or two years in the future.
Having been plagued by this same issue for about a month ourselves, I think I was finally able to track this down yesterday.
We use the events delta API instead of the webhook API, but apparently the same bug affects both... Someone at Microsoft really needs to fix this, it's insane.
Answer
Changes to events outside of the startDateTime..endDateTime window initially set on the events delta request always show up as a #removed delta.
More details
The events delta API captures the initial startDateTime..endDateTime window, which is then used for all subsequent calls with a $deltatoken. This will also bite you unexpectedly if your delta query uses $select etc. as changes to it will not apply until you create a new delta (by not passing an initial $deltatoken)
This detail is what led us to setting up a bit of a timebomb for ourselves. We had an initial window that was somewhat wide, but suddenly started receiving widespread reports of events showing as cancelled that definitely have not been removed from calendars.
This is a bug
Please, someone from Microsoft acknowledge that this is a real issue. Change made outside the discretely specified time window should NOT affect it, this makes it difficult to build integrations that we trust.
This only happens to events created over a year ago or two years in the future.
I’m guessing it has something todo with retention policies defined by your organization.
https://learn.microsoft.com/en-us/microsoft-365/compliance/create-retention-policies
With retention policies you can define how long specific items should be kept before being auto removed.
This can also happen if you end up using the wrong $deltatoken too.
I have a problem with my Microsoft Graph webhook subscriptions to /me/events. What I want to do is to subscribe to all user calendars.
First I have created the new app in https://apps.dev.microsoft.com using my personal Microsoft account.
Then in my app I subscribe to /me/events notifications using access token:
POST https://graph.microsoft.com/beta/subscriptions
{
"changeType": "created,updated",
"notificationUrl": "https://xxxxx.ngrok.io/notification-url",
"resource": "/me/events",
"expirationDateTime": "2018-11-14T09:40:10.933Z",
"clientState": "xxxx-xxxx-xxxx-xxxx"
}
My notificationUrl receives validation request to which my app responds with 200 OK and validation token. After that the POST request returns me my subscription:
{
"#odata.context" : "https://graph.microsoft.com/beta/$metadata#subscriptions/$entity",
"id" : "2773aa4c-e983-4d15-9236-xxxxxxxx",
"resource" : "/me/events",
"applicationId" : "d551ec34-8d44-4cc6-9b88-xxxxxxxx",
"changeType" : "created,updated",
"clientState" : "xxxx-xxxx-xxxx-xxxx",
"notificationUrl" : "https://xxxxx.ngrok.io/notification-url",
"expirationDateTime" : "2018-11-14T09:40:10.933Z",
"creatorId" : "00000000000"
}
This subscription works fine but only for one, default calendar in Outlook. I don't receive any notifications if I create, update events in any other calendars that exists in my account.
What could be the problem here, am I using wrong resource name (/me/events) or this is some limitation for personal accounts in Microsoft Graph?
When you use /me/events you are going to the default Calendar for the user (per the docs). In your case, you would want to enumerate the user's calendars (GET /me/calendars) then subscribe to each one's events collection, using the resource /me/calendars/{calendar-id}/events.
I am using the typheous gem to create a new Event through the Google Calendar API (V3). The response returns 200 and a Calendar Event is created. My question, is there a way to always create the Event with a video-call attached as well?
response = Typhoeus::Request.new(
"https://www.googleapis.com/calendar/v3/calendars/calendarId/events",
method: :post,
body: {
start: {
dateTime: Time.parse(split_time_range[0])
},
end: {
dateTime: Time.parse(split_time_range[1])
},
attendees: [
{
email: "#{ENV["my_email"]}"
}
],
summary: "New Meeting"
}.to_json,
params: {access_token: session[:google_calendar_access_token], calendarId: "primary", sendNotifications: true},
headers: {"Content-Type": "application/json"}
).run
The Google Calendar event body does have a field called HangoutsLink
hangoutLink string An absolute link to the Google+ hangout associated with this event. Read-only.
As you can see this field is read only. I would try and send it when you are creating your event but i am not sure its something you can set with the API.
There is an issue logged for this Calendar API: Hangout not being added automatically to event when creating using the API. I have not been able to find the "automatically create a video call to a created event" setting which they speak of but its an old issue this may have been removed.
I'm using slacks events API and have setup a subscription to the reactions_added event. Now when a reaction is added to a message, slack will send me a post body with all the details of the dispatched event as described here.
The problem I'm having is that I want to get the details, specifically the text of the message that my users have reacted to so I can parse/store etc that specific message. I assumed the message would return with some type of UUID that I could then respond to the callback and get the text, however I'm find it difficult to get the specific message.
The only endpoint I see available is the channels.history, which doesn't seem to give me the granularity I'm looking for.
So the tl;dr is: How do I look up a via slacks API, a messages text sent from the events API? Give the information I have the event_ts, channel and message ts I thought would be enough. I'm using the ruby slack-api gem FWIW.
You can indeed use the method channels.history (https://api.slack.com/methods/channels.history) to retrieve message from a public channel . The reaction_added dispatched event includes the channel ID and timestamp of the original message (in the item) and the combination of channelId + timestamp should be unique.
Be careful that you use the correct timestamp though. You need to use item.ts not event_ts
Full example dispatched event from the docs:
{
"token": "z26uFbvR1xHJEdHE1OQiO6t8",
"team_id": "T061EG9RZ",
"api_app_id": "A0FFV41KK",
"event": {
"type": "reaction_added",
"user": "U061F1EUR",
"item": {
"type": "message",
"channel": "C061EG9SL",
"ts": "1464196127.000002"
},
"reaction": "slightly_smiling_face"
},
"event_ts": "1465244570.336841",
"type": "event_callback",
"authed_users": [
"U061F7AUR"
]}
So calling channels.history with these values set should work:
latest = item.ts value
oldest = item.ts value
inclusive = 1
channel = item.channel value
If you want to get messages from a private channel you need to use groups.history.
https://api.slack.com/methods/channels.history