Sharing news from sharepoint to teams channel

New Contributor

Hello, I'm making a Sharepoint page where you can post news. I know you can set up a connector where news post is shown in Teams channel. I'm wondering is there a way to make a connector so you can choose if the news is going to show or not and if there are multiply channel so you can choose where the news is going.

Thank you.

1 Reply

@Untuvakana yes this is possible and we do exactly the same thing on our intranet where the user who has published a news story can click a button (or not) to publish the news to the all-company Teams General Channel. This requires some JSON column formatting and a flow in Power Automate.

 

In your Site Pages library you'll need a Single Line of Text column to hold the JSON column formatting. I've also added an extra Single Line of Text column where the flow adds Yes if the story has been added to Teams and turns off the button visibility so it can't be published to Teams twice by mistake,

 

0-SP-publishButton.png

 

THE JSON for the button is as follows and you'd need to replace the flow ID with yours, and also the header and flow run text if you wanted to:

 

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "button",
  "txtContent": "Publish to Teams",
  "customRowAction": {
    "action": "executeFlow",
    "actionParams": "{\"id\": \"021ec4e0-8f85-46b3-a557-a4456960a4eb\",\"headerText\":\"All Things REI\",\"runFlowButtonText\":\"Publish Now\"}"
  },
  "style": {
    "background-color": "#008082",
    "color": "white",
    "border-radius": "15px",
    "visibility": "=if(([$PublishedToTeams] == 'Yes'),'hidden','visible')"
  }
}

 

The flow then looks like this:

1-Flow.png

 

2-Flow.png

 

3a-Flow.png

 

3b-Flow.png

 

3c-Flow.png

 

4-Flow.png

 

The JSON for the Post your own adaptive card action is as follows:

Spoiler
{
"type": "AdaptiveCard",
"body": [
{
"type": "ColumnSet",
"columns": [
{
"type": "Column",
"items": [
{
"type": "TextBlock",
"text": "REI News",
"wrap": true
},
{
"type": "TextBlock",
"spacing": "None",
"size": "Large",
"weight": "Bolder",
"text": "@{body('Get_file_properties')?['Title']}"
},
{
"type": "TextBlock",
"spacing": "None",
"text": "@{outputs('Compose_First_Published')} - @{outputs('Compose_Contact')}",
"isSubtle": true
},
{
"type": "TextBlock",
"size": "Small",
"text": "@{body('Get_file_properties')?['Description']}",
"wrap": true
},
{
"type": "Image",
"url": "@{body('Get_file_properties')?['BannerImageUrl']}"
}
],
"width": 2
}
]
}
],
"actions": [
{
"type": "Action.OpenUrl",
"title": "Go to news article",
"url": "@{body('Get_file_properties')?['{Link}']}"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.0"
}

The result in the Teams channel is shown below:

 

5-TeamsResult.png

 

If you want to post to multiple channels you will either need to have parallel branches with the  adaptive card action in  each parallel branch, or you will need a button in your SharePoint list for each Team and then a separate flow for each team.

 

Rob
Los Gallardos
Microsoft Power Automate Community Super User.
If I've answered your question or solved your problem, please mark this question as answered. This helps others who have the same question find a solution quickly via the forum search. If you liked my response, please consider giving it a thumbs up. Thanks.