Subzero Labs

Free code · Subzero Labs

Brand-deal inbox: scam check + rate-card replies

From the Subzero Labs video "Your AI Has Amnesia. This Free Code Makes It Remember".

Free, no sign-up. Copy it, use it, share it.

For: Creators

The job: Sponsor emails pile up, some are scams that want you to sign in or pay a fee, and every real one needs a reply with your rates.

You give it: a mailbox export (.mbox from Google Takeout, Thunderbird or Apple Mail) or emails pasted into .txt files, plus your rate card in Markdown.

It is one agent of the free AI OS starter (https://subzero.bodymindbeing.me/free/ai-os-starter/) - download the whole starter, it runs on sample data out of the box. Nothing is sent anywhere: replies come out as drafts.

Download the AI OS starter (zip) 65 KB

MIT licence. Python 3.10+, no other installs. Unzip, then follow README.md.

Run this one

  1. Set up the starter (the steps on the starter page).
  2. python -m aios run brand_deals
  3. Edit config.json: point "brand_deals" at your own files (paths relative to config.json).

Check it yourself

  1. Open data/drafts/brand_deals/ - every price in a draft must be on your rate card; if not, the draft starts with [CHECK BEFORE SENDING].
  2. The sample has two scam emails (a fee in USDT; a short link + 'sign in with Google'): they get no draft at all.
  3. The scam rules are the FLAGS list at the top of the file - plain patterns you can read and edit.

agents/brand_deals.py

"""CREATORS - brand-deal inbox. Reads sponsor emails from a mailbox export (or pasted .txt files), checks every one for
scam red flags with plain rules (no AI), scores how well the brand fits YOUR channel (the AI reads your rate card +
rules from memory first) and drafts a reply that quotes your rate card. The code then checks every price in the draft
really is on your rate card. Nothing is ever sent: drafts are text files in data/drafts/brand_deals/."""
import re

from aios import llm, memory
from aios.config import path

from ._common import messages, save_draft

TITLE = "Brand-deal inbox"
# (pattern, flag, serious?) - serious = likely a scam: no draft, never reply with details or click anything
FLAGS = [
    (r"\b(?:pay|send)\b.{0,30}\b(?:fee|deposit)\b|processing fee|activation fee", "asks YOU to pay", True),
    (r"crypto|bitcoin|usdt|gift ?cards?|wire transfer|western union", "unusual payment method", True),
    (r"password|log ?in (?:details|with)|sign in with (?:google|your)|login|verification code|2fa",
     "asks you to sign in / for account access", True),
    (r"download (?:the|our|this) (?:app|file|brief)|\.exe\b|\.scr\b|\.rar\b|bit\.ly|tinyurl",
     "wants you to open a file / short link", True),
    (r"perpetu|in perpetuity|forever|all media|any media", "usage rights with no end date", False),
    (r"exclusiv", "exclusivity - price it in", False),
    (r"free product|gifted|in exchange for (?:the )?product|no (?:paid )?budget|exposure", "no cash budget", False),
]
PRICE = re.compile(r"[$£€]\s?\d[\d,]*(?:\.\d+)?k?", re.I)


def red_flags(text):
    return [(flag, serious) for rx, flag, serious in FLAGS if re.search(rx, text, re.I)]


def _amounts(text):
    return {re.sub(r"[\s,]", "", m.group(0)).lower().removesuffix(".00") for m in PRICE.finditer(text)}


def unknown_prices(reply, *allowed_texts):
    """Prices in the draft that are not on your rate card (or in the sponsor's own email) - an AI must never invent one."""
    ok = set().union(*(_amounts(t) for t in allowed_texts))
    return sorted(_amounts(reply) - ok)


def run(cfg, data, s):
    memory.sync_folder(data, s["brand_project"], path(cfg, s["brand_notes"]))
    rules = memory.notes_text(data, s["brand_project"])
    items, attention = [], []
    for n, (sender, subject, body) in enumerate(messages(cfg, s["mailbox"]), 1):
        flags = red_flags(subject + " " + body)
        who = sender.split("<")[0].strip()
        if any(serious for _f, serious in flags):
            items.append(f"SCAM SIGNS - {subject} ({who}): {', '.join(f for f, sv in flags if sv)} -> no draft. "
                         "Do not click, sign in or reply with details.")
            attention.append(f"Possible scam: '{subject}' ({', '.join(f for f, sv in flags if sv)})")
            continue
        r = llm.ask_json(f"MY CHANNEL NOTES (rate card + rules):\n{rules}\n\nSPONSOR EMAIL from {sender}\n"
                         f"Subject: {subject}\n\n{body}\n\nRate how well this brand fits my channel from 0 to 10 using "
                         "ONLY my notes, and draft a short friendly reply that quotes the right price from my rate card "
                         "and asks for anything missing (budget, deliverables, usage rights, dates). Quote the rate-card "
                         "lines as they are - do not calculate totals or discounts (I do the maths). "
                         'JSON: {"fit": 0, "why": "one line", "reply": "..."}')
        try:
            fit = int(r.get("fit", 0))
        except (TypeError, ValueError):
            fit = 0
        fit = max(0, min(10, fit - 2 * len(flags)))  # each yellow flag costs 2 points
        reply = str(r.get("reply", ""))
        bad = unknown_prices(reply, rules, body)
        if bad:
            reply = f"[CHECK BEFORE SENDING: {', '.join(bad)} is not on your rate card]\n\n" + reply
        f = save_draft(data, "brand_deals", n, sender, "Re: " + subject, reply)
        items.append(f"fit {fit}/10 - {subject} ({who}): {r.get('why', '')}"
                     + (f" | flags: {', '.join(x for x, _s in flags)}" if flags else "")
                     + (f" | price not on rate card: {', '.join(bad)}" if bad else " | prices match rate card"))
        if fit >= 7:
            attention.append(f"Good fit ({fit}/10): '{subject}' - reply draft in data/drafts/brand_deals/{f.name}")
    return {"summary": f"{len(items)} sponsor emails checked, {len(attention)} need you. Drafts saved - nothing sent.",
            "items": items, "attention": attention}

Shared as shown in the video. Replace any <PLACEHOLDERS> with your own values.