Microsoft Teams – Magic xpi : Send Chat message using Microsoft Graph REST API

Goal : Send Microsoft Teams Chat message from Magic xpi using Microsoft Graph API

1/ Define Authorization "ChatMessage.Send" under Microsoft Graph API in Azure Portal (Delegate authorization is mandatory)

2/ Get the conversation id from the Teams URL

(*) if you dont see the id in the URL, disable “Nouveau Teams” (“New teams”)

3/ Check that you can send a message using Postman with your credentials

Fill the Authorization TabControl with all relevant information (clientid, secret, …)

The URL must be in the format : https://graph.microsoft.com/v1.0/chats/<conversation id>/messages

exemple : https://graph.microsoft.com/v1.0/chats/19:3a12f010-cf21-488c-948a-2041bda4e04c_9037358c-987a-4368-94c4-ad256a9a7629@unq.gbl.spaces/messages

Set the json body with : {“body”: {“content”: “<text message>”}}

Check that the reponse is 201 Created

4/ Define a REST Magic xpi Resource with OAuth2 and press the “Access Token” Button

Verify that you can get an access token and verify that the refresh token is available.

5/ Define a path on the Magic xpi Resource by pressing “Paths” button

The path must be in the format : /chats/{id}/messages

where {id} corresponds to the teams conversation id

6/ Drag & Drop a REST Client component to make a Post on /chats/{id}/messages

set the conversation id

set the DataBlob with the Json Message

That’s all Folks.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

Retour en haut