Forums

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

Trigger a Confluence Cloud Automation Rule from another rule? (e.g. for CQL sub-branches hack)

Christoph Schötz April 17, 2025

In the Confluence Cloud Automation Rule Details, there is a checkbox "Check to allow other rule actions to trigger this rule. Only enable this if you need this rule to execute in response to another rule." at the very bottom (see screenshot below). Is there a way to trigger a specific Confluence Cloud Automation Rule from another rule?

Screenshot 2025-04-18 062740.png

Background why I want to do this: There are no CQL sub-queries in Confluence and e.g. ancestor and parent only accept specific page ids (no "~" to take pages with a title containing some string). I want to build an automation which checks for pages with a parent with some title and then again for pages having one of the search results as an ancestor. In Confluence Cloud Automation, I can use the "Branch rule / related entities" branch to execute CQL, but in this branch, I can't execute a "sub-branch" using the previous CQL search results in another CQL.

 

Please take a look at my example screenshot below: First, I want to get all pages which have "Ongoing" in its title. Then I want to get the pages with "Project Landingpage" in its title which have one of this "Ongoing" pages as a parent. Afterwards, I want to check for all the pages below each "Project Landingpage" page when they have been last modified to decide if an automation should execute some action, e.g. send an email to somebody (e.g. the page owner of the respective "Project Landingpage ..."). Now let's say we have around 100 categories and below each, there is a page tree like below Category A, with 0 to 20 "Project Landingpage ..." pages below the "Ongoing - Category ..." page. The check for last modified should be executed for all of the pages below these "Project Landingpage ..." pages, but not for the pages below "Project Landingpage ..." pages which might be already below "Closed - Category ..." pages (as the work on them is already completed but they should still be kept for documentation and reference).

Screenshot 2025-04-18 065000.png

 

2 answers

1 accepted

0 votes
Answer accepted
Christoph Schötz April 19, 2025

Thanks to @Bill Sheboy 's hint with the Send Web Request action, I was able to find a solution myself. I will post it here hoping it might be useful for others as well.

Here is my solution:

1. Set up a first rule to look for pages with "Ongoing" contained in the title and trigger a second rule for each of the search results

The rule should look like this:

Screenshot 2025-04-19 083549.png

The CQL for "Branch rule / related entities" is: title ~ "Ongoing" and type = page

The configuration details for Send web request are shown below:

Screenshot 2025-04-19 083941.png

To get the correct Web request URL and the custom data, you have to setup the start of the second rule already (I will describe this below). So first, let's finish the Headers configuration here:

Authorization: Following the great tutorial by Brad Evans here - don't forget to write "Basic " before the result of your PowerShell Base64 encoding, especially if you click the "Hidden" checkbox and come back later to update it ;)

Content-Type: application/json

2. Set up a "Manually triggered" rule to iterate over the previous search results and decide if actions are necessary

Create a second rule with "When: Manually triggered" which can then use CQL in another "Branch rule / related entities". Don't worry too much about the Branch details for now as we first want to get the configuration of the first rule done and for this we mainly need the "When: Manually triggered", any action and the configuration, that the rule can be triggered by other rule actions as shown in the second screenshot below.

Screenshot 2025-04-19 085445.png

Very important: Allow this second rule in the Rule details to be triggered by another rule (see screenshot below).

Screenshot 2025-04-18 062740.png

Then (after clicking Update to save the rule configuration and enable it), go to a page in the space you configured your automations for and use the "..." menu as shown in the screenshot below to trigger the automation manually using the "Automate" action:

Screenshot 2025-04-19 091217.png

 

 

Open the developer tools (for your Browser, Chrome in my screenshot on the right side) and go to the Network tab. Then select the rule you configured in the Page automations pop-up on the left side and click on Automate to start it. Hint: it is a good idea to clear the developer tools data before to spot your rule easier.

Screenshot 2025-04-19 091518.png

Search for the rule ID in the developer tools in the Network tab as shown below (you find the rule ID when you hover over your rule in the Automation - Rules overview), click on it and copy the Request URL in the Headers tab as shown below:

Screenshot 2025-04-19 091858.png

This is the "Web request URL" rule 1 should send the web request to, so open the rule 1 config and paste it there so that it looks like in the screenshots above for rule 1.

Then go to the Payload tab in the developer tools, right click on the Request Payload and click on "Copy value" as shown in the screenshot below.

Screenshot 2025-04-19 091951.png

This is the "Custom data" rule 1 should send the web request with, so open the rule 1 config and paste it there so that it looks like in the screenshots above for rule 1. Then edit the page ID at the end of the "Custom data" to be "{{cqlResult.id}}" so that it sends the page ID of the respective CQL result instead of the static page ID you just triggered it manually for (see the screenshots for rule 1 above).

If you saved and did everything correctly so far, you should be able to run rule 1 successfully triggering rule 2 in case your CQL returns any results.

The rest of the solution

As the answer already is pretty long, I will now focus on the core aspects of the rest of the solution.

In rule 2, we use the same concept as in rule 1 to trigger a rule 3 and 4 which looks like rule 2 (manually triggered). Example CQL: parent = {{page.id}} and title ~ "Project Landingpage" and lastmodified < startOfDay("-56d")

The key idea here for rule 3 and 4 is that we use "Branch rule / related entities" to run a CQL and if the result is empty (meaning no pages are found which were modified in the given time range), we do some action. To check this, we use the "{{smart values}} condition" as shown in the screenshot below comparing "{{cqlResults}}" to empty (just leaving the second value empty and using "equals" to compare).

Screenshot 2025-04-19 094627.png

This way, I achieved to implement my original approach described in my question above. Please let me know in case of any further questions or if you need more details. And thanks again for the idea to use Send Web Request @Bill Sheboy!

Best regards

Christoph 

 

 

2 votes
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.
April 18, 2025

Hi @Christoph Schötz 

Short answer: I do not believe your scenario can be solved with automation rules, although it might be possible using the REST API endpoints and called from a custom application with better looping options.  You may want to investigate if there are marketplace apps to help manage / query pages this way.

 

For more information...

You are correct that branches cannot be nested yet.  There are some open suggestions to add this capability.  Some workarounds for such situations are:

  • "Flatten" the outer and inner search requests using the REST API and the Send Web Request action to gather the page list, and then use an Advanced Branch to iterate.  One big challenge with this approach is once inside of the Advanced Branch, there is only "data" and no concept of objects like Pages...preventing the use of the built-in actions.  Thus, the REST API must be used for all remaining read / update needs.  Another challenge is the processing limit for branching, which it seems you might exceed.
  • Use a primary rule for the "outer" loop and call another rule using the Incoming Webhook trigger (called via the Send Web Request action).  This would not work for your scenario because it would likely hit the 10 loop detection limit, halting the rule.  And even if it did, such calls with Send Web Request to other rules do not return results at this time.  (There is another open suggestion to add that feature.)

 

Even if the nested branching was possible, I do not believe "Last Modified" (or createdAt for a version) is available unless an individual page is read with the endpoints.  This will lead to the rule needing to read each individual page for your scenario.

 

Kind regards,
Bill

Christoph Schötz April 18, 2025

Hi @Bill Sheboy

Thanks a lot for your fast and detailed reply!

The Send Web Request action suggestion was a great one, I am happy to report that I just were able to use it to implement my original idea. I will post my solution as an answer to my question right after I replied to you.

As you are speaking of "open suggestions to add this capability" above: is there any quick and reliable way to find all open suggestions related to Confluence Automation, so that I could vote on them?

Thanks a lot again and in advance for your support and keep being amazingly helpful, you rock!

Best regards,

Christoph

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.
April 19, 2025

Well done solving this, particularly the part of using the Send Web Request action to trigger the manual rule!  I recommend monitoring that one to ensure it does not trip the 10 loop limit due to repeated calls from the Scheduled Trigger rule.

 

Regarding open suggestions and defects, you may search the public backlog for those...such as checking the Automation and Confluence Cloud projects:

https://jira.atlassian.com/issues/?jql=(project%20%3D%20%22Automation%20for%20Cloud%22%20OR%20(project%20%3D%20%22Confluence%20Cloud%22%20AND%20summary%20~%20%22automation%22))%20AND%20resolution%20%3D%20Unresolved%20ORDER%20BY%20Created%20ASC

Please add additional criteria if you want to narrow the search by Summary, Description, etc.

 

Christoph Schötz April 21, 2025

Thanks a lot for your feedback and your hints @Bill Sheboy and will do!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events