Skip to main content
All CollectionsWorkflows
Mastering Rules in Workflows
Mastering Rules in Workflows

Automate Smarter: Enhance Triple Whale's Workflows with Powerful Rules

Chaim Davies avatar
Written by Chaim Davies
Updated over a month ago

Introduction

Triple Whale's Workflows feature is a powerful tool that automates tasks, generates insights, and streamlines data processes for e-commerce businesses. Among its core components are Rules, which add a layer of intelligence and control to your Workflows. By defining specific conditions and actions, Rules enable you to create dynamic, responsive Workflows that react to changes in your data, detect anomalies, and provide timely notifications. In this article, we'll delve into the Rules feature, exploring its types, functionalities, and how you can leverage it to enhance your data automation strategies.

What Are Rules in Workflows?

Rules in Workflows are conditional statements that determine when and how certain actions are executed within a Workflow. They act as the decision-making logic, allowing you to set criteria that trigger specific responses or workflows based on your data. Rules make your Workflows smarter and more responsive by introducing conditional logic that can handle complex scenarios.

Types of Rules

There are two primary types of Rules in Triple Whale's Workflows:

  1. Regular Rules

  2. GPT Rules

1. Regular Rules

Regular Rules are deterministic conditions set using either a no-code builder or SQL queries. They allow you to specify precise criteria based on your data fields, metrics, and thresholds. Regular Rules are ideal for scenarios where you have specific, quantifiable conditions that need consistent monitoring.

Features of Regular Rules

  • Deterministic Logic: Provides exact conditions that lead to predictable outcomes.

  • No-Code Builder: Allows users without coding experience to set up Rules using a user-friendly interface.

  • SQL Support: For advanced users, SQL queries can define complex conditions.

  • Multiple Conditions: You can stack multiple Rules together to create compound conditions.

  • Action Triggers: Define what actions should be taken when conditions are met, such as sending notifications or executing sub-workflows.

Example Use Cases

  • Performance Thresholds:

    • Condition: If Return on Ad Spend (ROAS) drops below 2.

    • Action: Send an email notification to the marketing team.

  • Inventory Alerts:

    • Condition: If stock levels for a product fall below 50 units.

    • Action: Trigger a replenishment request.

  • Sales Milestones:

    • Condition: When daily sales exceed $10,000.

    • Action: Send a celebratory Slack message to the team.

How to Create Regular Rules

  1. Access the No-Code Rule Builder:

    • In your Workflow step, select the option to add a Rule.

    • Choose the Regular Rule type.

  2. Define Your Condition:

    • Select the data table or metric you want to monitor.

    • Set the condition using operators (e.g., equals, greater than, less than).

    • Input the threshold or value for the condition.

  3. Set the Action:

    • Determine what should happen when the condition is met.

    • Actions can include sending notifications, running sub-workflows, or updating data fields.

  4. Save and Test:

    • Save your Rule and run the Workflow to test if it behaves as expected.

2. GPT Rules

GPT Rules leverage artificial intelligence to interpret complex, less deterministic conditions. They utilize GPT (Generative Pre-trained Transformer) models to understand nuanced instructions and consider the context from previous steps in the Workflow. GPT Rules are ideal when dealing with conditions that are hard to define with strict parameters or when you need AI-driven analysis.

Features of GPT Rules

  • Contextual Understanding: Can reference and interpret data from previous Workflow steps.

  • Natural Language Input: Define conditions using plain language prompts.

  • AI Analysis: Capable of making decisions based on patterns, trends, and anomalies detected by AI.

  • Flexibility: Handles complex scenarios that regular conditional logic may not cover.

Example Use Cases

  • Anomaly Detection:

    • Prompt: "Is today's conversion rate significantly lower than the average of the past week?"

    • Action: If yes, generate a detailed report highlighting potential issues.

  • Trend Analysis:

    • Prompt: "Detect if there is a downward trend in email open rates over the last month."

    • Action: Notify the email marketing team with recommendations.

  • Performance Comparisons:

    • Prompt: "Compare the ROAS of our top 10 ad campaigns to the overall account average."

    • Action: Highlight campaigns performing below average.

How to Create GPT Rules

  1. Add a GPT Rule:

    • In your Workflow step, choose to add a Rule and select the GPT Rule type.

  2. Define the Prompt:

    • Write a natural language instruction or question that the AI will interpret.

    • Ensure the prompt references any necessary context from previous steps.

  3. Set the Action:

    • Decide what should happen if the AI determines the condition is met.

    • This could include generating insights, sending notifications, or triggering other actions.

  4. Save and Test:

    • Run the Workflow to see how the GPT Rule performs and adjust the prompt as needed.

Steps to Integrate Rules

  1. Plan Your Workflow:

    • Identify where decisions need to be made based on data conditions.

  2. Add Workflow Steps:

    • Include data retrieval and analysis steps as needed.

  3. Insert Rules:

    • After the steps that provide necessary data, add a Rule to evaluate conditions.

  4. Define Actions Based on Rules:

    • Determine what the Workflow should do if the Rule's condition is met or not met.

  5. Test the Workflow:

    • Run the Workflow to ensure the Rules behave as expected, making adjustments if necessary.

Advanced Features of Rules

Stacking Multiple Rules

You can stack multiple Rules within a single Workflow to handle complex decision-making processes. This allows for multi-layered conditions where an action is taken only if all specified conditions are met.

Example:

  • Rule 1: If ROAS is below 2.

  • Rule 2: And if click-through rate (CTR) has decreased by more than 10% compared to the previous week.

  • Action: Pause the affected ad campaigns and notify the marketing team.

Using SQL in Regular Rules

For advanced users familiar with SQL, Regular Rules can be defined using SQL queries. This provides greater flexibility and precision in specifying conditions, especially for complex datasets.

Example:

  • SQL Query:

    SELECT
    campaign_name
    FROM
    ad_performance
    WHERE
    roas < 2
    AND ctr < (SELECT AVG(ctr) FROM ad_performance WHERE date >= CURRENT_DATE - INTERVAL '7 days')
  • Action: Generate a list of underperforming campaigns for review.

Contextual GPT Rules

GPT Rules can access and interpret data from previous Workflow steps, allowing for contextual decision-making.

Example:

  • Previous Step: Retrieve sales data for the last 30 days.

  • GPT Rule Prompt: "Based on the sales data, determine if there is an unusual drop in sales in any product category compared to the previous month."

  • Action: If an anomaly is detected, generate a report highlighting the affected categories.

Practical Examples and Use Cases

Example 1: Automated Anomaly Detection

  • Objective: Detect significant drops in website traffic and notify the team.

  • Workflow Steps:

    1. Data Retrieval: Load website traffic data for the past two weeks.

    2. GPT Rule:

      • Prompt: "Is today's website traffic significantly lower than the average of the past week?"

    3. Action: If yes, send an alert email to the web analytics team.

Example 2: Managing Ad Spend

  • Objective: Optimize ad spend by pausing underperforming ads.

  • Workflow Steps:

    1. Data Retrieval: Get performance metrics for all active ad campaigns.

    2. Regular Rule:

      • Condition: If an ad's cost per acquisition (CPA) is higher than $50.

    3. Action: Pause the ad campaign and notify the ad manager.

Example 3: Inventory Management

  • Objective: Prevent stockouts by monitoring inventory levels.

  • Workflow Steps:

    1. Data Retrieval: Access current inventory levels for all products.

    2. Regular Rule:

      • Condition: If inventory level for any product is below 100 units.

    3. Action: Send a restock request to the supply chain team.

Tips for Creating Effective Rules

  • Define Clear Conditions: Ensure that your conditions are specific and measurable.

  • Use Dynamic Time Frames: Reference relative dates (e.g., "last 7 days") to keep Rules relevant over time.

  • Test Rules Individually: Before integrating into larger Workflows, test each Rule to confirm it behaves as expected.

  • Combine Rules Strategically: Use multiple Rules to handle complex scenarios, but avoid unnecessary complexity.

  • Monitor Outputs: Regularly check the outcomes of Rules to ensure they continue to meet your needs.

  • Leverage AI Wisely: Use GPT Rules for conditions that are too complex for regular logic but be aware of their less deterministic nature.

Limitations and Considerations

  • AI Variability: GPT Rules may produce different outcomes based on AI interpretations. Regular monitoring is advisable.

  • Data Dependencies: Ensure that the data required for your Rules is available and correctly formatted.

  • Complexity Management: Overly complex Rules can be difficult to manage. Keep them as straightforward as possible.

  • Cost Implications: Advanced features or high-frequency Rule evaluations may incur additional costs. Verify any potential charges.

Conclusion

Rules are a pivotal component of Triple Whale's Workflows, empowering you to automate intelligent responses to your business data. By mastering both Regular Rules and GPT Rules, you can create dynamic Workflows that not only automate tasks but also adapt to changing conditions, detect anomalies, and provide actionable insights. Whether you're monitoring performance metrics, managing inventory, or optimizing marketing efforts, Rules enable you to add a sophisticated layer of logic to your data automation strategies.

By effectively utilizing Rules, you enhance the responsiveness and efficiency of your operations, allowing you to focus on strategic decision-making and driving business growth.

Did this answer your question?