Microsoft Graph meeting request appointment id - microsoft-graph-api

I'm trying to port API code from ExchangeService to Microsoft Graph for handling meeting requests received in a mailbox.
The old code casts inbox messages as MeetingMessage and then refers to the appointment by its item.AssociatedAppointmentId.UniqueId. MS Graph doesn't seem to have a similar id in its message properties?
I get the meeting messages from the Inbox with
var inboxMessages = await graphClient.MailFolders.Inbox.Messages.Request().GetAsync();.
I tried https://graph.microsoft.com/v1.0/users/[mail]/mailFolders/Inbox/messages/[message_id]?$expand=microsoft.graph.eventMessage/event, but it returns "404 The resource was not found".
How do you get the appointment id from the meeting request message in MS Graph?

Related

Send message to self-Chat in Microsoft Teams using Graph API

I'm trying to send a message to my self-Chat in Microsoft Teams through a Graph API call but can't find the ID of this specific chat. For the record, this type of chat was introduced to Teams in June, 2022.
By reading the Graph API documentation, it's possible to list all chats available for a specific user using the following API call (in this case, myself):
[GET] https://graph.microsoft.com/beta/me/chats/
Yet, I can't seem to find my self-chat in there. The chat itself is already created since I wrote messages in it but it doesn't appear in the call response.
I've tried to filter the results by most recent results, by filtering on my own name or by filtering by ChatType, but it was still missing.
Is anyone aware of a way to get the ID of a user self-chat in Microsoft Teams?
Thanks!
Self chat is a special kind, You can use this endpoint to communicate with it:
https://graph.microsoft.com/v1.0/me/chats/48:notes/messages
Hope that helps :)
Answering harrywyn's question regarding the pop up notification, you can set it as unread the same as any chat like this:
EndPoint = f'https://graph.microsoft.com/v1.0/chats/48:notes/markChatUnreadForUser'
update_chat = {
"user": {
"id" : uid,
"tenantId": TENANT_ID
}
}
resp = requests.post(EndPoint, headers=headers, verify=False, json=update_chat)

Microsoft teams messaging extension inconsistently sending a valid conversation ID to use in a graph call

I am developing a MSTeams application, and inside I use a messaging extension. Upon opening the extension, a request is fired over to my message handler, which I use an azure function to handle. Alongside the request is a payload, with details about the context (in this case the conversation or chat) of where the messaging extension was opened from.
Now, I've built up a graph URL with the conversation ID from the payload:
const id = context.req.body.conversation.id
const graphEndpoint = encodeURIComponent(`https://graph.microsoft.com/beta/me/chats/${id}/members`)
I authenticate a user by calling microsoftTeams.authentication.authenticate({...}) before I make the call, and use the token in the request.
Sometimes, this call will succeed, and return the information I want. However, the other times it will fail with a 400, telling me I had a bad request, despite it being a GET request with no body.
I notice in bad requests, that the conversation ID doesn't trail with #thread.v2 or #unq.gbl.spaces etc. I have no clue why this is so inconsistent, or if it's my fault. Any help would be appreciated.
EDIT: I have also seen that the issue only occurs when the id starts with a:, and succeeds when it starts with 19:. However, the context in which I open the messaging extension is the same each time: In a 1:1 / User:User chat.
I have previously implemented installing the bot in the conversation to get this information, but this method is very undesirable. Perhaps a side point - it seems that the conversations where I have previously installed the bot seem to return the 19: id, and everything else a:.
Here's an example of the 400 response:
{
"error": {
"code": "BadRequest",
"message": "Bad Request",
"innerError": {
"date": "2021-01-25T09:43:26",
"request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1",
"client-request-id": "3bb55aa2-e694-4c80-952c-88842f482dc1"
}
}
}
The conversation id you received in the turn-context is not the chat-id. The conversation id is different from conversation id. Conversation id the id between bot and the user and chat id the id of the chat. Both are different. You cannot use conversation id to call the graph API. Please use the chat id to call graph API. You can get the chat id using list chats API.

How to get all in-progress rooms with their participants in one HTTP request?

For performance reasons, I need to get all rooms together with their participants in only one HTTP request. Is that supported by Twilio REST API Client?
You can use the Twilio Room Resource API to get the list of Rooms based on there status.
Below is the Code in C# which returns a list of Room resources created in the given account. The list also includes paging information. Status Can be: in-progress (default) or completed
// Find your Account Sid and Token at twilio.com/console
TwilioClient.Init(accountSid, authToken);
var rooms = RoomResource.Read(
status: RoomResource.RoomStatusEnum.Completed,
limit: 20
);
Let me know if it helps!

Does Outlook graph api cache events?

I am making a call to the graph api to get a specific event:
return await graphClient.Me.Events[ExternalID]
.Request()
.Expand(singleValueExtendedPropertyExpandString)
.GetAsync()
.ConfigureAwait(false);
The event is properly returned. However, when I try to get the instances for the event:
var instanceException = (await graphClient.Me.Events[ExternalID].Instances
.Request(queryOptions)
.GetAsync()
.ConfigureAwait(false))
.Where(i => i.Type == EventType.Exception)
.FirstOrDefault();
I get an error from the graph API: "The specified object was not found in the store.".
I used the graph explorer to search for the particular event (with the url: https://graph.microsoft.com/v1.0/me/events/EXTERNALID) and also received the message that the object could not be found.
I have rerun the code several times and returned the event on the first GET only to receive an error on the second GET.
Has anyone experienced this before? Does the graph api cache GET results?
Does the event appear in the calendar in Outlook or teams' client?
I have faced this issue when creating an event through graph API and sometimes it returns a success response with the event data but the event doesn't appear in either calendars and returns the same error you posted when trying to query it.

slack rtm api, get usernames from dm channel id and vice-versa

I'm playing around with the slack rtm api, and they say that "You can send a message to a private group or direct message channel in the same way, but using a Group ID (C024BE91L) or DM channel ID (D024BE91L)." Is there any way to get from the DM channel ID to the username that you are sending the direct message to?
I'm using a workaround to get this, there might be better way but I couldn't find one.
You can make an API call to im.open with user id (not username, though it can be retrieved pretty easily), the response will return you the DM channel ID.
This is a quick attempt I did in Python:
def get_direct_channel(sc, user_id):
'''
Get direct channel id from userid
sc => slack client
'''
direct_message = sc.api_call("im.open", user=user_id)
channel = direct_message.get("channel")
if channel:
channel_id = channel.get("id")
if channel_id:
return channel_id
return None
More info from the doc.

Resources