Scenario
Marketing creates content in a vacuum, disconnected from what sales is actually selling. This job pulls your current pipeline by stage and industry, identifies dominant segments, and uses Mavera’s generation engine to produce stage-specific nurture content dynamically tied to your real pipeline. When your pipeline shifts, your content shifts with it.Architecture
Code
import os, requests
from collections import Counter
SF = os.environ["SALESFORCE_INSTANCE"]
SF_T = os.environ["SALESFORCE_ACCESS_TOKEN"]
MV_K = os.environ["MAVERA_API_KEY"]
SF_H = {"Authorization": f"Bearer {SF_T}"}
MV_H = {"Authorization": f"Bearer {MV_K}", "Content-Type": "application/json"}
opps = requests.get(
f"https://{SF}/services/data/v66.0/query", headers=SF_H,
params={"q": "SELECT StageName, Industry, Amount FROM Opportunity WHERE IsClosed = false ORDER BY Amount DESC LIMIT 100"},
).json()["records"]
seg_counts = Counter((o.get("StageName", "Unknown"), o.get("Industry", "Unknown")) for o in opps)
top_segments = seg_counts.most_common(5)
for (stage, industry), count in top_segments:
seg_value = sum(o.get("Amount", 0) for o in opps if o.get("StageName") == stage and o.get("Industry") == industry)
context = f"{count} open deals in '{stage}' stage, {industry} industry. Pipeline value: ${seg_value:,.0f}."
gen = requests.post(
"https://app.mavera.io/api/v1/generations", headers=MV_H,
json={
"input_data": context,
"prompt": (
f"Generate a nurture email for prospects in the '{stage}' stage, "
f"{industry} industry. Address common concerns at this stage, "
f"provide social proof, include a clear next-step CTA."
),
},
).json()
print(f"\n{'='*50}")
print(f"Stage: {stage} | Industry: {industry} | Deals: {count}")
print(f"{'='*50}")
print(gen.get("output", ""))
const SF = process.env.SALESFORCE_INSTANCE;
const SF_T = process.env.SALESFORCE_ACCESS_TOKEN;
const MV_K = process.env.MAVERA_API_KEY;
const { records: opps } = await fetch(
`https://${SF}/services/data/v66.0/query?q=${encodeURIComponent(
"SELECT StageName, Industry, Amount FROM Opportunity WHERE IsClosed = false ORDER BY Amount DESC LIMIT 100"
)}`,
{ headers: { Authorization: `Bearer ${SF_T}` } }
).then((r) => r.json());
const segCounts = {};
for (const o of opps) {
const key = `${o.StageName || "Unknown"}|${o.Industry || "Unknown"}`;
segCounts[key] = (segCounts[key] || 0) + 1;
}
const topSegments = Object.entries(segCounts).sort(([, a], [, b]) => b - a).slice(0, 5);
for (const [key, count] of topSegments) {
const [stage, industry] = key.split("|");
const segValue = opps
.filter((o) => o.StageName === stage && o.Industry === industry)
.reduce((s, o) => s + (o.Amount || 0), 0);
const gen = await fetch("https://app.mavera.io/api/v1/generations", {
method: "POST",
headers: { Authorization: `Bearer ${MV_K}`, "Content-Type": "application/json" },
body: JSON.stringify({
input_data: `${count} open deals in '${stage}' stage, ${industry}. Value: $${segValue.toLocaleString()}.`,
prompt: `Generate a nurture email for '${stage}' stage, ${industry}. Address stage concerns, social proof, clear CTA.`,
}),
}).then((r) => r.json());
console.log(`\n${"=".repeat(50)}`);
console.log(`Stage: ${stage} | Industry: ${industry} | Deals: ${count}`);
console.log(gen.output || "");
}
Example Output
==================================================
Stage: Qualification | Industry: Technology | Deals: 12
==================================================
Subject: How [TechCorp] cut evaluation time by 3 weeks
Hi {{Name}},
I noticed your team is evaluating solutions. We recently helped TechCorp,
a similar-sized engineering org, go from first call to POC results in 10 days.
What made the difference:
- Pre-built integrations with their existing stack
- Dedicated SE for the entire eval period
- ROI calculator access before any contracts
Would a 20-minute walkthrough be useful?
==================================================
Stage: Negotiation | Industry: Financial Services | Deals: 8
==================================================
Subject: Your security review — we've done this before
Hi {{Name}},
Security reviews can slow things down in financial services. We've completed
InfoSec reviews with 15+ banks this year — happy to share our SOC 2 Type II,
pen test results, and data residency docs upfront.
Want me to send the security packet today?
Schedule weekly via cron. When your pipeline shifts toward a new industry or stage, your content library automatically adapts.
Salesforce Overview
Back to all 8 Salesforce jobs
Competitive Displacement Tracker
Next: AI-generated battle cards from competitor data