cancel
Showing results for 
Search instead for 
Did you mean: 

Flow - post a message to a Teams chat

Posting a message to a Team channel is possible but it could be interesting to do the same thing to a Team chat

Status: New
Comments
bsmith298
Regular Visitor

Our team hasn't found channels useful. But we do use the chat to communicate all day. So this would be awesome.

shchien1117
New Member

same situation here. I think Teams chat message more useful than Teams Channel post. 

skartes
New Member

I would love to be able to take an email I get from 1 person in my org sent just to me and have Flow move it automatically to Teams chat.  

jhurdus
New Member

Completely agreed, this would be a massive value for our application!! In our case, submission of a form would create a sharepoint list item, which would also pull from the form a specific set of users that are all then put into a group chat together.

 

This would be AMAZING.

David_Nguyen
Microsoft

This is possible with the following steps: 

1- Add HTTP with Azure AD connection in your flow:

 

s.PNG

  • => This will generate the skypetoken for posting message.

 

2- Create another Invoke a HTTP request action to post the message using new connection.

 

You need to open your Team in Web mode and find the msg.teams.microsoft.com url for Base URL. It will be like this:

https://amer.ng.msg.teams.microsoft.com/

Resource is: https://teams.microsoft.com/

 

David_Nguyen_0-1597813068710.png

 

In the Invoke action URL, you need to paste your conversations id which is the Chat you want to post the message, like below

 

https://[region].ng.msg.teams.microsoft.com/v1/users/ME/conversations/[conversation_with_thread]/messages

 

Headers:

 

{ "authentication": "skypetoken=@{body('Invoke_an_HTTP_request')['tokens']['skypetoken']}" }

 

 

Request Body should be like:

 

{
"content": "<div><div class=\"copy-paste-block\" itemprop=\"copy-paste-block\">

 

click in this link: <p><a href=\"https://teams.microsoft.com/\" title=\"https://teams.microsoft.com/\" target=\"_blank\" rel=\"noreferrer noopener\">https://teams.microsoft.com/</a></p>

 

</div>\n</div>",
"messagetype": "RichText/Html",
"contenttype": "html"
}

 

as.PNG

 

Note:

If you get this error message:

BaseResourceUri (https://teams.microsoft.com) must be a base of the full url (https://apac.ng.msg.teams.microsoft.com/v1/users/ME/conversations/19:c669b980f2434a738704xxxxx92fabe...).

 

This means the connection used in the SECOND Invoke http action is still using the connection for FIRST http action  in which we used for https://teams.microsoft.com/api/authsvc/v1.0/authz or the Base Resource URL does not set correctly as in Step 2

You need to select the connection which used with based is like: https://apac.ng.msg.teams.microsoft.com in the three dots menu (...) 

 

image.png

 

 

Good luck with Power Platform!

David Nguyen

RCAUTOWFM
New Member

@David_Nguyen is there another way to accomplish this? My organization does not utilize the premium services.

 

Thanks!

David_Nguyen
Microsoft

@RCAUTOWFM I used to try with the HTTP action only but the access_token from login step is not enough permission to generate the skypetoken or I made something wrong.

Steps might help on your checking:

1.PNG

2.PNG

3.PNG

4.PNG

 

Reference: https://docs.microsoft.com/en-us/graph/auth-v2-user

nkoterba
New Member

@David_Nguyen I'm having the same issue as @RCAUTOWFM  when it comes to subscription level. We do not have premium so even a regular HTTP action is blocked. It would be best if the Teams module supported posting to a chat versus just team channels as most of our staff use chat over channels.

 

Any other ways to accomplish this without "PREMIUM" level?

 

H4077
New Member

@David_Nguyen please 

 

What other options i have in the field "MessageType" other than "Text"??? Im trying to get a message with a clickable url. But it seems the mandatory field in the body request "MessageType": "Text" makes my result in just plane text and not in a clickeable URL

David_Nguyen
Microsoft

@H4077 

 

I updated the comment. Change request body with

 

"messagetype": "RichText/Html",
"contenttype": "html"