This post shows how to nest rules and steps in PRO Rules, the rules of PRO Rules Client and PRO Rules Server. It is written for version 4.0.
You don’t need nesting for most jobs. One rule with its conditions, its save folder and a few steps does the work. Nesting helps in advanced cases, such as:
- When no rule saved anything from an email, do something else with it, such as moving it to a folder you check by hand.
- When the attachments of one email each need different handling.
- When many rules share the same conditions or the same steps, and you don’t want to type them again in each rule.
- When a step should work on the result of another step: the files of a zip, or a converted PDF.
New to PRO Rules? Read save emails and attachments to folders first. It walks through a whole rule. In version 3.x the PRO Rules tab was called Global filters.
In this post
The tool in this guide: Mail Attachment Downloader PRO RulesSee PRO Rules
Nesting rules: the four rule types
Each entry in the PRO Rules tab has a Rule type. You pick it with the arrow next to New rule…, or later with Rule type: in the rule’s Save part.
- Global rule: the usual rule. It saves what matches its conditions, then runs its steps.
- Shared filter: only conditions. It saves nothing and runs no steps of its own. Other rules use its conditions, and they show under it in the list.
- Negative rule: steps for the emails nothing saved. It saves nothing: its steps run for the emails no rule saved anything from.
- Shared action: steps that other rules run. It saves nothing, and its steps run when another rule runs it.
Shared actions are always listed first. The rules and shared filters below them run in the order of the list, and the rules under a shared filter run right after it.

Example: one shared filter, three rules and a shared action
Say Acme, Northwind and Fabrikam send emails with “Invoice ID” in the subject. You want to:
- save their PDF attachments to
\\fileserver\Finance\Invoices\PDF, - save their Word attachments to
\\fileserver\Finance\Invoices\Word, - move an email with neither to an “Issues” folder of the mailbox,
- and record the email’s details in a database for each saved file.
Turn PRO Rules on first: tick Use PRO Rules for every account at the top of the PRO Rules tab.
1. The shared filter
Click the arrow next to New rule… and pick Shared filter – filters only, no actions. Name it “Invoice ID emails”. Click Add a condition, choose Subject and type 'Invoice ID'. Click Save.
The shared filter decides which emails the rules under it see. It saves nothing by itself.
2. A rule under it for the PDFs
Open the shared filter’s menu (its + button, or right-click it) and choose Add a rule under this shared filter › Global rule – filters and actions. The new rule gets a Use a shared filter condition for “Invoice ID emails”, so it only runs for the emails that filter matches.
- Name it “Invoice PDFs”.
- Add an Attachment name condition with
'.pdf', so only PDF files match. - In Save, pick The attachments and set the Save folder to
\\fileserver\Finance\Invoices\PDF. - Under Then, click Add a step… and add Mark as read. You could add Move or copy the email instead.
3. A second rule for the Word files
Do the same again: Add a rule under this shared filter › Global rule – filters and actions. Name it “Invoice Word files”, use '.doc' (it also matches .docx) in the Attachment name condition, and save to \\fileserver\Finance\Invoices\Word.
The PRO Rules tab now shows the shared filter as 1, with the two rules under it as 1.1 and 1.2.
4. A negative rule as the catch-all
From the shared filter’s menu, choose Add a rule under this shared filter › Negative rule. Name it “Invoice ID emails with no files”. A negative rule saves nothing, so you only give it steps.
Under Then, add Move or copy the email and pick the “Issues” folder of the mailbox. Now an “Invoice ID” email from which no rule saved anything is moved there for you to look at.
5. A shared action for the database
Click the arrow next to New rule… and pick Shared action. Name it “Save email details to the database”. Under Then, add Save to a database and set it up. See save emails and attachments to a database; we won’t repeat that here. Save to a database needs PRO Rules Server. With PRO Rules Client, use a step such as Upload to cloud or Copy file in the shared action instead.
Now let the two rules run it. Select “Invoice PDFs” and “Invoice Word files” in the list, then choose Rule settings › Shared filters and actions › Add ‘Shared action’ to selected, and pick the shared action. Another way: open the shared action’s menu and use Make a rule run it.
Each rule now has a Run another rule step under Then. It runs the shared action’s steps there, for the same email and file. You can also add that step yourself with Add a step….
What you have
- The shared filter picks the emails with “Invoice ID” in the subject.
- Its two rules save the PDF and Word attachments to their own folders, mark the email as read, and run the shared action.
- The shared action records the email’s details in the database for each saved file.
- The negative rule moves an “Invoice ID” email to “Issues” when no rule saved anything from it.
Before the first real run, click Rule settings › Test all rules…. It runs the rules that are on, on emails you pick, and shows which rule saves each file. Nothing is changed: files go to a temporary folder, and moving, marking as read and other outside steps are only described.

Nesting steps: steps inside steps
Steps under Then run in order, from the top. A step can also hold steps of its own. The steps inside it work on its result: the files of a zip, the PDF a conversion made, the fields an AI found.
Steps that can hold steps include Unzip, Convert documents, Make PDFs searchable (OCR), Find fields with AI, Copy file, Upload to cloud, Save to a database and Web hook.
To put a step inside another one:
- In the Rule Editor’s outline, select the step that should hold it, for example Unzip.
- Click Add a step….
- In the Add it: box, choose Inside “Unzip”. The other choices are after the selected step, At the end of Then and At the end of If something fails.
- Pick the step and click Add.
To move a step, drag its row: drop it between two rows, or on a group, If a field… or For files named… to put it inside. Move up (Alt+Up) and Move down (Alt+Down) work too.

In the picture, Make PDFs searchable (OCR) reads each scanned PDF. Find fields with AI, inside it, reads the searchable PDF and fills {INVOICE_NUMBER}, {DUE_DATE} and {TOTAL_INCLUDING_TAX}. The four steps inside that use those fields. Move or copy the email is back at the top level of Then, after the OCR step and everything inside it.
Another example: Unzip a zip of invoices, then Convert documents inside it to make a PDF of each file, then Save to a database and Run a command line inside that. See unzip, convert to PDF and run a script for that one, step by step. OCR, Unzip, databases, web hooks and command lines need PRO Rules Server.
Decide inside a rule
The Decide and repeat kind of steps in Add a step… lets part of a rule run only sometimes, while the rest goes on as usual:
- If a field… runs the steps under it only when a field is empty, not empty, or matches. For example, upload only when an invoice number was found.
- For files named… runs the steps under it for the saved files whose names match, such as only the PDFs.
- Group of steps keeps steps together, in order.
- Run another rule runs a shared action’s steps here.
When the files go to the same folder and only their steps differ, For files named… can replace a shared filter with two rules: one rule saves the attachments, then runs one set of steps for the PDFs and another for the Word files.

If something fails
Below Then, each rule has If something fails. Its steps run when a step above fails. Use the {ERROR_MESSAGE} field to say what went wrong.
- With PRO Rules Client: Move or copy the email, Delete the email or Mark as read.
- With PRO Rules Server, also: Send an email, Send notification, the database steps, Run a script and Run a command line.
New in 4.0: a step that fails is tried again by itself, after a wait, and a failed step holds back the steps below it until it works. By default the steps under If something fails run once the program has given up on the step. Change that, and the number of tries, in Settings › Retries, or for one rule with the Retries… button in its Save part.
Points to remember
- Rules run from the top of the list. The first rule that matches a file saves it, and the rules below it don’t see that file.
- Shared filters, negative rules and shared actions save nothing. Only global rules save files.
- Test with Test this rule… in the Rule Editor, or Test all rules…, before you rely on a rule.
Related
- Chained rules and actions
- Conditions inside a rule: If a field…, For files named…
- Save emails and attachments to folders with PRO Rules
- Rule order, the catch-all rule, and turning rules on and off
- Why did my rule not download the attachment or email?
- PRO Rules
Questions or suggestions about this post? Contact us.