Transition to MS Teams Workflows
Asked by Aaron Sachs:

Hi folks,

MS has seen fit to deprecate their connectors in favor of transitioning to PowerAutomate Workflows. The workflow, as I understand it, essentially functions the same as a webhook (i.e., You get a webhook POST endpoint and any payload it receives it will post to a MS Teams channel):  

![CleanShot 2024-07-09 at 13.55.01@2x.png](/t5/image/serverpage/image-id/334429i70C1057C7D40916E/image-size/large?v=v2&px=999 "CleanShot 2024-07-09 at 13.55.01@2x.png")

But that doesn't seem to work as advertised:  

![CleanShot 2024-07-09 at 13.56.51@2x.png](/t5/image/serverpage/image-id/334430i892C4D66FE36018E/image-size/large?v=v2&px=999 "CleanShot 2024-07-09 at 13.56.51@2x.png")

Which I'm seeing fail out with the following:  

\`\`\`

The execution of template action 'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?\['body'\]?\['attachments'\]' is of type 'Null'. The result must be a valid array.

\`\`\`  
From what I can tell, it seems like JSON body being sent over doesn't contain any attachments? Has anyone else made this move to Workflows? If so, how did you do it?


Answers:
author: Mathias Boer-Mah
body: Hi - I have gotten this to work directly in Jira Automation by

Adding the Flow Bot to the Channel in Teams as per below

[Add Flow Bot to Channel](https://www.marksgroup.net/blog/office-365-add-flow-app-and-flow-bot-to-microsoft-teams/#:~:text=You%20can%20now%20add%20Microsoft%20Flow%20directly%20to,bar%20in%20a%20Channel%3A%20Select%20Flow%3A%20Click%20Save%3A)

Using the "Send Web Request"

Inputting the new webhook url (post type) - and using the below custom data body

{  
"type": "Application/JSON",  
"attachments": \[{  
"contentType": "object",  
"content": {  
"type": "AdaptiveCard",  
"version": "1.4",  
"body": \[{  
"type": "TextBlock",  
"text": "{{issue.summary}}",  
"isSubtle": false,  
"wrap": false,  
"size": "Large",  
"weight": "Bolder",  
"spacing": "None"  
}, {  
"type": "TextBlock",  
"text": "{{issue.key}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
}, {  
"type": "TextBlock",  
"text": "Created by: {{issue.reporter.displayName}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
}, {  
"type": "TextBlock",  
"text": "Status: {{issue.Request Type.currentStatus.status}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
}

\]  
}  
}  
\]  
}

Its pretty basic but the unmodified workflow works successfully now

Thanks Ryan for pointing me in the right direction with your code

I will see if Atlassian updates their code for the standard teams automation in the coming weeks before switching over to the above

comments: author: Jesus Cordoba
body: I was able to make it work with a "basic" jason just like you. I appreciate the idea you brought up because i was able to implement it. if anyone needs a copy of my {{issueslookup}} push to an incoming webhook I will be happy to provide it.


author: Nikhil Khairnar
body: Can you help me with solving this issue? i am still stuck with

'Send_each_adaptive_card' failed: the result of the evaluation of 'foreach' expression '@triggerOutputs()?\['body'\]?\['attachments'\]' is of type 'Null'. The result must be a valid array.

this error  


author: Jesus Cordoba
body: Yes, of course. You have to select as shown in this picture. If you nee help on the JSON just provide me the tags/smart values you need to push and I'll be happy to help you. ![Screenshot 2024-07-12 at 5.43.09?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/335404i81657A50343686CA/image-size/large?v=v2&px=999 "Screenshot 2024-07-12 at 5.43.09?PM.png")


author: Nikhil Khairnar
body: Hey Thanks Jesus  
below JSON i am using in this jira automation   
:  
{  
"text": "Unassigned tickets (Number of tickets : {{lookupIssues.size}})\\n{{#lookupIssues}}\\nKey: \[{{key}}\]({{url}})\\nSummary: {{summary}}\\nPriority: {{priority.name}}\\nReporter: {{fields.reporter.displayName}}\\n{{/lookupIssues}}\\n"  
}  

which searches for number of unassigned tickets and the list of those tickets in single teams message.  
Thanks Jesus


author: Michael Orr
body: For any of the fields you're including in the web request that can contain data you don't control (ie: the {{issue.summary}}, {{issue.description}}), you will want to add the .jsonEncode function to them, otherwise any user data which contains characters like quotes will break the json encoding and your web request will fail. Use:

{{issue.summary.jsonEncode}}

{{issue.description.jsonEncode}}


author: Jesus Cordoba
body: Below is the code, after you copy/paste please make sure you have in the "Send Web Request" the correct headers.

![Screenshot 2024-07-15 at 4.47.05?PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/335761iD14FE1BD78FB61F3/image-size/large?v=v2&px=999 "Screenshot 2024-07-15 at 4.47.05?PM.png")

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

{  
"type": "Application/JSON",  
"attachments": \[  
{  
"contentType": "application/vnd.microsoft.card.adaptive",  
"content": {  
"type": "AdaptiveCard",  
"version": "1.4",  
"body": \[  
{  
"type": "TextBlock",  
"text": "?\*\*Unassigned JIRA Tickets\*\*",  
"wrap": true,  
"weight": "Bolder",  
"size": "Large",  
"color": "Accent"  
},  
{  
"type": "TextBlock",  
"text": "Here is a summary of unassigned JIRA tickets.",  
"wrap": true,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "Number of tickets: {{lookupIssues.size}}",  
"wrap": true,  
"weight": "Bolder",  
"size": "Medium",  
"color": "Good"  
},  
{  
"type": "ColumnSet",  
"columns": \[  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "Key",  
"weight": "Bolder",  
"color": "Light",  
"wrap": true,  
"size": "Medium"  
}  
\],  
"backgroundColor": "DarkBlue"  
},  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "Summary",  
"weight": "Bolder",  
"color": "Light",  
"wrap": true,  
"size": "Medium"  
}  
\],  
"backgroundColor": "DarkBlue"  
},  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "Reporter",  
"weight": "Bolder",  
"color": "Light",  
"wrap": true,  
"size": "Medium"  
}  
\],  
"backgroundColor": "DarkBlue"  
}  
\]  
},  
{  
"type": "Container",  
"spacing": "Medium",  
"separator": true,  
"items": \[  
{  
"type": "TextBlock",  
"text": "{{#lookupIssues}}",  
"wrap": false  
},  
{  
"type": "ColumnSet",  
"spacing": "Medium",  
"separator": true,  
"columns": \[  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "\[{{key}}\]({{url}})",  
"wrap": true,  
"color": "Accent",  
"weight": "Bolder",  
"size": "Default"  
}  
\],  
"backgroundColor": "#F3F3F3",  
"separator": true  
},  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "{{summary.jsonEncode}}",  
"wrap": true,  
"size": "Default"  
}  
\],  
"backgroundColor": "#F3F3F3",  
"separator": true  
},  
{  
"type": "Column",  
"width": "stretch",  
"items": \[  
{  
"type": "TextBlock",  
"text": "{{fields.reporter.displayName.jsonEncode}}",  
"wrap": true,  
"size": "Default"  
}  
\],  
"backgroundColor": "#F3F3F3",  
"separator": true  
}  
\]  
},  
{  
"type": "TextBlock",  
"text": "{{/lookupIssues}}",  
"wrap": false  
}  
\]  
},  
{  
"type": "TextBlock",  
"text": "? For more details, please visit the JIRA dashboard",  
"wrap": true,  
"size": "Small",  
"weight": "Lighter",  
"color": "Attention"  
}  
\],  
"actions": \[  
{  
"type": "Action.OpenUrl",  
"title": "View in JIRA portal",  
"url": "Your own URL"  
}  
\]  
}  
}  
\]  
}


author: Nikhil Khairnar
body: Okay Thanks Jesus . It was a big help


author: Jesus Cordoba
body: So it's working for you now [@Nikhil Khairnar](/t5/user/viewprofilepage/user-id/5542432) ?


author: Peter Martens
body: Hi [@Jesus Cordoba](/t5/user/viewprofilepage/user-id/5423915)  

I was just trying out posting a very basic message which I've used the connector for in the past. I've tried adapting it like you mentioned above but I'm not getting the results I expect.  
What I want to post is this (body of the message I use for the connectors):  

\*{{reporter.displayName}}\* has raised \[{{issue.key}} {{issue.summary}}\] ({{issue.toUrl}})  

Could you help me in how to manage this via the webhook directly?  


author: Jesus Cordoba
body: Of course [@Peter Martens](/t5/user/viewprofilepage/user-id/4619679) - here is your code, do you need help with building the flow?

\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

{  
"type": "Application/JSON",  
"attachments": \[  
{  
"contentType": "application/vnd.microsoft.card.adaptive",  
"content": {  
"type": "AdaptiveCard",  
"version": "1.4",  
"body": \[  
{  
"type": "TextBlock",  
"text": "Unassigned tickets (Number of tickets: {{lookupIssues.size}})",  
"wrap": true,  
"weight": "Bolder",  
"size": "Large",  
"color": "Accent"  
},  
{  
"type": "TextBlock",  
"text": "{{#lookupIssues}}",  
"wrap": true  
},  
{  
"type": "TextBlock",  
"text": "\*{{fields.reporter.displayName.jsonEncode}}\* has raised \[{{key}} {{summary.jsonEncode}}\]({{url}})",  
"wrap": true  
},  
{  
"type": "TextBlock",  
"text": "{{/lookupIssues}}",  
"wrap": true  
}  
\]  
}  
}  
\]  
}


author: Cris Ky
body: thanks for the JSON template! It works for the most part during my testing, however, it does fail to trigger a notification for tickets with attachments inside them.

The error message in Jira's audit log reads: **code":"InvalidRequestContent","message":"The request content is not valid and could not be deserialized: 'Bad JSON escape sequence**

Is anyone else getting this?

EDIT: Actually, it's not just tickets with attachments in them... I'm not sure why it gives that error for some tickets but not others.

EDIT2: Fixed my problem by using **.jsonencode**


author: Peter Martens
body: Hi [@Jesus Cordoba](/t5/user/viewprofilepage/user-id/5423915) ,

Thanks for the JSON, Unfortunately it seems I'm still missing some key points because it comes out like this in the teams channel:  
![2024-07-18 08_47_37-Teams and Channels _ Incoming bugs _ DevRepublic _ peter@devrepublic.nl _ Micros.png](https://community.atlassian.com/t5/image/serverpage/image-id/336243iF626A72523BC33F2/image-size/large?v=v2&px=999 "2024-07-18 08_47_37-Teams and Channels _ Incoming bugs _ DevRepublic _ peter@devrepublic.nl _ Micros.png")  

If anyone knows what I'm missing please let me know, I also see some new information in this thread so I'll also read some more to see if that provides me with the answer I'm looking for.


author: Peter Martens
body: Hi, I found out I used the wrong process step. I was using post message instead of post card.  
Now I've updated this and now I'm getting a card, unfortunately this is empty:  
![picture (2).png](https://community.atlassian.com/t5/image/serverpage/image-id/336293i16686ECC8E4D7154/image-size/large?v=v2&px=999 "picture (2).png")


author: Peter Martens
body: Hi all, I've tried some more things without success. Dummy messages are okay but when I use the JSON above I get this message:

**BadRequest** . The request failed. Error code: 'InvalidBotAdaptiveCard'. Error Message: 'Microsoft.Azure.ProcessSimple.Data.Entities.Exceptions.ProcessSimpleDataException: The specified Teams flowbot adaptive card request is missing or invalid. The tracking Id is '{0}'. ---\> AdaptiveCards.AdaptiveSerializationException: Property 'type' must be 'AdaptiveCard' at AdaptiveCards.AdaptiveCardConverter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.DeserializeConvertable(JsonConverter converter, JsonReader reader, Type objectType, Object existingValue) at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent) at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) at Newtonsoft.Json.JsonConvert.DeserializeObject\[T\](String value, JsonSerializerSettings settings) at AdaptiveCards.AdaptiveCard.FromJson(String json) at Microsoft.Azure.ProcessSimple.Data.Components.AdaptiveCards.AdaptiveCardBuilder.DeserializeAdaptiveCard(String serializedAdaptiveCard, RequestIdentity requestor, CultureInfo cultureInfo, BotAdaptiveCardAtMentions atMentions) in C:\\__w\\1\\s\\src\\processsimple\\Roles\\ProcessSimple.Data\\Components\\AdaptiveCards\\AdaptiveCardBuilder.cs:line 750 --- End of inner exception stack trace --- at Microsoft.Azure.ProcessSimple.Data.Components.AdaptiveCards.AdaptiveCardBuilder.DeserializeAdaptiveCard(String serializedAdaptiveCard, RequestIdentity requestor, CultureInfo cultureInfo, BotAdaptiveCardAtMentions atMentions) in C:\\__w\\1\\s\\src\\processsimple\\Roles\\ProcessSimple.Data\\Components\\AdaptiveCards\\AdaptiveCardBuilder.cs:line 754 at Microsoft.Azure.ProcessSimple.Web.Common.Validation.BotAdaptiveCard(String card, RequestIdentity senderRequestIdentity) in C:\\__w\\1\\s\\src\\processsimple\\Roles\\ProcessSimple.Data\\Common\\Validation\\BotValidation.cs:line 918'.


author: Peter Martens
body: Hi everyone,  

I've finally found a solution which is working for me, maybe it might also be helpfull for someone else here.

First I created the web request from Jira:  
![picture.png](https://community.atlassian.com/t5/image/serverpage/image-id/336354i8D01BEA25690CD78/image-dimensions/349x730?v=v2 "picture.png")

Then in teams I created these steps:  
![picture (2).png](https://community.atlassian.com/t5/image/serverpage/image-id/336355iE9DE5D53D60529B9/image-size/large?v=v2&px=999 "picture (2).png")  
For the message I simply added Dynamic content and chose content here:  
![picture (2).png](https://community.atlassian.com/t5/image/serverpage/image-id/336356i7DE5E21D9AF635BE/image-size/large?v=v2&px=999 "picture (2).png")

That's it, after these steps I only faced the issue with a bot not in conversation roster error. This was caused because I was sending to a private channel. Once I was sending to an open channel this was not longer occuring.


author: Bill Almeda
body: I've essentially done the same as above but get the following error:

**ExpressionEvaluationFailed** . The execution of template action 'Apply_to_each' failed: the result of the evaluation of 'foreach' expression '@triggerBody()?\['attachments'\]' is of type 'Null'. The result must be a valid array.


author: Bill Almeda
body: So after posting my last message I got it to work. I had incorrect message type. One outstanding question though, I used adaptive card waiting on response, I will test but will just posting a card work the same way?


author: Aaron Sachs
body: Hey all, so thanks to everyone for the contributions. I ended up with something similar to what many of you have posted:  

{  
"type": "Application/JSON",  
"attachments": \[  
{  
"contentType": "object",  
"content": {  
"type": "AdaptiveCard",  
"version": "1.4",  
"body": \[  
{  
"type": "TextBlock",  
"text": "?? A new ticket has been assigned to the Network Team",  
"isSubtle": false,  
"wrap": true,  
"weight": "Bolder",  
"spacing": "None",  
"color":"Attention" },  
{  
"type": "TextBlock",  
"text": "A new ticket has been received. Please ensure you triage and assign the ticket accordingly.",  
"isSubtle": false,  
"wrap": true,  
"weight": "Lighter",  
"spacing": "None",  
"color":"default"  
},  
{  
"type": "TextBlock",  
"text": "\*\*Summary:\*\* {{issue.summary}}",  
"isSubtle": false,  
"wrap": true,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "\*\*Description:\*\* {{issue.description.jsonencode}}",  
"isSubtle": false,  
"wrap": true,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "\*\*Issue key:\*\* {{issue.key}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "\*\*Created by:\*\* {{issue.reporter.displayName}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "\*\*Status:\*\* {{issue.Request Type.currentStatus.status}}",  
"isSubtle": false,  
"wrap": false,  
"spacing": "None"  
},  
{  
"type": "TextBlock",  
"text": "? For more details, click the \*\*Open Issue\*\* button below",  
"wrap": true,  
"size": "Small",  
"weight": "Lighter",  
"color": "Attention"  
}  
\],  
"actions": \[  
{  
"type": "Action.OpenUrl",  
"title": "Open Issue",  
"url": "{{issue.url}}"  
}  
\]  
}  
}  
\]  
}  

I think some of the key bits for me were the \`.jsonencode\` function (that saved my ? [@Michael Orr](/t5/user/viewprofilepage/user-id/4600374) TY!!!) and then using the adaptive card actions to open the ticket from Teams.   

Practically, it comes out looking like this:  

![CleanShot 2024-07-17 at 15.40.42@2x.png](https://community.atlassian.com/t5/image/serverpage/image-id/336159iDDA4ACE4898423DE/image-dimensions/367x306?v=v2 "CleanShot 2024-07-17 at 15.40.42@2x.png")

Which I'm generally happy with. It seems like there's plenty to play with according to the schema: <https://adaptivecards.io/explorer/AdaptiveCard.html>. Thanks again, all!


author: Britta Neugebauer _yasoon_
body: Hi there,

*(I am cross posting this suggestion, as there are quite a few users struggling with the deprecation of O365 connectors)*

I work at yasoon, an Atlassian Marketplace Platinum Partner. Our focus is to provide applications that deeply integrate Jira and Microsoft 365. So this topic is part of our everyday life and that's why I felt called to share this video with you:

[?? Jira automation: How to deal with the retirement of Office 365 connectors within Microsoft Teams (youtube.com)](https://www.youtube.com/watch?v=2PDvEC9bnQ4)

In the video we're showing you how to set up basic and advanced automations with Microsoft and Jira. Hope it helps.

[Jira automation: How to deal with the retirement o... - Atlassian Community](https://community.atlassian.com/t5/Jira-articles/Jira-automation-How-to-deal-with-the-retirement-of-Office-365/ba-p/2753061)

Happy Friday!

comments: author: Eric Sebian
body: Is this only for jira cloud? I'm on DC.


author: Britta Neugebauer _yasoon_
body: Hi [@Eric Sebian](/t5/user/viewprofilepage/user-id/698764) , the app is also available for DC: [Microsoft 365 for Jira - Outlook Email, Teams, Calendar \| Atlassian Marketplace](https://marketplace.atlassian.com/apps/1213138/microsoft-365-for-jira-outlook-email-teams-calendar?hosting=datacenter&tab=overview)  

If you need help setting up anything, you can get in touch with us here: [yasoon Support - Jira Service Management (atlassian.net)](https://yasoon.atlassian.net/servicedesk/customer/portal/3)


author: Eric Sebian
body: Hi Britta.

this doesn't work for DC the way that it is noted for cloud. DC doesn't have the Actions option yet. the image from cloud shows that that option is needed. ![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/343983iB9F73C2C489C66C2/image-size/large?v=v2&px=999 "image.png")![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/343984iBA8EA9F7E4B40D27/image-size/large?v=v2&px=999 "image.png")


author: Britta Neugebauer _yasoon_
body: Hi Eric, that's right. In DC you can only work with triggers. Can you schedule a call with support so we can advise you on your use case? [yasoon Support - Jira Service Management (atlassian.net)](https://yasoon.atlassian.net/servicedesk/customer/portal/3)

Best, Britta


author: Romain Monnet
body: Hello [@Eric Sebian](/t5/user/viewprofilepage/user-id/698764) ,

I was searching for an answer too. and I saw this page... <https://confluence.atlassian.com/msteamsjiraserver/jira-notifications-via-teams-workflows-1425670660.html>

Maybe it can help you.

BR,

Romain


author: Ryan Haman
body: I put in a bug ticket yesterday - this is the response I got
> As of now, our engineering team is evaluating the level of impact for Jira Automation from the removal of the Office 365 connectors for MS Teams. I'll let you know as soon as we have a clear response for the next step moving forward as the component that the Automation rule is using to send the message to MS team is the deprecated one, and it would need to use the new one from the backend.

comments: author: Ryan Haman
body: Atlassian created the ticket below. Doesn't sound like a quick fix is expected.

[\[AUTO-1374\] Provide support for Microsoft Workflows in automation rules](https://jira.atlassian.com/browse/AUTO-1374)


author: saksham singhal
body: I have one question can we add report as an attachment in it


author: Move Work Forward
body: Guys,

There is another simple way to get notified from [Jira](https://youtu.be/KLhOYe0TaOE), [Confluence](https://www.youtube.com/watch?v=A4E8rx5gu94) and [Bitbucket](https://www.youtube.com/watch?v=3R_r2MpKtUU) in Microsoft Teams channel using Microsoft Teams Workflows app.

Cheers,  
Leo

comments: author: Aaron Sachs
body: Can you share? I wasn't seeing anything other than using a generic webhook endpoint to send a notification to a la <https://community.atlassian.com/t5/Jira-Service-Management/Re-Transition-to-MS-Teams-Workflows/qaq-p/2757518/comment-id/175799#M175799>


author: Jeffrey Davison
body: Leo's suggestion does not work for me for Bitbucket.  

The tooltip for the MS Teams Connector within our Bitbucket instance, explicitly states  
"MS Teams webhook URL. URL must have the following pattern: https://.../IncomingWebhook/.." and the new URL does not have that pattern.  

Testing the connection with the new URL yields an 'Error: Webhook URL is invalid' as you might expect.


author: Jeffrey Davison
body: To close out my statement, shortly after I posted this I found that the the Bitbucket MS Teams Connector had a recent update that handles the Workflows changes.

[https://marketplace.atlassian.com/apps/1220054/microsoft-teams-connector-for-bitbucket?tab=versions\&hosting=datacenter](https://marketplace.atlassian.com/apps/1220054/microsoft-teams-connector-for-bitbucket?tab=versions&hosting=datacenter)

We updated the plugin in our Bitbucket instance and all is well with the new functionality - including backwards compatibility for the old /IncomingWebhook/ URL pattern.

Hope this may help someone else.


author: Adam Brunt
body: We currently have a Jira automation rule which POSTs to an O365 connector and the Web Request Body (on the rule action) is "Issue Data (Jira format)"

I don't suppose anyone has already come up with the custom payload to use to replicate the same message effect with Workflows ?

comments: author: Aaron Sachs
body: Hi [@Adam Brunt](/t5/user/viewprofilepage/user-id/5152789) see my reply here: <https://community.atlassian.com/t5/Jira-Service-Management/Re-Transition-to-MS-Teams-Workflows/qaq-p/2757518/comment-id/175799#M175799>. I took some inspiration from other folks. The kicker is that you have to have Jira post a web request. The Jira automation side looks something like this:

<br />

![CleanShot 2024-07-16 at 22.35.38@2x.png](https://community.atlassian.com/t5/image/serverpage/image-id/336160i580A40DF0C8859AE/image-dimensions/331x253?v=v2 "CleanShot 2024-07-16 at 22.35.38@2x.png")

![CleanShot 2024-07-17 at 15.45.57@2x.png](https://community.atlassian.com/t5/image/serverpage/image-id/336161iD915ABC3AA55B6FF/image-size/large?v=v2&px=999 "CleanShot 2024-07-17 at 15.45.57@2x.png")

And then your teams workflow will use this template:

![CleanShot 2024-07-17 at 15.48.51@2x.png](https://community.atlassian.com/t5/image/serverpage/image-id/336162iDEEBAF7F7A6E3B81/image-size/large?v=v2&px=999 "CleanShot 2024-07-17 at 15.48.51@2x.png")

So you'll sub the webhook endpoint you get from the workflow into your Jira automation.


author: Ryan Haman
body: Getting the same issue. Doing a google search, a lot of people are getting the error with other apps using webhooks.

comments: author: Steven Jordan
body: I had to convert my payload to a JSON string:

    ConvertTo-Json with -Depth 10

`The above change got the script to post to Teams without error -with one caveat. Every post read, "Teams cannot display this message". ?`

`Modifying adaptive card version from 1.5 to 1.4 fixed that issue. Some formatting still isn't working (e.g., emojis: ???). `

`Another work-around is to set the flow up to post a message (i.e., not an adaptive card). That method didn't work well with JSON format (HTML did work though). Wasted half a day on this nonsense. Now I have to update all my scripts ?. `

Here's an example that should work:

```
# Force TLS 1.2 for the Invoke-RestMethod command
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

# Define your Teams webhook URL
$TeamsWebhookUrl = "https://xxxx.xxxxxx.xxxxx"

# Function to send an alert to Teams
function Send-TeamsAlert {
param (
[string]$Title,
[string]$Description,
[string]$Date,
[string]$ArticleId,
[string]$Link
)

$adaptiveCard = @{
"\$schema" = "http://adaptivecards.io/schemas/adaptive-card.json"
"type" = "AdaptiveCard"
"version" = "1.4"
"body" = @(
@{
"type" = "Image"
"url" = "https://xxxx.xxxxxx.xxxxx/xxxx.jpg"
},
@{
"type" = "TextBlock"
"text" = "Security Advisory:"
"size" = "Large"
"wrap" = $true
"style" = "heading"
},
@{
"type" = "TextBlock"
"text" = "Article Id: $ArticleId"
"wrap" = $true
"size" = "Medium"
"weight" = "Default"
},
@{
"type" = "TextBlock"
"text" = $Title
"wrap" = $true
"spacing" = "Small"
"size" = "Medium"
},
@{
"type" = "TextBlock"
"text" = $Link
"wrap" = $true
}
)
}

$Payload = @{
"type" = "message"
"attachments" = @(
@{
"contentType" = "application/vnd.microsoft.card.adaptive"
"content" = $adaptiveCard
}
)
}

$PayloadJson = $Payload | ConvertTo-Json -Depth 10

# Send the adaptive card to Teams
Invoke-RestMethod -Uri $TeamsWebhookUrl -Method Post -ContentType "application/json" -Body $PayloadJson
}

# Function to test the alert
function Test-TeamsAlert {
Send-TeamsAlert -Title "Test Security Advisory" -Description "This is a test." -Date (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ") -ArticleId "TEST12345" -Link "https://supportportal.juniper.net/s/global-search/%40uri?language=en_US#sort=relevancy&f:ctype=[Security%20Advisories]"
}

# Uncomment below to run test
Test-TeamsAlert
```


author: Aaron Sachs
body: Wow! Thanks y'all for the amazing feedback and responses. I've not had a chance to go through it all yet, but it looks like [@Jesus Cordoba](/t5/user/viewprofilepage/user-id/5423915) 's answer is my first port of call. I'll let y'all know how it goes!


author: Nikhil Khairnar
body: Yes [@Jesus Cordoba](/t5/user/viewprofilepage/user-id/5423915)

Thank you for the JSON. It worked for me, although I had to make a few changes. Thanks for showing the correct way. One thing I'm curious about is the "Post as" title. Why are we unable to alter or edit it? Is there any way or workaround to change it?

![image.png](https://community.atlassian.com/t5/image/serverpage/image-id/336330i393FAD8CF0B6475C/image-size/large?v=v2&px=999 "image.png")


author: Bill Almeda
body: I have the same question with regards to Post as, it is posting as myself. Can that be changed to the reporter of the Jira issue or just as a bot?


Tags: automation

cloud

jira-service-management

jira-service-management-cloud

ms-teams