Scenario
Subreddits surface emerging topics hours before mainstream channels. This job monitors/rising, sends each trend to Mave for brand-alignment, then feeds approved trends into Generate.
Architecture
Code
import os, requests, time
# --- Auth setup same as Job 1 ---
SUB = "marketing"
BRAND = "B2B marketing analytics platform. Audience: Marketing directors/VPs. Tone: Data-driven, practical, contrarian."
# 1. Rising posts
rising = [p["data"] for p in requests.get(f"{RD}/r/{SUB}/rising",
headers=RD_H, params={"limit": 20, "raw_json": 1}).json()["data"]["children"]]
# 2. Brand alignment via Mave
aligned = []
for post in rising:
check = requests.post(f"{MV_BASE}/mave/chat", headers=MV_H, json={
"message": f"Evaluate trend for brand alignment (score 1-10).\n\nTREND: {post['title']}\nCONTEXT: {post.get('selftext','')[:300]}\nSUBREDDIT: /r/{SUB} | Score: {post.get('score',0)}\n\nBRAND: {BRAND}\n\nIf 7+: suggest angle + format. Estimate trend velocity."
}).json()
content = check.get("content", "")
lines = [l for l in content.split("\n") if "/10" in l or "score" in l.lower()]
try: score = int("".join(c for c in (lines[0] if lines else "0") if c.isdigit())[:2])
except: score = 0
if score >= 7:
aligned.append({"title": post["title"], "score": post.get("score",0), "alignment": score, "angle": content[:300]})
time.sleep(0.5)
print(f"Evaluated: {len(rising)} | Aligned: {len(aligned)}")
# 3. Generate content
for trend in aligned[:5]:
gen = requests.post(f"{MV_BASE}/generations", headers=MV_H, json={
"prompt": f"Write a LinkedIn article (600-800 words) based on:\n\nTREND: {trend['title']}\nANGLE: {trend['angle'][:200]}\n\nHook: Open with Reddit insight. Body: Data + frameworks. CTA: Free trial. Tone: data-driven, contrarian.",
}).json()
print(f"\n{'='*50}\nTREND: {trend['title']} | Alignment: {trend['alignment']}/10")
print(gen.get("output", gen.get("content", ""))[:500])
// --- Auth setup same as Job 1 ---
const SUB = "marketing";
const BRAND = "B2B marketing analytics. Audience: Marketing directors/VPs. Tone: Data-driven, contrarian.";
// 1. Rising posts
const rising = (await (await fetch(`${RD}/r/${SUB}/rising?limit=20&raw_json=1`, { headers: RD_H })).json())
.data.children.map(p => p.data);
// 2. Brand alignment
const aligned = [];
for (const post of rising) {
const check = await fetch(`${MV_BASE}/mave/chat`, { method: "POST", headers: MV_H,
body: JSON.stringify({ message: `Evaluate trend for brand alignment (1-10).\n\nTREND: ${post.title}\nCONTEXT: ${(post.selftext||"").slice(0,300)}\n\n${BRAND}\n\nIf 7+: suggest angle. Estimate velocity.` }),
}).then(r => r.json());
const line = (check.content || "").split("\n").find(l => l.includes("/10")) || "";
const score = parseInt((line.match(/\d+/) || ["0"])[0], 10);
if (score >= 7) aligned.push({ title: post.title, score: post.score||0, alignment: score, angle: (check.content||"").slice(0,300) });
await new Promise(r => setTimeout(r, 500));
}
console.log(`Evaluated: ${rising.length} | Aligned: ${aligned.length}`);
// 3. Generate
for (const trend of aligned.slice(0, 5)) {
const gen = await fetch(`${MV_BASE}/generations`, { method: "POST", headers: MV_H,
body: JSON.stringify({ prompt: `LinkedIn article (600-800 words).\n\nTREND: ${trend.title}\nANGLE: ${trend.angle.slice(0,200)}\n\nHook with Reddit insight. Data + frameworks. CTA: free trial.` }),
}).then(r => r.json());
console.log(`\n${"=".repeat(50)}\nTREND: ${trend.title} | Alignment: ${trend.alignment}/10`);
console.log((gen.output || gen.content || "").slice(0, 500));
}
Example Output
Evaluated: 20 | Aligned: 6
TREND: "Our attribution model was completely wrong" | Alignment: 10/10
# Our Attribution Model Was Lying to Us (and Yours Probably Is Too)
A thread in /r/marketing surfaced something uncomfortable: a director
rebuilt attribution and found 40% of "high-performing" channels were
getting credit for conversions they didn't influence...
Error Handling
Rising vs hot
Rising vs hot
/rising surfaces fast-growing posts. Fall back to /hot?limit=10 for smaller subreddits.Content length
Content length
If truncated, increase
max_tokens or split into sections.