2
votes

Using the Microsoft Teams documentation here and following the hyperlink titled "Office 365 Connectors API Reference", which links to https://dev.outlook.com/Connectors/Reference but redirects to: https://docs.microsoft.com/en-us/outlook/actionable-messages/card-reference we end up with a page titled "Actionable message card reference".

This is a very useful document, listing all the fields we can use in a JSON string to create actionable contact cards, to push to various webhook connectors within the Office 365 ecosystem.

Using the JSON validator at https://messagecardplayground.azurewebsites.net/ I have constructed and tested the following:

{
   "title":"New Office 365 Group: Success",
   "text":"Performed by: someuser",
   "themeColor":"00e600",
   "sections":[
      {
         "title":"Section Title"
      },
      {
         "facts":[
            {
               "name":"Name",
               "value":"PRJ000001"
            }
         ]
      },
      {
         "potentialAction":[
            {
               "@context":"http://schema.org",
               "@type":"ViewAction",
               "name":"View Log",
               "target":"something"
            }
         ]
      }
   ]
}

This is valid and renders correctly on that site, but when trying to send it to either an Office 365 Group Mailbox or a Team Channel, I get the error:

Bad payload received by generic incoming webhook.

If we take a simpler JSON construct like so, it works for both the O365 Group Mailbox and Team channel:

{
   "title":"New Office 365 Group: Success",
   "text":"Performed by: someuser",
   "themeColor":"00e600",
   "potentialAction":[
      {
         "@context":"http://schema.org",
         "@type":"ViewAction",
         "name":"View Log",
         "target":[
            "https://link/to/log"
         ]
      }
   ]
}

It appears as though either the documentation is ahead of the service, or that the Groups and Teams webhook connectors don't support the full list of options and perhaps this only works for Outlook? Any ideas?

Thanks.

2

2 Answers

3
votes

The ViewAction mentioned in the payload is not supported now. You should replace it with OpenUri action. you can find more information about in our documentation: https://docs.microsoft.com/en-us/outlook/actionable-messages/card-reference

Please use the following payload and it should work fine.

{
"title": "New Office 365 Group: Success",
"text": "Performed by: someuser",
"themeColor": "00e600",
"sections": [{
        "title": "Section Title"
    }, {
        "facts": [{
                "name": "Name",
                "value": "PRJ000001"
            }
        ]
    }, {
        "potentialAction": [
            {
                "@context": "http://schema.org",
                "@type": "OpenUri",
                "name": "View Log",
                "targets": [{
                        "os": "default",
                        "uri": "http://..."
                    }
                ]
            }
        ]
    }
]
}

Let us know if you run into any other issues.

2
votes

Here are a couple of suggestions:

  • You should include the summary property which is required, even though the documentation doesn't say it. We'll fix that.
  • Try replacing your ViewAction with an OpenUri action. ViewAction is deprecated. Although ViewAction is still supported, we want to encourage everyone to use OpenUri instead.