Automated loyalty program management: ingest transaction data, calculate reward points, evaluate customer tier status, detect at-risk customers, generate personalized retention offers, and produce program performance reports.
┌─────────────────────────────────────┐
│ full-loyalty-pipeline │
└─────────────────────────────────────┘
┌─────────────────────┐
│ ingest-transactions │ (command) validate CSVs in data/transactions/
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ calculate-points │ transaction-processor (haiku) — parse, calc, update balances
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ evaluate-tiers │ tier-evaluator (sonnet) — tier thresholds, at-risk detection
└──────────┬──────────┘
│
┌──────────▼──────────┐
│ review-tier-actions │ program-reviewer (opus) — compliance decision gate
└──────────┬──────────┘
┌────┴─────────────────────────┐
│ advance │ rework (→ evaluate-tiers, max 2)
▼ ▼
┌─────────────────┐ fail → ingest-transactions
│ generate-offers │ offer-personalizer (sonnet) + memory MCP
└────────┬────────┘
│
┌────────▼────────────┐
│ compile-program- │ report-generator (haiku) — markdown reports
│ report │
└─────────────────────┘
┌──────────────────────────────┐ Runs: daily at 02:00
│ daily-points-sync │
│ ingest → calculate → check │
└──────────────────────────────┘
┌──────────────────────────────┐ Runs: 1st of each month at 04:00
│ monthly-program-report │
│ aggregate → analyze → │
│ compile-monthly │
└──────────────────────────────┘
cd examples/loyalty-program-manager
ao daemon start
# Run the full pipeline
ao workflow run full-loyalty-pipeline
# Or run just a daily sync
ao workflow run daily-points-sync
# Watch live
ao daemon stream --pretty
# Schedules run automatically:
# Daily sync: every day at 02:00
# Full pipeline: every Monday at 03:00
# Monthly report: 1st of month at 04:00| Agent | Model | Role |
|---|---|---|
| transaction-processor | claude-haiku-4-5 | Parses CSVs, calculates points with category/tier multipliers, updates profiles |
| tier-evaluator | claude-sonnet-4-6 | Evaluates tier status, grace periods, at-risk detection (40% frequency decline) |
| offer-personalizer | claude-sonnet-4-6 | Generates targeted offers; enforces Platinum personalization rule |
| program-reviewer | claude-opus-4-6 | Compliance gate — verifies tier logic before offers are issued |
| report-generator | claude-haiku-4-5 | Compiles markdown performance reports and tier dashboards |
| quick-tier-checker | claude-haiku-4-5 | Lightweight daily boundary check (no full analysis) |
| monthly-analyst | claude-sonnet-4-6 | Deep monthly health analysis, trend detection, ROI metrics |
- Multi-workflow design — Three distinct workflows (full pipeline, daily sync, monthly report)
- Scheduled execution — Cron schedules at daily, weekly, and monthly intervals
- Decision gate with routing —
review-tier-actionsroutes to rework/fail/advance - Rework loops — Tier evaluation retried up to 2 times on reviewer rejection
- Multi-model routing — Haiku (fast/cheap), Sonnet (analysis), Opus (review gate)
- Command phases — Shell script for CSV validation before any agent work
- Memory MCP — Persistent customer preferences across pipeline runs
- Sequential-thinking MCP — Structured reasoning for edge-case tier logic
- Output contracts — Structured JSON outputs at each phase boundary
- Mixed phase types — command, agent, and decision phases in one workflow
| Tier | Quarterly Points (90-day) | Earn Rate | Key Benefit |
|---|---|---|---|
| Bronze | 0 – 999 | 1x | Base program |
| Silver | 1,000 – 4,999 | 1.5x | Free shipping $50+ |
| Gold | 5,000 – 14,999 | 2x | Free shipping + early access |
| Platinum | 15,000+ | 3x | All benefits + dedicated support |
- Rolling 90-day qualification window (not calendar quarter)
- 30-day grace period before any tier downgrade
- At-risk flag: >40% transaction frequency decline over 60 days
- Points expiry: 12-month inactivity threshold (warning at 11 months)
- Max 3 active offers per customer
- Platinum customers MUST receive personalized offers — never generic
MCP Servers (auto-installed via npx):
@modelcontextprotocol/server-filesystem@modelcontextprotocol/server-sequential-thinking@modelcontextprotocol/server-memory
System tools:
bash(for transaction validation script)python3(for monthly data aggregation)
No external API keys required — runs entirely on local files and Claude models.
loyalty-program-manager/
├── .ao/workflows/
│ ├── agents.yaml # 7 agents with distinct roles
│ ├── phases.yaml # 11 phases across 3 workflows
│ ├── workflows.yaml # 3 workflow definitions
│ ├── mcp-servers.yaml # filesystem, sequential-thinking, memory
│ └── schedules.yaml # daily, weekly, monthly schedules
├── config/
│ ├── tier-thresholds.yaml # Tier boundaries, grace periods, at-risk rules
│ ├── points-rules.yaml # Category multipliers, tier rates, bonus campaigns
│ └── offer-templates.yaml # Offer types, validity, personalization rules
├── data/
│ ├── transactions/ # Input CSVs (daily imports)
│ ├── customers/ # customer-profiles.json, activity-history.json
│ └── audit-log.json # Append-only run history
├── output/
│ ├── tier-actions/ # tier-changes-{date}.json, daily-check-{date}.json
│ ├── offers/ # offer-batch-{date}.json
│ └── reports/ # program-report, tier-dashboard, monthly reports
├── scripts/
│ └── validate-transactions.sh
├── CLAUDE.md
└── README.md