Skip to content

Chapter 12: Journey Logic

The Problem

Your welcome journey works, but it treats everyone the same. You want: "Send high-value prospects the premium onboarding. A/B test the reminder subject line. If they're in Europe, wait for GDPR-compliant timing. If they abandon mid-journey, trigger a recovery flow."

Real customer experiences need logic.

The Key Idea

Core concept

Journey logic lets you personalize paths with conditions, split audiences with A/B tests, and handle edge cases with timeouts and branches.

AI helps you express complex logic in plain English, then generates the corresponding YAML.

Decision Points

Branch customers based on conditions:

> "After the welcome email, check if they're a high-value prospect. If yes, send premium onboarding. If no, send standard onboarding."
yaml
- type: decision_point
  name: Check Customer Value
  with:
    branches:
      - segment: high-value-customers
        next: premium-onboarding
      - segment: all-customers
        next: standard-onboarding
  next: premium-onboarding  # default if no branch matches

Customers flow to different paths based on the condition.

Multiple Conditions

Check multiple criteria:

> "Branch based on region: US goes to path A, Europe to path B, everyone else to path C"
yaml
- type: decision_point
  name: Regional Routing
  with:
    branches:
      - segment: us-customers
        next: us-path
      - segment: eu-customers
        next: eu-path
  next: other-path  # default for unmatched customers

The first matching segment wins. Unmatched customers follow the default next.

A/B Testing

Split audiences to test variations:

> "A/B test the reminder email: 50% get version A, 50% get version B"
yaml
- type: ab_test
  name: Reminder Test
  with:
    variants:
      - percentage: 50
        next: reminder-version-a
      - percentage: 50
        next: reminder-version-b

Customers are randomly assigned, and assignment is sticky (same customer always gets same variant).

Unequal Splits

Test with different allocations:

yaml
- type: ab_test
  name: New Feature Test
  with:
    variants:
      - percentage: 80
        next: standard-flow
      - percentage: 20
        next: new-flow

80% continue normally; 20% try the new experience.

Wait with Timeout

Wait for behavior, but not forever:

> "Wait up to 7 days for them to make a purchase. If they do, send a thank you. If not, send a reminder."
yaml
- type: wait
  name: Wait for Purchase
  with:
    duration: 7
    unit: day
    condition:
      segment: made-purchase
  next: send-reminder  # after timeout

This waits up to 7 days. If the customer matches the segment condition before the timeout, they proceed immediately. Otherwise, they continue after the duration.

Segment-Based Conditions

Check segment membership dynamically:

yaml
- type: decision_point
  name: Check Engagement
  with:
    branches:
      - segment: engaged-users
        next: engaged-path
  next: re-engage-path  # default for non-engaged

The segment is evaluated at the moment the customer reaches this step.

Combining Logic

Complex flows combine multiple patterns:

> "Welcome journey: Send welcome email. Wait 3 days or until they purchase.
If purchased, thank them and exit. If not purchased, check their value score.
High value gets a personal outreach. Low value gets an automated reminder.
A/B test the reminder: version A is email, version B is SMS."

AI generates a multi-branching flow:

yaml
type: journey
name: Welcome Journey

reentry: no_reentry

segments:
  made-purchase:
    rules:
      - type: behavior
        name: purchase_completed
        operator: Exists

  high-value:
    rules:
      - type: attribute
        name: predicted_ltv
        operator: Greater
        value: 500

journeys:
  - state: draft
    latest: true
    stages:
      - name: Welcome Stage
        steps:
          - type: activation
            name: Welcome Email
            with:
              activation: welcome-email
            next: wait-for-action

          - type: wait
            name: Wait for Purchase
            with:
              duration: 3
              unit: day
              condition:
                segment: made-purchase
            next: check-value

          - type: decision_point
            name: Check Value
            with:
              branches:
                - segment: high-value
                  next: personal-outreach
            next: reminder-test

          - type: activation
            name: Personal Outreach
            with:
              activation: personal-outreach
            next: journey-end

          - type: ab_test
            name: Reminder Channel Test
            with:
              variants:
                - percentage: 50
                  next: reminder-email
                - percentage: 50
                  next: reminder-sms

          - type: activation
            name: Reminder Email
            with:
              activation: reminder-email
            next: journey-end

          - type: activation
            name: Reminder SMS
            with:
              activation: reminder-sms
            next: journey-end

          - type: end
            name: Journey Complete

Merge Points

Bring branches back together:

yaml
# A/B test sends to different paths
- type: ab_test
  name: Channel Test
  with:
    variants:
      - percentage: 50
        next: email-path
      - percentage: 50
        next: sms-path

# Each path does its action, then points to merge
- type: activation
  name: Send Email
  with:
    activation: reminder-email
  next: merge-point           # Points to merge

- type: activation
  name: Send SMS
  with:
    activation: reminder-sms
  next: merge-point           # Points to merge

# Merge collects all branches
- type: merge
  name: Continue Together
  next: follow-up-sequence    # Everyone continues here

Multiple steps point their next: to the merge step. The merge then routes everyone to the same follow-up path.

Jump Steps

Skip to another stage:

yaml
- type: jump
  name: Fast Track
  with:
    target:
      journey: loyalty-program
      stage: main-stage

Useful for moving high-intent customers directly to another journey or stage.

Mental Model: Flowcharts

Journey logic is a flowchart:

Each diamond is a decision point. Each rectangle is an action. Lines show the flow.

Testing Journey Logic

Verify complex logic works:

> "Trace what happens for a high-value customer from the US who doesn't purchase within 3 days"
Trace: High-value US non-purchaser

1. Welcome Email → sends
2. Wait for Purchase → waits 3 days, times out
3. Check Value → predicted_ltv > 500, goes to personal-outreach
4. Personal Outreach → sends
5. End

Total journey time: 3 days
Messages sent: 2 (welcome, personal outreach)

Pitfalls

"Customers are stuck."

Check for missing next references or unreachable steps:

> "Find any dead ends in this journey"

"A/B results are skewed."

Ensure the split happens before any filtering:

> "Is the A/B test splitting a representative sample?"

"Timeout doesn't seem to work."

The condition might be checked at the wrong time:

> "When exactly is the segment condition evaluated?"

What You've Learned

  • Decision points branch based on conditions
  • A/B tests randomly split audiences
  • Wait steps can have conditions and timeouts
  • Merge points bring branches together
  • Jump steps skip to other stages
  • Complex logic combines these patterns
  • Always trace through example customers

Next Step

You've mastered journey logic. Chapter 13 shows you how to automate everything—scheduling recurring jobs and data pipelines with AI-generated workflows.


You can build intelligent journeys. Next, you'll automate the entire operation.