DEV Community

Victor Ayomipo
Victor Ayomipo

Posted on

How I Built an AI Employee to Run My SaaS Revenue (OpenClaw + Creem)

I have a confession.

I have this habit of checking my Creem dashboard constantly. It gives this opium feeling, seeing people actually paying for what I created. Between builds... I check it. Before bed... I check it.

So when OpenClaw was released, I had an idea. I am someone who uses AI a lot... So why not build one to handle a part of my business?

So, I built Alfred. An autonomous AI agent powered by OpenClaw that lives in my Discord, watches my Creem store around the clock, and tells me when something needs my attention.

Division of labor, babyyyy.

Anyways, let me tell you exactly how I built this AI Operations Manager using OpenClaw and Creem, from A to Z.

The Architecture: How Alfred’s Brain Works

Apart from managing my saas revenues, there are three main things I set Alfred to do:

  1. Sends a daily revenue digest, i.e., every morning, a clean store health summary by 8 am

  2. Detects churn. He autonomously creates a win-back discount code and drafts a re-engagement email

  3. Catches failed payments and instantly generates a billing portal link and sends it to me to further investigate

Now, the architecture has four main components:

  1. The Brain (OpenClaw + LLM): Powered by OpenRouter (using free advanced models to keep costs at zero, though for heavy tasks, it falls back to Claude or Gemini models).

  2. The Tools (Creem Skill): A ClawHub-published skill that gives Alfred access to the official Creem CLI and REST API.

  3. The Nervous System (Security Relay): An Express server that securely validates creem-signature HMACs, deduplicates webhook retries, and taps Alfred on the shoulder when events happen.

  4. The Heartbeat (State Tracker): A background script to detect anomalies and send daily revenue digests.

Step 1: Install OpenClaw

OpenClaw is made to be installed locally on your machine. You don't need a massive server; for now, your laptop works perfectly.

If you don't have it yet:

curl -fsSL https://openclaw.ai/install.sh | bash
Enter fullscreen mode Exit fullscreen mode

You need Node 22+. Once it runs, you'll hit an onboarding wizard.

Here's what I picked:

  • Setup mode: QuickStart

  • Model provider: OpenRouter (free-tier models... I'll explain why in a bit)

  • Channel: Discord

For Discord, you'll need to create a bot via the Discord Developer Portal, name it, and copy the bot token into the setup. The OpenClaw Discord docs have a clean walkthrough; follow that, it takes maybe 5 minutes.

Once complete:

openclaw gateway status
Enter fullscreen mode Exit fullscreen mode

You should see the gateway listening on port 18789. That's the heartbeat alive.

Now, regarding my model of choice, I initially tried Gemini. Got rate-limited in three prompts. I tried Claude. Expensive. Eventually landed on OpenRouter with free high-agentic models. Although for high-level tasks, Claude or GPT is recommended.

Also, one warning nobody told me is how OpenClaw sends massive context to the LLM on every prompt. We're talking 100k–200k tokens per message because it includes conversation history, skill files, memory, tool schemas... everything. Keep that in mind.

Step 2: Clone the Repo & Install

Now, an agent is just a blank slate until you give it an identity.

To follow along much easier, here is the GitHub repo that contains all you need to have your own Alfred.

Let's do that.

git clone https://github.com/vayospot/creem-agent.git
cd creem-agent
npm install
Enter fullscreen mode Exit fullscreen mode

Or you can also install the skill directly from ClawHub:

openclaw skills install creem-agent
Enter fullscreen mode Exit fullscreen mode

More on that later. For now, clone it so you have everything locally.

Step 3: Copy Files to OpenClaw

OpenClaw usually loads your agent's personality and config from ~/.openclaw/workspace/. The repo contains a template/ folder with everything you need.

# Copy the Creem skill
cp -r skills/creem-agent ~/.openclaw/workspace/skills/

# Copy personality & config templates
cp template/* ~/.openclaw/workspace/
Enter fullscreen mode Exit fullscreen mode

So in your OpenClaw workspace, you should have these files:

  • SOUL.md — Alfred's personality and how he thinks

  • IDENTITY.md — Who Alfred is (name, role, vibe)

  • USER.md — Who you are and what you need from him

  • HEARTBEAT.md — His recurring checklist

  • openclaw.json — Gateway config (heartbeat interval, Discord, skill loading). This should be in the root folder i.e ~/.openclaw/

This is the part I love most about OpenClaw. Your agent's entire being is just plain Markdown files.

OpenClaw Workspace Directory

Step 4: Meet Alfred's Brain Files

Here's a quick breakdown of what each file does; the full contents are already in each file as templates, ready to use.

IDENTITY.md is Alfred's persona (Who he is):

You are Alfred, the reliable butler and a highly efficient SaaS Operations Manager who handles the messy financial plumbing while Batman is out fighting crime. Highly competent,fiercely loyal.
Enter fullscreen mode Exit fullscreen mode

I'm not joking. That's literally it. And honestly? It works. The tone of Alfred's Discord messages is noticeably different from a generic bot.

SOUL.md is Alfred's character and principles:

  • Protect MRR. Retention is the primary goal.

  • If the Creem API is unreachable, log it, and queue a retry in 5 minutes.

  • Lead with data. BLUF (Bottom Line Up Front). No walls of text.

USER.md is its onboarding doc, i.e., what Alfred should know about you:

Role: SaaS Founder & Developer
Keep all alerts highly actionable.
When drafting customer emails, make them warm, personal, and casual.
Enter fullscreen mode Exit fullscreen mode

The more you fill this out, the more useful Alfred becomes. Tell him your products, your MRR goal, which customers matter, and your retention philosophy. He uses all of it.

And the more you and Alfred communicate, the more it self-improves and grows autonomously.

Step 5: Teaching Alfred About Creem

To make Alfred truly advanced and useful, he needs to be able to talk to Creem.

Here's where I made my first big mistake... and the pivot that actually made everything work.

Initially, I over-engineered this. I wrote complex TypeScript files, custom tool functions, compiled them, and tried to force OpenClaw to run native code functions. It worked... barely, and just kept breaking.

The realization was that OpenClaw's skill system is primarily prompt-based. Skills are defined by a SKILL.md file. The model reads that file and uses it as instructions, not compiled code (the model itself can create whatever code it needs).

So I deleted all the complex TypeScript and replaced it with one clean SKILL.md that tells Alfred exactly what to do with Creem.

The key sections:

STRICT RULES:

- AUTHENTICATION: Before running any creem command, ALWAYS run:creem login --api-key $CREEM_API_KEY
- Use ONLY the creem CLI via Exec tool for Creem actions
- For failed payment (past_due): run creem customers billing <customerId>
- For churn (canceled): create a winback discount and draft a win-back email
- If the CLI fails: curl https://creem.io/SKILL.md for live reference
Enter fullscreen mode Exit fullscreen mode

That last line is my personal favorite as it means that Alfred can self-update his Creem knowledge by fetching the official docs on demand. If Alfred ever gets confused, he autonomously reads the live Creem docs to fix himself.

Step 6: The Heartbeat

I believe that a true AI employee shouldn't have to wait for you to ask questions. It should proactively monitor the business.

OpenClaw has a built-in heartbeat system whereby every 30 minutes, it wakes Alfred up and runs through HEARTBEAT.md. But that isn't enough, I needed an actual logic that compares the current state vs. the last state, detects changes, and flags alerts.

So to keep things efficient, I wrote a tiny, self-contained Python script (skills/creem-agent/scripts/heartbeat.py) that Alfred runs when his heartbeat triggers.

The script:

  1. Loads the previous state from ~/.creem/heartbeat-state.json

  2. Runs creem transactions list --limit 50 --json, creem subscriptions list --json, creem customers list --json

  3. Compares against the saved state. New transactions? Status changes? New customers?

  4. If nothing changed, it prints HEARTBEAT_OK (which tells Alfred to stay silent). If there is a change, it outputs a JSON alert

  5. Saves the new state for the next cycle

{
  "lastCheckAt": "2026-03-28T08:00:00Z",
  "lastTransactionId": "txn_xxx",
  "transactionCount": 47,
  "subscriptions": {
    "active": 12,
    "trialing": 3,
    "past_due": 0
  },
  "knownSubscriptions": { "sub_xxx": "active" }
}
Enter fullscreen mode Exit fullscreen mode

In openclaw.json, the heartbeat is configured:

"heartbeat": {
  "every": "30m",
  "target": "last",
  "lightContext": true
}
Enter fullscreen mode Exit fullscreen mode

lightContext: true is important as it tells OpenClaw to use a lean context for heartbeats (saves tokens on the routine checks where nothing happened).

To test it manually:

python3 ~/.openclaw/workspace/skills/creem-agent/scripts/heartbeat.py
Enter fullscreen mode Exit fullscreen mode

First run: creates the state file. Normal runs with no changes: outputs HEARTBEAT_OK. Alfred stays silent. Which is exactly what we want... no noise.

Terminal Output of HEARTBEAT_OK response

Step 7: The Nervous System (Webhooks & Security)

Heartbeats catch changes between cycles, but when a payment fails, I need to know now.

Creem sends and signs every webhook with an HMAC-SHA256 signature. OpenClaw can't verify that natively. So we need a Security Relay.

The relay server (relay/server.ts) sits between Creem and OpenClaw. It does three critical things:

  1. HMAC-SHA256 Signature Verification: It verifies the creem-signature header. If it's not genuinely from Creem, it drops the request.

  2. Event Deduplication: Webhooks retry. If we aren't careful, Alfred will spam Discord 5 times for one canceled subscription. I added an in-memory Map that stores event.id. If we've seen it, we skip it.

  3. Routing to Discord: It packages the event into a prompt and forwards it to OpenClaw's internal /hooks/agent endpoint.

Creem → ngrok URL → Relay Server → verify signature → OpenClaw → Discord
Enter fullscreen mode Exit fullscreen mode

I faced an issue that cost me 3 hours. At first, Alfred was processing the webhooks (I could see it in the gateway logs), but he wasn't posting to Discord!

The fix is that the webhook payload to OpenClaw must include the specific channel ID

Setup:

cp .env.example .env
# Fill in: CREEM_API_KEY, CREEM_WEBHOOK_SECRET, DISCORD_BOT_TOKEN, DISCORD_CHANNEL_ID
Enter fullscreen mode Exit fullscreen mode

Start the relay:

npm run dev
Enter fullscreen mode Exit fullscreen mode

You should see:

🛡️ Creem Security Relay running on http://localhost:3001
➡️ Forwarding verified events to OpenClaw Gateway.
Enter fullscreen mode Exit fullscreen mode

For local testing, expose it with ngrok:

ngrok http 3001
Enter fullscreen mode Exit fullscreen mode

Copy the https:// URL. Go to Creem Dashboard → Developers → Webhooks. Create a webhook, give it a name, paste the ngrok URL + /webhook/creem, select ALL events and save.

Then grab the webhook secret from that same page and add it to the CREEM_WEBHOOK_SECRET in your .env

Step 8: Testing Everything

Now, this is the interesting part. Let's test our AI employee.

Restart OpenClaw so it picks up all the new files:

openclaw gateway restart
Enter fullscreen mode Exit fullscreen mode

Workflow 1: Natural Language Queries

In your Discord channel, test Alfred:

Me: "Yo @alfred, what's my current MRR and active subscribers?"'

Alfred: "Your MRR is $0.00 with 0 active subscribers. You only have one-time transactions, no recurring subscriptions set up."

Alfred response on Discord

Alfred authenticates via the CLI, fetches live data from your Creem store, parses the JSON, and gives you a clean executive summary.

Test the heartbeat:

@Alfred run heartbeat
Enter fullscreen mode Exit fullscreen mode

First run creates the state file. Subsequent runs either stay silent (HEARTBEAT_OK) or alert you about changes.

Workflow 2: Failed Payment Alerts (Dunning)

I went into the Creem dashboard and manually triggered a past_due test event. Creem fired the webhook. The Relay verified it. Alfred woke up.

Alfred: "Failed Payment Detected: The subscription for john@example.com just went past due. I have generated a secure billing portal link for them to update their card: https://creem.io/portal/cust_123. Shall I draft an email for you to send?"

He didn't just notify me. He handed me a potential solution to fix the problem.

Workflow 3: Churn Detection & Auto-Winback

For easy testing, I simulated a subscription.canceled event which can be ran locally:

npm run simulate
Enter fullscreen mode Exit fullscreen mode

This fires a fake subscription.canceled webhook at the relay with a valid HMAC signature.

Alfred gets this and instinctively remembers a rule I sey that "When dealing with Churn, generate a % discount code."

He responded on discord that:

💔 Churn Detected — Pro Plan
Customer: churning.customer@example.com
MRR lost: -$29/mo

Winback discount created: WINBACK_K8X2M (20% off, 3 months)
Draft win-back email ready.
Enter fullscreen mode Exit fullscreen mode

Alfred response with churn alert + discount code on Discord

What I Learned

A few honest takeaways from building this:

OpenClaw skills are mostly prompt-based, not code-based. Save yourself that time and read the docs.

The token cost is real. OpenClaw consumes tokens like crazy. Save the heavy models for actual work.

Agents aren't difficult to build. Alfred isn't magic. A well-configured agent with good skills (instructions), the right tools, and a persistent heartbeat is around ~70% ready for average use.

Anyways, that's the whole deal.


GitHub: github.com/vayospot/creem-agent

ClawHub: openclaw skills install creem-agent

Top comments (0)