Microsoft Teams Spoke will not work with Microsoft Teams Workflows - They will stop working in Oct

Community Alums
Not applicable

I ran across this yesterday and have tried to create a workflow in Microsoft Power Builder for Teams to create a new Webhook and it's not working.

The message I'm getting in Microsoft Teams:

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



Putting the new webhook in Microsoft Team Spoke I'm getting the following error:
Error: 400. Message: {"error":{"code":"InvalidRequestContent","message":"The input body for trigger 'manual' of type 'Request' must be of type JSON, but was of type 'application/octet-stream'."}}. (Process Automation.0e9862431324030039a039ed9344b05f; line 5)

Does anyone know how to deal with this.  We have a lot of flows that call into teams and this would suck to have it just stop working.

Any help would be appreciated.

1 ACCEPTED SOLUTION

Keminda
Tera Expert

The reason for the above error is the webhook is expecting the request payload to be in JSON format.

Currently its sent in a  different format. to achieve this you have to edit the flow action step Post Message and add Content Type: "application/json"  in headers.

 

But the next issue you will face is MS Teams spoke is using connector cards (MessageCards) format for posting cards, which is in a different format from Adaptive cards in Teams workflows.

https://learn.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/cards/cards-referen...

 

It Seems, we have to build a custom Flow Action which supports Adaptive card format.

View solution in original post

16 REPLIES 16

To get round this what I did was this:

 

1. Create a new account in Entra ID called ServiceNow.

2. Gave the account the roles needed to post to Teams.

3. Gave the account Cloud admin (I think. Might have bene full admin).

4. Approved the connections in ServiceNow using the new ServiceNow Entra account.

5. Removed the admin privs from the account.

 

This means that all the posts into teams now look like they are coming from a service account called ServiceNow. Which is better than it being an actual person.

 

YMMV

This is true and smart, but I think a big issue we are missing here is that regardless. You have to make sure this user is a member of the team you're posting. 

Ah yes, forgot to mention that bit. That was step 6 when I couldn't get it to work!

Spencer L
Tera Contributor

Simple custom fix (at your own risk) for refactoring MS Teams Connector.

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

 

SpencerL_0-1721935302838.png

SpencerL_1-1721935314691.png

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 Teams Workflow

    • In your desired Teams Channel, open the channel settings and select Workflows

Workflows Dropdown.png

    • Select Post to a channel when a webhook request is received

Screenshot 2024-07-25 at 2.23.47 PM.png

 

    • 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
  • SpencerL_5-1721935546481.png
  • 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": "Hello World!"
                        }
                    ]
                }
            }
        ]
    }

 

 

  • 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

SpencerL_6-1721935679756.png

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

 

SpencerL_7-1721935808773.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

SpencerL_8-1721935850450.png

 

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

SpencerL_9-1721935862002.png

 

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

 

Hope this helps!

 

 

Does this work??