O365 deprecating webhook in Teams - Affecting the "Post Incident Detail" MSTEAMS Action in flow

Corrie Van Wyk
Tera Expert

We have built some functionality using the MSTEAM "post incident detail' OOB Action in Servicenow Flow designer to post incidents to the relevant Teams Channel based on the relevant webhook configured for a channel in teams.

We recently got a notification from TEAMS that: 
Action Required: O365 connectors within Teams will be deprecated and notifications from this service will stop. Learn more about the timing and how the Workflows app provides a more flexible and secure experience. If you want to continue receiving these types of messages, you can use a workflow to post messages from a webhook request. Set up workflow

The supposed replacement for this is the workflow "Post to a Channel when a webhook request is received". But this will directly affect the OOB action "Post incident Detail" and other of the OOB actions for teams.

Has anyone been notified of this and maybe have a valid workaround to post incident details to an MS TEAMS channel like the Post Incident Details function does today?

10 REPLIES 10

Joel O
Mega Sage

Some other new information provided to me in another thread. Hope this helps others out. 

 

https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1650148

 

This is indeed the solution provided to the case I logged:
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB1650148

In Short, there seems to be like for like actions between Microsoft Teams Spoke and the Microsoft Teams Graph Spoke

I am still investigating if this does work as expected

Spencer L
Tera Contributor

How to handle the Microsoft Teams Connector Deprecation in ServiceNow

 

If you utilize Microsoft Teams Connector webhooks for posting messages to channels you may have noticed that this warning message concerning their deprecation.

Deprecation Warning.png

 

The Teams Connectors were initially scheduled for deprecation on [?]. On July 23rd, Microsoft announced that they would be extending the retirement time line for existing Teams Connectors through December 2025 and Connector usage after December 31, 2024, existing Connectors will require additional action for them to work (you have to change the respective webhook URLs). Teams Connectors will be replaced by “Workflows”.

 

For those that are using the ServiceNow Microsoft Teams “Post a Message” Flow action from the Microsoft Teams Spoke for IntegrationHub and want to refactor their ServiceNow/MS Teams message posting pipeline using Workflows, below is a simple guide to achieve this, pending an update to the Spoke.

 

  1. Set up workflow
    1. In your desired Teams Channel, open the channel settings and select Workflow

Workflows Dropdown.png

b. Select Post to a channel when a webhook request is received

Workflow templates.png

 c. In the workflow, open the first flow step and look at the HTTP POST URL (it should look something like https://prod-XXX...) and copy it for later. This is the endpoint we will be using in our ServiceNow Flow

 

2. Refactor ServiceNow “Post a Message” Microsoft Teams Flow Action

Before running to simply replace the webhook URL input in the existing Flow Action, let’s take a look deeper look at it. we see that the action makes use of a script include called “MSTeamsMessageBuilder(). We see that it utilizes the generateBasicPayload method. In that function, we can see the structure of the payload.

 

If we compare this payload to the payload shown in the Webhooks documentation, we see that they are not the same.

 

 

{
        "type": "message",
        "attachments": [
            {
                "contentType": "application/vnd.microsoft.card.adaptive",
                "contentUrl": null,
                "content": {
                    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                    "type": "AdaptiveCard",
                    "version": "1.2",
                    "body": [
                        {
                            "type": "TextBlock",
                            "text": "Submitted response:"+ response
                        }
                    ]
                }
            }
        ]
    }

 

Note: More advanced Adaptive Cards can be created be utilizing the Adaptive Card Designer and replacing the “content” property with the generated JSON in the Card Payload Editor in the Designer linked above.

 

In other words, the existing ServiceNow “Post a Message” Microsoft Teams flow action will not work in its current state. Not to worry!

 

In Flow Designer, let’s create a custom Flow Action called “Post a Message to Microsoft Teams” (or whatever you’d like to call it.

 

Set up the following Action Inputs 

Action Inputs.png

Add a new “Script” (or Payload Builder) step and call it “Build Payload” and set up the following input variables

buildPayload Input Variables.png

Use the code below for the “Script” field:

 

(function execute(inputs, outputs) {

var payload = {
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "contentUrl": null,
            "content": {
                "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
                "type": "AdaptiveCard",
                "version": "1.3",
                "body": [],
                "actions": []
            }
        }
    ]
};

if (inputs.messageTitle != null) {
    payload.attachments[0].content.body.push({
        "type": "TextBlock",
        "text": inputs.messageTitle,
        "wrap": true,
        "size": "Large",
        "weight": "Bolder"
    });
}

if (inputs.message != null) {
    payload.attachments[0].content.body.push({
        "type": "TextBlock",
        "text": inputs.message
    });
}

if (inputs.actionURL != null) {
    payload.attachments[0].content.actions.push({
        "type": "Action.OpenUrl",
        "url": inputs.actionURL
    });
    if (inputs.actionName != null) {
        payload.attachments[0].content.actions[0].title = inputs.actionName;
    } 
}

outputs.payload = JSON.stringify(payload);

})(inputs, outputs);

 

 

Set up the following Output Variable 

buildPayload Output Variables.png

 

Add a new “REST” step and configure using details below

REST Step.png

 

Additionally, you can add error handling to this Flow Action if you’d like

Hope this helps!

Thanks a lot. I've tried to follow your suggestion. I could post the message to Teams Channel successfully. But facing some issues.

 

  1. It seems not support the HTML format?
  2. The character seems to be limited?
  3. Can we hide the 'Open Url' button if we don't put the Action URL? 

 

 

Bird1_0-1723014831903.png

 

Spencer L
Tera Contributor

I recommend referencing theAdaptive Card Designerif you would like to adjust the look of the posted card. The example I provided is the simplest version of a Teams adaptive card