A few days ago, I got a challenge that required me to send a message from a SharePoint page into a Microsoft Teams chat and that can be achieved using Microsoft Graph. I created a blank SPFx project and this post will go to the most important elements. You can also take a look at a sample webpart that I built using this process.
First, you need to add to the package-solution.json the required scopes for the Microsoft Graph can make the required calls. These are the scopes:
{
"resource": "Microsoft Graph",
"scope": "ChatMessage.Send"
},
{
"resource": "Microsoft Graph",
"scope": "Chat.Create"
},
{
"resource": "Microsoft Graph",
"scope": "Chat.ReadWrite"
},
{
"resource": "Microsoft Graph",
"scope": "User.Read"
},
{
"resource": "Microsoft Graph",
"scope": "User.ReadWrite.All"
},
{
"resource": "Microsoft Graph",
"scope": "Directory.Read.All"
},
{
"resource": "Microsoft Graph",
"scope": "Directory.ReadWrite.All"
}
For this webpart to be able to make the calls, you will need to approve this scopes on your SharePoint. Then we need to make 4 calls to Microsoft Graph:
You can check all the required code on the following link.
The post Send a message to Microsoft Teams using Microsoft Graph in SPFx appeared first on SharePoint Tricks.
Original Post https://sharepoint-tricks.com/send-a-message-to-microsoft-teams-using-microsoft-graph-in-spfx/