It is possible to send a notification via Teams. Depending on certain events, users will then receive a message. This message can be simple or enriched with HTML code to highlight certain information.
Three distinct methods for sending a Teams message are possible:
- Either directly via PowerApps,
- via PowerAutomate, by calling a flow from PowerApps :
- With Teams Actions « Post message in a chat or channel«
- With Teams Action « Send a Microsoft Graph HTTP request » from Teams Connector
From only PowerApps
1. Add the Teams connector
2. Add a button
3. Add the following formula to the OnSelect function
A. You create a new Chat instance with your receipient :
UpdateContext({TeamChat: MicrosoftTeams.CreateChat("email@email.com", {topic:""}).id});
B. You create a message
Set(MessageChat, { recipient : TeamChat, messageBody : "Hello World"});
C. You can now send a message (MessageChat variable) in Chat (TeamChat variable) :
MicrosoftTeams.PostMessageToConversation("User", "Group chat", ParseJSON(JSON(MessageChat)));
You can reduce the formula as follows :
MicrosoftTeams.PostMessageToConversation(
"User",
"Group chat",
ParseJSON(JSON(
{
recipient : MicrosoftTeams.CreateChat("email@email.com", {topic:""}).id,
messageBody : "<b>Hello</b>"
}
))
);
By PowerAutomate with Teams Connector
1. Create a new Flow named CreateChatTeamsMessage
2. Add When Power Apps calls a flow (V2) trigger
3. Create a new Text input paramater named Email

4. Add « Post message in a chat or channel » Action from Teams Connector

5. Select Flow bot in Post as parameter
6. Select Chat with Flow Bot in Post in parameter
7. Add Email Parameter in Recipient field and a Message.

8. In PowerApp page, create a Button
9. Add the following formulas to call your new flow :
CreateChatTeamsMessage.Run("email@email.com")
By PowerAutomate with MS Graph
We can also use the Automate power connector. This connector also has the advantage of being basic, and therefore free. You won’t need an additional license. It will interface directly with MS Graph to create a message.
Before doing so, you need to obtain the chat ID of the recipient. This will enable you to send the message with the Chat ID.
1. Create a new flow named CreateteamsMessageGraph
2. Add Text Input parameter named ChatId
3. Add « Send a Microsoft Graph HTTP request » action

4. In the new action added, set Uri parameter
Uri : https://graph.microsoft.com/v1.0/me/chats/@{triggerBody()?['text_1']}/messages
Method : Post
Body : {
"importance": "high",
"body": {
"content": "Hello World"
}
}

5. Go in your PowerApp Canvas page, and add a galley with Items formulas
MicrosoftTeams.GetChats("oneonone","all").value
6. Add a new button in item Gallery control with following formulas :
CreateteamsMessageGraph.Run(thisItem.id)