Skip to main content

Agent Building | Step 2b: Adding Logic

Transform your data into actionable insights and automated decisions with AI-powered analysis and rule-based logic.

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

Step 2a: Add Logic

Once you’ve gathered your datasets in Step 1, it’s time to transform raw numbers into strategic guidance—and then layer in the decision-making rules that automate next steps.



2.1 Logic Types

After your data has been processed, embed decision rules to control when and how downstream steps execute:

Action

What It Does

Example Use Case

Prompt Rule

Defines conditional logic in plain language.

“If the new customers percentage is greater than 10%”

Formula Rule

Builds classic if-then-else logic using an editor or via SQL.

If aov > $100, label segment ‘High-Value’; else ‘Standard’.”

Run Subworkflow

Executes one or more other Agents in parallel.

After computing key metrics, kick off the ‘Daily Marketing Pulse’ and ‘Daily Flourishing Creative’ Agents simultaneously, before feeding those results into a subsequent analysis.

Loop

Iterates an Agent step over each item in a list or table.

For each product SKU in my top-50 list, run a forecasting model to generate individual weekly demand projections.

Close Loop

Feeds results back into an earlier step or external system to complete a cycle.

“After updating customer segments, push the new lists back into our CRM and re-run the retention analysis.”

Implementation Tips:

  • Order matters: Place logic steps immediately after the analysis they govern.

  • Combine rules: Use Prompt and Formula rules together—for instance, a Prompt Rule to check a complex condition, and a Formula Rule to assign labels.

  • Monitor performance: Loops and subworkflows can increase run time; test on small subsets before full execution.


Bringing It All Together

By combining Analyze Data actions with Add Logic controls, your Agent becomes more than a report builder—it becomes an autonomous decision engine:

  1. Analyze: Forecast next month’s revenue.

  2. Rule: If forecast < target, tag “Underperforming.”

  3. Subworkflow: Trigger a promotional campaign Agent for those tagged.

  4. Loop & Close Loop: Iterate this process per campaign and sync results back to your dashboard.

This layered approach ensures that every run not only uncovers insights but also automatically acts on them—driving continuous optimization without manual intervention.

Did this answer your question?