Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create weekly summary automation to Slack?

Hadar Dinte February 26, 2023

Hello,

I created an automation that send a notification to slack when the issue passed the Due date or is near the Due date. 

Now, I want to add a weekly report that calculates the number of issues that: passed the due date, near the due date, opened or closed in the previous week. 

I want to send the Email/slack message like this: 

Number of issues that Opened this week: X (number)
Number of issues that Done/Closed this week: X (number)
Number of issues near the due date: X (number)
Number of issues that passed the due date for now: X (number)

I would like to get any help if somebody know how to create automation for that

Thanks

3 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
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.
February 26, 2023

Hi @Hadar Dinte 

What have you tried thus far to solve this?  Using automation rules often requires learning and experimentation, so the documentation and examples in the template library can help.

If you have not started yet, I suggest using the Lookup Issues action with JQL to capture the issues for each of your measures.  Then save the count results using Create Variable actions, where each count would be {{lookupIssues.size|0}}

Then you could report all of the measures in your message by referencing the created variables.

Kind regards,
Bill

Hadar Dinte February 27, 2023

Hi Bill, Thank you very much! it's work.

The only problem I have is that I get a number of messages to Slack according to the first action that I did in the rule.

For example, if the rule found 3 issues that created last week, so I will get 3 messages.  

I would be happy to know if do you have any idea why it's happening, and how to solve it?

 

WhatsApp Image 2023-02-27 at 12.11.58.jpeg

Bill Sheboy
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.
February 27, 2023

I suspect the cause is you are using a Scheduled Trigger with JQL, which then runs for each issue found.  The fix is to remove the JQL from the trigger.

For example:

  • trigger: scheduled with no JQL
  • action: Lookup Issues with JQL for issues created
  • action: create a variable to save your issues created count
  • and so on for the other counts...
  • action: send Slack message 

If that does not help, please post images of your complete rule and the audit log details showing the execution.  Those will provide context to help explain the symptoms.

Hadar Dinte February 28, 2023

I can't run the rule without JQL

WhatsApp Image 2023-02-28 at 10.18.55.jpeg

Bill Sheboy
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.
February 28, 2023

Please post an image of your entire rule, as I believe that will show you are referencing issue fields and not just the created variables or the lookup issues results.

Hadar Dinte March 2, 2023

I dont know if it's elegant work, but I wrote a Query in the JQL tab that the result of this query is 1 issue - so in the end I got only 1 message of the summary. 

WhatsApp Image 2023-03-02 at 10.34.22.jpeg

Hadar Dinte March 2, 2023

Another question I have is,

If there is a way to make the smart value in the slack message hyperlink? Because I need that the hyperlink will lead to a list of the issues, and not only for one ticket

Bill Sheboy
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.
March 2, 2023

Until you post the image of your entire rule, I don't know how to answer the questions you are asking about the errors.

Hadar Dinte March 4, 2023

Ok,

Here are the images of my rule 

Thank you! 

WhatsApp Image 2023-03-05 at 08.47.33.jpegWhatsApp Image 2023-03-05 at 08.49.15.jpeg

Bill Sheboy
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.
March 5, 2023

Thanks for that information. 

When posting an image of long rules, I recommend using a browser extension (or app) which can capture a complete, scrolling browser tab view.

Back to the error you observed, the cause is because the rule is referencing an issue's fields in the condition test on Issue Type.  That condition is not needed for the scenario you described. 

Instead you can do this, as I suggested earlier:

  • trigger: scheduled with no JQL
  • action: Lookup Issues with JQL for issues created.  For example...
    • project = BA AND issueType = Security AND created >= startOfWeek(-7d)
  • action: create a variable to save your issues created count.  For example...
    • variable name: varIssuesCreated
    • smart value: {{lookupIssues.size|0}}
  • and so on for the other counts...
  • action: send Slack message, referencing the Created Variables.  For example...
    • the number of issues opened this week: {{varIssuesCreated}}
    • and so on for the other counts...

Please note there is no JQL for the trigger.  All of the issue information comes from the Lookup Issues actions.

Hadar Dinte March 6, 2023

Thank you, it works.

Now, I would like that the numbers that I get in the Slack message will be hyperlink, and will lead to the list of the issues. 

I tried to add the world URL to the new smart value in the slack message, for example: <{{issuecreated.url}}> but it is not work

Can you help me with that, please?

Bill Sheboy
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.
March 6, 2023

Created variables are text, and so there are no other attributes, such as url.

I can think of two ways to do what you ask with a link to the issues...

a) Add links for each issue in the lookup after the number, with

{{#lookupIssues}}{{url}}{{^last}} ; {{/}}{{/}}

 

b) Use HTML formatting and encoding in your Slack message, and make a link for the number as a reference to a JQL search of the issues. For example,

<a href="https://yourJiraURL/issues/?jql=JQL from the lookup">{{varIssuesCreated}</a>

This can also be made dynamic if the JQL and URL values are stored in variables and combined later.

Hadar Dinte March 7, 2023

Thank you @Bill Sheboy 

I didn't succeed with the first option.

For now, I passed the Query's URL to the slack message. Unfurtantelly it's not elegant work, but its work

Screenshot 2023-03-07 at 11.24.57 AM.pngScreenshot 2023-03-07 at 11.19.17 AM.png

Hadar Dinte March 21, 2023

Hey @Bill Sheboy ,

According to this automation, Could it be that the {{lookup issues.size}} don't know how to count more than 100 issues?

Thanks,

Hadar

Bill Sheboy
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.
March 21, 2023

That is correct: the lookup issues action has a limit of 100 issues.

Hadar Dinte March 22, 2023

Thank you 

1 vote
Maria Makarova
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!
November 28, 2023

Hey @Hadar Dinte 

I stumbled upon one thing that might help with the weekly report. I had a similar setup with Slack notifications for due dates, and I found this for JIRA and Slack integration. It works as a pre-made solution that you just use in your environment: https://www.getlazy.ai/templates/jira-weekly-done-issues-to-slack-fc1657c7-1588-47ef-a48e-249d846db7a8 (sorry for the link, hope it's allowed here)

They have a guide there, it walks you through setting up the JIRA and Slack connection, and it automatically fetches closed tickets and posts them to Slack every week. For me it was super handy for generating those weekly reports without much hassle.

Hope that works for you too

0 votes
Tuncay Senturk
Community Champion
February 26, 2023

Hi @Hadar Dinte 

To create an automation that sends a weekly report

1. Create a new Jira automation rule and select the trigger "Scheduled", and set the trigger to run once a week on a day you prefer.

2. Add the action "Jira: JQL Search" to the rule. In the search query, you can use JQL to search for issues

Below I am sharing some of the alternative JQLs that you can use to filter issues and get the count:

  • Number of issues that Opened this week: X (number)

    created >= startOfWeek() - 7d AND created < startOfWeek()
  • Number of issues that Done/Closed this week: X (number)

    status changed to Closed during (startOfWeek() - 7d, startOfWeek())   

     you can use OR to add more statuses or use resolution field instead
  • Number of issues near the due date: X (number)

    duedate >= startOfDay() AND duedate <= startOfDay() + 2d

    (assuming 2d is enough)
  • Number of issues that passed the due date for now: X (number)

    duedate <= startOfDay() AND status not in (closed, resolved)

     

3. Add the action "Send a Slack message" to the rule, and format the message using the results of the JQL search.

 

Here is the sample yaml code

Number of issues that Opened this week: {{#=}}{{searchResults.created}}{{/}}
Number of issues that Done/Closed this week: {{#=}}{{searchResults.status changed}}{{/}}
Number of issues near the due date: {{#=}}{{searchResults.duedate <= startOfDay() + 2d}}{{/}}
Number of issues that passed the due date for now: {{#=}}{{searchResults.duedate <= startOfDay()}}{{/}}

 

I hope this helps

Hadar Dinte February 26, 2023

Hi Tuncay, Thank you very much.

Do I need to enter the yaml code in the message of the "Send a Slack message" action?

And I didn't understand how the yaml code know which data he need to take? 

Hadar Dinte February 26, 2023

About the JQL's, I already have some of them, but I get the list of the issues and I need the sum (number) of them

Tuncay Senturk
Community Champion
February 26, 2023

Please check this link. Then check Smart values to have a better understanding.

Like Hadar Dinte likes this
Hadar Dinte February 27, 2023

Thank you 

Suggest an answer

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

Atlassian Community Events