【问题标题】:Send message to self-Chat in Microsoft Teams using Graph APISend message to self-Chat in Microsoft Teams using Graph API
【发布时间】:2022-12-02 07:33:19
【问题描述】:

I'm trying to send a message to myself-Chat in Microsoft Teamsthrough 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!

【问题讨论】:

    标签: microsoft-graph-api microsoft-teams


    【解决方案1】:

    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 :)

    【讨论】:

    • Thank you, it works wonders! Is that documented somewhere? I think I missed it in the documentation.
    • I'm not sure if that's documented yet. Figured it out by looking at the link in Teams web client.
    • thanks!!! just adding my call for extra info curl --location --request POST 'graph.microsoft.com/v1.0/me/chats/48:notes/messages' --header 'Authorization: Bearer Token' --header 'Content-Type: application/json' --data-raw '{ "body": { "content": "Hello World" } }'
    • Has anyone been able to get a notification to pop up when you post a new message? I've tried setting it to the highest priority with no luck. I'm trying to use this as a sort of an internal notification system.
    • @David that's actually what I ended up doing in order to get the notifications. I set up a flow to read a RSS feed and shoot off a message when it pulls new items.
    【解决方案2】:

    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)

    【讨论】:

      猜你喜欢
      • 2022-12-19
      • 2013-06-22
      • 1970-01-01
      • 2020-07-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-27
      • 1970-01-01
      相关资源
      最近更新 更多