How to Trigger an Automation more than once per hour?
Learn to trigger an Automation Studio flow more than once per hour using SSJS and WSProxy. This guide covers refreshing segments and triggering Journeys more frequently, optimizing your Marketing Cloud automations.
In this quick post, I will go through how to trigger an Automation Studio flow more than once per hour. Here are two common use cases:
- Refresh segments: For example, in an enterprise account, populate data extensions in shared folders more frequently so that child Business Units don't have to wait one full hour for updated data.
- Trigger query-powered Journeys more frequently to make them closer to real time
Let's start!
How to trigger an Automation from another Automation?
We will use a script activity in Automation Studio to trigger a second Automation. Before you begin, make sure you think through the questions below, they will help identify if there are other solutions:
- Does your automation actually need to be triggered more frequently? Why?
- If the automation powers a journey that uses CRM data, can the Journey be configured using Salesforce Data instead?
Here's what you will need:
- Identify how long your automation takes to run
- Automation External Key
- Script Activity enabled in Automation Studio. (If you can't see the activity, open a case with Salesforce support to get it enabled)
Ready?
Create a Script Activity to trigger Another Automation
Inside a new automation, or in the Activitites tab of Automation Studio, create a new Script activity with the following code. We will use SSJS and WSProxy to trigger the second automation:
<script runat="server">
Platform.Load('core', '1.1.1');
// We first need to initialize the proxy
var proxy = new Script.Util.WSProxy()
// here we set the automation customer key.
// change the key to the automation you want to trigger when this script runs
var props = { CustomerKey: 'External Key of Your Target Automation' }
var options = {}
// here we ask the proxy to execute the Automation for us, using the action "Start"
var result = proxy.performItem("Automation", props, "Start", options);
// at this point you could log the results to a data extension, but Ive left it blank or check if the action was successfull
</script>
Test the script in a CloudPage and add to a new automation then add the same Script activity multiple times to the automation and add wait times in between so the script gets executed multiple times per hour, which will result in the target automation running multiple times per hour:
Make sure the automation you are triggering has enough time to run before you trigger it again, otherwise you will not get the expected results. Adjust the wait times accordingly. For example, if you have a query that needs to run every 10 minutes and it takes 2 minutes to run, adjust the wait in the automation to something like 7 minutes, then trigger it 6 times.
If your script is failing, check out the post where we go through how to debug and log error messages in Server Side Javascript:
Have any questions, suggestions or feedback? Leave a comment below.
See you on the next post!