How to setup Teams Workflows for Jira Data Center to receive updates on the tickets

65 comments

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2024

@Eric Sebian  Power Automate and flows should be automatically added if you have a license for Office 365 products (i.e. Teams). And you will need some additional PA license in order to use Premium triggers and actions in you flows, but it not the case for this tutorial.

Please follow this instruction and try to sign in to PA - https://learn.microsoft.com/en-us/power-automate/sign-up-sign-in. If your can find your created flow there, you should be good.

One more point that should be checked - the webhook URL from the first step should be encoded as it will not work in Jira (please check Jira logs for the errors. com.atlassian.webhooks should be enabled in Logging and Profiling):

HTTP POST URL should be decoded or all ‘%2F' should be replaced with the '/’, otherwise Jira Webhook will throw 403 error code

The domain for the webhook should be added to the Allow list in order to send data to the webhook. otherwise, it could be blocked.


For what I can see "Flow '' is not installed can happen when the flow is misconfiguration".

- Volodymyr B.

Eric Sebian
Contributor
August 14, 2024

I have power automate. but not premium. see image. image.pngimage.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2024

@Eric Sebian  we are not using PREMIUM actions for this flow, so your license should work properly.

As for the error you can see while trying to run the flow manually - it seems that is related to how Parse Json test run is working, as we should put the test data there (type - "object", attachments - JSON with Jira event). I can see this error as well even with using valid data that should be parsed.

If you are not seeing any data in run history for your flow I can assume the trigger is not working and you have never received any messages to that endpoint. And the reason for that can be - Jira Webhook is not sending data due to wrong URL, as it should be encoded (see my previous comment). Jira is blocking requests to the workflow generated domain (webhook URL domain from "When a Teams webhook request is received").

Regards,
Volodymyr B.

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 14, 2024

To test a flow without Jira you can use Postman and send POST request to the URL generated by the first step:

Screenshot 2024-08-14 at 18.36.19.png

with some test data:

 

{

"timestamp": 1721915955206,

"webhookEvent": "jira:issue_updated",

"issue_event_type_name": "issue_updated",

"user": {

"self": "https://localhost:2990/jira/rest/api/2/user?username=admin",

"name": "admin",

"key": "admin",

"emailAddress": "admin@test.com",

"avatarUrls": {

"48x48": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=48",

"24x24": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=24",

"16x16": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=16",

"32x32": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=32"

},

"displayName": "Admin Admin",

"active": true,

"timeZone": "UTC"

},

"issue": {

"id": "10219",

"self": "https://localhost:2990/jira/rest/api/2/issue/10219",

"key": "T-4",

"fields": {

"issuetype": {

"self": "https://localhost:2990/jira/rest/api/2/issuetype/10002",

"id": "10002",

"description": "A task that needs to be done.",

"iconUrl": "https://localhost:2990/jira/secure/viewavatar?size=xsmall&avatarId=10318&avatarType=issuetype",

"name": "Task",

"subtask": false,

"avatarId": 10318

},

"timespent": null,

"project": {

"self": "https://localhost:2990/jira/rest/api/2/project/10401",

"id": "10401",

"key": "T",

"name": "Test project",

"projectTypeKey": "business",

"avatarUrls": {

"48x48": "https://localhost:2990/jira/secure/projectavatar?avatarId=10324",

"24x24": "https://localhost:2990/jira/secure/projectavatar?size=small&avatarId=10324",

"16x16": "https://localhost:2990/jira/secure/projectavatar?size=xsmall&avatarId=10324",

"32x32": "https://localhost:2990/jira/secure/projectavatar?size=medium&avatarId=10324"

}

},

"priority": {

"self": "https://localhost:2990/jira/rest/api/2/priority/2",

"iconUrl": "https://localhost:2990/jira/images/icons/priorities/high.svg",

"name": "High",

"id": "2"

},

"assignee": {

"self": "https://localhost:2990/jira/rest/api/2/user?username=admin",

"name": "admin",

"key": "admin",

"emailAddress": "admin@test.com",

"avatarUrls": {

"48x48": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=48",

"24x24": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=24",

"16x16": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=16",

"32x32": "https://www.gravatar.com/avatar/dac3582b036e18b911d98494b925c9b7?d=mm&s=32"

},

"displayName": "Admin Admin",

"active": true,

"timeZone": "UTC"

},

"updated": "2024-07-25T13:59:15.201+0000",

"status": {

"self": "https://localhost:2990/jira/rest/api/2/status/10000",

"description": "",

"iconUrl": "https://localhost:2990/jira/",

"name": "To Do",

"id": "10000",

"statusCategory": {

"self": "https://localhost:2990/jira/rest/api/2/statuscategory/2",

"id": 2,

"key": "new",

"colorName": "default",

"name": "To Do"

}

},

"components": [],

"description": "Test description",

"summary": "Test summary",

}

},

"changelog": {

"id": "10442",

"items": [

{

"field": "priority",

"fieldtype": "jira",

"from": "3",

"fromString": "Medium",

"to": "2",

"toString": "High"

}

]

}

}


If the flow works properly there is definitely an issue with Jira webhook configuration that cannot send the request.

- Volodymyr B.

Eric Sebian
Contributor
August 14, 2024

thanks! Seeing a 401 error: 

 

 

Eric Sebian
Contributor
August 14, 2024

image.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

Hi @Eric Sebian 

as far as I can see those endpoints doesn't require any authentication at all. Please check Authorization tab in your Postman as it can take some auth headers from previous requests you have done (at least on your screenshot there is some data).

Regards,
Volodymyr B.

Eric Sebian
Contributor
August 15, 2024

you were right. But even after clearing it, it still fails. 

image.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

@Eric Sebian , please select No Auth from the drop down as it still using empty credentials
Screenshot 2024-08-15 at 17.06.21.png

Eric Sebian
Contributor
August 15, 2024

Hi. Getting closer. That did the trick. Though the teams was never updated and I got this error: 

 

image.png

 

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

@Eric Sebian  on the latest screenshot I can see the different set of steps from what you have shared before and it doesn't much the steps from the guide above. Please follow the guide and add the exact steps as:

Screenshot 2024-08-15 at 19.01.41.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 15, 2024

@Eric Sebian on the latest screenshot I can the the different set of steps than was provided in the guide. Please follow the guide and fill in all the required fields. In the end you should receive the flow like:

Screenshot 2024-08-15 at 19.01.41.png

Eric Sebian
Contributor
August 15, 2024

I did that, but unfortunately, it stops connecting all together. 

image.pngimage.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2024

Hi @Eric Sebian 

Please make sure you are sending exactly the same POST requests with test data as in my previous comments to test the flow. The error "Unable to process template..." can happen only if you send POST request with no data:

Screenshot 2024-08-16 at 11.39.21.png

Regards,
Volodymyr B.

Eric Sebian
Contributor
August 16, 2024

Even with the body submitted, it still fails. 

image.pngimage.png

Roberto Ialino
Contributor
August 16, 2024

 -

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 16, 2024

Hi @Eric Sebian 

you are using one of the predefined flows in Power Automate, not the one described in the guide. We are sending JSON to the flow that is expecting Adaptive card. The failure  can send in the latest comment is expected.

The flow, you can perform Postman test against, is: "When a Teams webhook request is received" -> "Parse JSON" -> "Post card in a chat or channel". If you send post request to such flow, you should receive a card in defined Teams channel:

Screenshot 2024-08-16 at 17.55.28.png

Regards,
Volodymyr B.

Eric Sebian
Contributor
August 16, 2024

I finally got it to work with postman!! So that tells me that the workflow/webhook works. How do I apply that to jira? image.pngimage.png

Eric Sebian
Contributor
August 16, 2024

When I plug the same webhook into jira, there is no connection at all. Doesn't show in the run history. Do I need to white list the power automate url (https://make.powerautomate.com/)? image.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 19, 2024

Hi @Eric Sebian 

If the workflow is working (confirmed above) and you are not receiving any updates from configured Jira DC webhook please try to do next steps:

- the webhook URL from the first step ("When a Teams webhook request is received") should be decoded as it will not work in Jira (please check Jira logs for the errors. com.atlassian.webhooks should be enabled in Logging and Profiling)
- please add the webhook URL from the first step ("When a Teams webhook request is received") to the allow list in your Jira DC, so Jira can send data to that URL, i.e. prod-24.westus.logic.azure.com or *.westus.logic.azure.com.

from the guide:

HTTP POST URL should be decoded or all ‘%2F' should be replaced with the '/’, otherwise Jira Webhook will throw 403 error code

The domain for the webhook should be added to the Allow list in order to send data to the webhook. otherwise, it could be blocked.

Eric Sebian
Contributor
August 19, 2024

Good to know! One last question (hopefully). When setting up domain for the allow list, should it be a wildcard expression? 

image.png

Eric Sebian
Contributor
August 19, 2024

I tried them all and Domain was the correct selection. I'm now seeing the comments go into the teams channel! I just need to figure out why the status "In Progress" when that's not the status. Thanks again for all of your help!! you are the best. image.png

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2024

Hi @Eric Sebian 

Glad to hear that you were able to configure workflows and now you are receiving updates in your Teams channel.
If you are going to have Jira notifications in few Teams channels and you need to create separate workflow for each channel. In that case you'll receive unique webhook URLs from the first step. So it so it is better to add to allow list a wildcard record (i.e. *.westus.logic.azure.com).

Also, please keep in mind that Teams workflows can have limitations on number of processed events per day per user - https://learn.microsoft.com/en-us/power-platform/admin/api-request-limits-allocations . So our recommendation is to apply JQL on Jira webhook to listen to only issues from specific projects.

Regards,
Volodymyr B. 

Eric Sebian
Contributor
August 20, 2024

Will do! I'm almost there! can you tell me 2 things? 1. Why am I getting 2 run histories, and one of them errors, everytime the flow is triggered by the jira webhook: image.png

 

And the 2nd question is: Why am I getting the incorrect status showing in the card? Is it hard coded in the code somewhere? I look for a reference to status in the JSON code but couldn't find anything. 

image.png

 

I'm hoping that, once this is fixed, we'll be done!! Thanks again!! ejs

Volodymyr Batrukh
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
August 20, 2024

Hi @Eric Sebian 

For the Question #1:
From the it seems that Jira Webhook is sending two events (maybe just when comment is added) and the second one has a totally different schema...Regularly Jira webhook should send just one event having the same format all the time. Is it possible that you have some custom configuration or app installed that can send another event? You can try to reach Atlassian support to investigate this issue - https://support.atlassian.com/contact/.

Another option you can try - modify workflow a bit and add conditions to send the card only if the trigger body has expected format:

Screenshot 2024-08-20 at 17.00.07.png

 - add new step "Condition" after Parse JSON step
 - drag and drop last step to the True section under condition
 - select condition and set next options
    - body('Parse_JSON')['issue'] IS NOT EQUAL TO  (EMPTY_VALUE)
    - body('Parse_JSON')['user'] IS NOT EQUAL TO  (EMPTY_VALUE)

In the end you should receive similar condition as above ^^.  Please note that in that case the workflow will be triggered for both event coming from Jira, but only one of the will send the card to the channel. The second one will be executed successfully, but will do nothing. 

For the Question #2:

The status is taken from the webhook event. Please check one of the Successful run and check what value is coming under Parse JSON -> INPUTS -> status -> status category -> name. This values is taken and displayed on UI (value is not hardcoded):

Screenshot 2024-08-20 at 16.37.19.png


UPD for Question #1:

Jira is sending two events when comment is created
 1) "webhookEvent": "jira:issue_updated",  "issue_event_type_name": "issue_commented"
2) "webhookEvent": "comment_created"

The second one will fail as we are using the schema for the first event types only. To fix it we can add condition after Parse JSON to not process the second type of events

"body('Parse_JSON')['webhookEvent']" Is not equal to "comment_created" and send card only if that condition is met:

Screenshot 2024-08-21 at 12.24.15.png

Regards,
Volodymyr B.

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events