Friday, March 1, 2019

Send Actionable Message Card to Microsoft Teams From Microsoft Flow

Microsoft Teams is an unified communications platform that combines persistent workplace chat, video meetings, file storage (including collaboration on files), and application integration.

Microsoft Flow is cloud-based service that allows business users to create and automate workflows and tasks across multiple applications and services. Currently Flow has a built-in Teams connector, and it does a decent job which allows Flow instances to post messages into Teams channels. However, the connector currently only supports plain text messages, and they look like coming from the authors of Flow instances. 

There is a way to post richer information to Teams through incoming webhook.

Teams Incoming webhook is a URL provided by Teams for any service to post content with the goal of sharing that content in your team's channel. When you configure it, you get a URL which represent an endpoint accepting JSON message. 

In the following example, I am going to show a simple Flow definition which contains one trigger and one action. On manual triggering, an actionable rich message card will be posed to a Teams channel. 

Step 1 Create an Incoming webhook in a Teams channel
















Name the webhook "SPWorkflowRichMsgCard" (the name can usually be an application or service which all members in the team understand)














Copy the Url of the webhook, and save it for later use












Step 2 Create the Flow definition with a manual trigger and a Http action


In Http action, switch "Method" to "POST", update Url to the Webhook Url saved above, add one header with key as "Content-Type" and value as "application/json", and also paste following JSON snippet into the text editor (Be aware of escaping "@" with "@@")

{
  "@@context": "https://schema.org/extensions",
  "@@type": "MessageCard",
  "themeColor": "0072C6",
  "title": "Sample Feedback Card",
  "text": "Tell us how you like Actionable Messages. Click **Learn More** to learn more about Actionable Messages!",
  "potentialAction": [
    {
      "@@type": "ActionCard",
      "name": "Send Feedback",
      "inputs": [
        {
          "@@type": "TextInput",
          "id": "feedback",
          "isMultiline": true,
          "title": "Let us know what you think about Actionable Messages"
        }
      ],
      "actions": [
        {
          "@@type": "HttpPOST",
          "name": "Send Feedback",
          "isPrimary": true,
          "target": "http://..."
        }
      ]
    },
    {
      "@@type": "OpenUri",
      "name": "Learn More",
      "targets": [
        {
          "os": "default",
          "uri": "https://docs.microsoft.com/outlook/actionable-messages"
        }
      ]
    }
  ]
}


Test the Flow







Open the Teams channel, there should be a rich message card posed by "SPWorkflowRichMsgCard", and it's ACTIONABLE!









Hopefully it's helpful...

4 comments:

  1. Umm... Or just use the Microsoft Teams action "Post your own adaptive card as the Flow bot to a channel (preview)". Shouldn't that work just fine?

    ReplyDelete
  2. @Daniel. Post your own adatpive card is good but it comes with the pre text of use flow in adaptive card

    ReplyDelete
  3. Daniel, using incoming webhook and http action is a little more flexible, so you won't see any fixed text coming with the Teams action. In fact, the same JSON message can be posted from any application, for example SharePoint designer, or even a Java program.

    ReplyDelete
  4. thanks for each certainly one of space informative web site. The vicinity else might also simply I accumulate that satisfactory of sponsorship written in such a perfect means? i've a challenge that Im simply now lively nearly, and i've been on the see out for such safety. windowsupdate_8007000e windowsupdate_dt000

    ReplyDelete