Lesson 5: Add a Filter Step
In many situations, you may need to condense your data and only extract and analyze relevant pieces. To do this, you can use filter steps to search for content that meets the conditions you specify, and remove any content you don’t need in the scope of your workflow.
In this lesson, we’ll teach you how to enhance your Welcome Workflow with a simple filter query. Before you begin, check that your Welcome Workflow’s decision step is an automated one. If you need a refresher for configuring automated decisions, go back and read the instructions in Lesson 5: Use Decision Steps.
Add a Filter Step to Your Welcome Workflow
To add a filter step to your Welcome Workflow:
- Open your Welcome Workflow in the Workflow Builder, and view the Upublished Changes. If there are no unpublished changes, simply edit the workflow.
- Click on the + button right after the trigger.
- Select Filter for the step type.
- Name the filter “Filter for TLD.” (TLD stands for “Top-Level Domain”).
- Select Only continue if.. for the “Filter Type.”
- In the “Filter by Query” field, click on the blue + button and choose the Welcome Trigger.domain trigger variable you created in a previous lesson. After the variable populates in the field, enter
ends_with “.com"after the variable.
- Click the Continue button to finish configuring the filter step.
- Test the workflow with the string
battle.netas the input. To do so, click on the Test button in the upper-right corner of the workflow builder and enter
battle.netwhen prompted. Then click the Test Workflow button.
- Verify that the test job details has two cards in the All Outputs tab. The last card you should see is the “Filter for TLD” step.
- Test the workflow again, this time with
rapid7.com. When the test job completes, observe the the All Output cards, and take a look at any Artifacts created by your workflow.
Congratulations! You learned how to control workflow executions by filtering content.
In this lesson, you added a basic filter step to check if the input email was from the “.com” top-level domain or not. The filter type “Only continue if…” executes the rest of the workflow steps only if the filter conditions are met. When you tested the workflow with the “battle.net” address, the input’s domain (“.net) and the domain you set in the filter query (“.com”) didn’t match, so the filter step stopped the workflow from running as soon as the mismatch was found.
Conversely, when you tested the workflow with
rapid7.com, the last few characters in the input matched the condition in the filter step, and the filter step allowed the workflow to continue running. The rest of the steps should have behaved exactly like they did in Lesson 5.
How do filter steps work?
Filter steps work by seeking true or false (boolean) responses to queries. You’ll build these queries to suit your needs using the InsightConnect query language. You already used this query language in Lesson 5, when you created an Automated Decision.
This lesson only covered a string matching query on a single string, but you can build queries to check JSON objects or arrays full of data.