Automation rule lookup: send one single message to Slack with a list of pages

Eloá
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!
October 18, 2024

I have an automation that notifies people about pages that haven't been updated in 6 months and don't have the "deprecated" label. 
The automation works, however, it sends one message per page returned (several messages) instead of sending one single message with the list of pages returned. 

If I add the action "Then: Send Slack message" inside the Branch, the automation works but I receive several messages in the Slack channel.
 

Screenshot 2024-10-18 at 14.53.24.png

 

If I add the action "Then: Send Slack message" outside the Branch , I receive an empty message (my idea of using the variable doesn't work outside the branch).

Screenshot 2024-10-18 at 15.27.10.png

How can I solve this issue?

Here's the complete automation:

1. Trigger: Scheduled

2. Action: Lookup Pages (Last updated more than 6 months ago)

3. Action: Create Variable Variable Name: pageList ( empty)

4. Branch: For Each (Smart Value) Smart Value: {{lookupPages}} Variable Name: page

5. If Condition First Value: {{page.labels.join(",")}} Condition: Does not contain Second Value: deprecated

6. Action: Create Variable (to edit the previous variable) Variable Name: pageList Value: {{#if(pageList)}}{{pageList.concat("\n")}}{{/}}{{page.title}} at {{page.url}} Last updated on: {{page.dateLastUpdated.shortDate}}, Author: {{page.author.fullName}}

7. Action: Send Slack Message The following pages have not been updated in the last 6 months and do not have the "deprecated" label: {{pageList.concat("\n")}}

1 answer

1 accepted

2 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.
October 18, 2024

Hi @Eloá -- Welcome to the Atlassian Community!

To send one single message rather than one message per page, try removing the branch:

  • trigger: scheduled, with no CQL in the trigger
  • action: lookup pages with CQL, including checking for your deprecation information to exclude them
  • action: send the Slack message, iterating over the {{lookupPages}} smart value

 

If you instead wanted to send one message to each author with their list of pages, you could use a variation of that which branches over the distinct authors.  Please see this article which uses a similar technique to send one email per assignee: https://confluence.atlassian.com/jirakb/automation-to-send-email-only-once-per-assignee-1310985609.html

 

Kind regards,
Bill

Isis Bertini October 21, 2024

Hi, @Bill Sheboy

Thank you for your quick response!

How can I use the "Lookup pages" action with CQL? In Confluence automation, the "Lookup pages" action only provides three predefined criteria to choose from (Last updated, Author, and Created), and it doesn't seem to offer the option to include custom CQL queries.

Screenshot 2024-10-21 at 14.28.01.png

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.
October 21, 2024

Sorry, I do not currently have Confluence automation in my instance, and so I remembered it incorrectly.  Please try using Lookup CQL Results instead:

https://support.atlassian.com/cloud-automation/docs/actions-in-confluence-automation/#Lookup-actions

Like Isis Bertini likes this
Isis Bertini October 22, 2024

Thank you @Bill Sheboy, it worked. 

Like Bill Sheboy likes this
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.
October 22, 2024

Awesome; I am glad to learn it is working!  Please consider marking this question as "answered" to help others with a similar need find solutions faster.  Thanks!

Jeremiah Rappley November 12, 2024

Hi Isis and Bill,

I'm working on a request to configure a rule similar to this, but I don't see an option in Confluence Automation to lookup pages using CQL. The only options that I have under the Lookup Pages component are Author, Created, and Last updated.

Would you be able to share a screenshot or more details about the configuration you're using to lookup pages using CQL?

Thanks in advance!

Screenshot 2024-11-12 at 15.20.10.png

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.
November 12, 2024

Hi @Jeremiah Rappley -- Welcome to the Atlassian Community!

My mistake as I am currently not using Confluence automation rules: one may trigger or branch on CQL to Confluence pages but not use Lookup Pages with CQL.

As a workaround you could call the REST API content search with CQL and the Send Web Request action. 

Here is the content search endpoint: https://developer.atlassian.com/cloud/confluence/rest/v1/api-group-search/#api-wiki-rest-api-search-get

And here is a how-to article for calling a REST API with Send Web Request: https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events