Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Transition to MS Teams Workflows

Aaron Sachs July 9, 2024

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

But that doesn't seem to work as advertised:

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?

7 answers

2 accepted

3 votes
Answer accepted
Mathias Boer-Mah July 10, 2024

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 

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

 

Jesus Cordoba July 11, 2024

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.

Like # people like this
Nikhil Khairnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 12, 2024

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

Jesus Cordoba July 12, 2024

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

Like # people like this
Nikhil Khairnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 15, 2024

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

Michael Orr
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 15, 2024

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}}

Like # people like this
Jesus Cordoba July 15, 2024

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

******************************

{
"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"
}
]
}
}
]
}

Like Nikhil Khairnar likes this
Nikhil Khairnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 16, 2024

Okay Thanks Jesus . It was a big help 

Jesus Cordoba July 16, 2024

So it's working for you now @Nikhil Khairnar ?

Peter Martens July 17, 2024

Hi @Jesus Cordoba

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?

Jesus Cordoba July 17, 2024

Of course @Peter Martens - 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
}
]
}
}
]
}

Cris Ky
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 17, 2024

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 

Peter Martens July 17, 2024

Hi @Jesus Cordoba ,

 

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

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.

Peter Martens July 18, 2024

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

Peter Martens July 18, 2024

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'.

Peter Martens July 18, 2024

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

Then in teams I created these steps:
picture (2).png
For the message I simply added Dynamic content and chose content here:
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.

Like Ian Walker likes this
0 votes
Answer accepted
Aaron Sachs July 17, 2024

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

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!

2 votes
Britta Neugebauer _yasoon_
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
July 12, 2024

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)

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

Happy Friday!

1 vote
Ryan Haman July 11, 2024

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.

Ryan Haman July 16, 2024

Atlassian created the ticket below. Doesn't sound like a quick fix is expected. 

 [AUTO-1374] Provide support for Microsoft Workflows in automation rules

0 votes
Move Work Forward
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 17, 2024

Guys,

There is another simple way to get notified from Jira, Confluence and Bitbucket in Microsoft Teams channel using Microsoft Teams Workflows app.

Cheers,
Leo

Aaron Sachs July 17, 2024

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

0 votes
Adam Brunt July 16, 2024

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 ?

Aaron Sachs July 17, 2024

Hi @Adam Brunt 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:


CleanShot 2024-07-16 at 22.35.38@2x.png

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

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

0 votes
Ryan Haman July 10, 2024

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

Steven Jordan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 10, 2024

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

 

Like # people like this
Aaron Sachs July 16, 2024

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 's answer is my first port of call. I'll let y'all know how it goes!

Like # people like this
Nikhil Khairnar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 18, 2024

Yes @Jesus Cordoba

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events