Scaling organic search visibility and consistent video output typically forces founders and lean marketing teams into an expensive trade-off: either hire a full-time editorial team with 5-hour turnaround times per article, or rely on generic "one-click AI wrappers" that hallucinate, repeat topics, and publish off-brand content.
We engineered the Arivra Autonomous Content Engine—a state-driven, microservice workflow architecture that autonomously executes keyword research, writes structured 1,500-word SEO deep-dives, scripts companion 60-second explainer videos, and runs technical on-page SEO audits.
Before a single word goes live, the system pauses execution and dispatches an interactive preview to Telegram, allowing the founder to Approve, Revise (with natural language feedback), or Reject in one tap.
Input & Intelligence
- • Google Trends demand
- • Keyword intent gap
- • News & RSS feeds
- • Topic memory exclusion
Orchestrator & Router
- • n8n state machine
- • Idempotent step-guard
- • Tiered LLM routing
- • Claude • GPT-4o • Gemini
Content Pipeline
- • WF-1: Outline & thesis
- • WF-2: 1,500w deep draft
- • WF-3: 60s video script
- • WF-4: SEO audit score
Telegram Approval Loop
- • 1-Tap inline [Approve]
- • Natural language [/feedback]
- • Recursive v1 → v2 loop
- • Safe halt on [Reject]
Publish & Track
- • Static Headless MDX
- • LinkedIn B2B post
- • X / YouTube scripts
- • Google Search Console
The Engineering Problem
Most early-stage content automations fail in production because they are built as fragile, linear chains rather than resilient distributed systems:
- Topic Cannibalization: Without persistent semantic memory, automated pipelines repeatedly generate overlapping articles around the same primary keywords, diluting domain authority.
- Single-Model Fragility: Hardcoding a single LLM API means the entire pipeline crashes whenever the provider hits a rate limit, experiences latency spikes, or returns malformed JSON.
- Token Waste on Partial Failures: If a 6-step workflow fails on step 5, naive automations restart from step 1—burning API credits and duplicating database rows.
- Heavy CMS Overhead: Traditional database-backed CMS platforms require paid servers, constant security patching, and slow dashboard logins just to review a draft.
System Architecture: 5-Stage Autonomous Pipeline
Instead of a monolithic script, the engine is decoupled into five isolated sub-workflows governed by a central orchestrator and an idempotent step-guard:
1. Semantic Topic Memory & Deduplication
Before pitching or researching a topic, the Research Module queries a historical topics_memory ledger. It extracts all previously targeted primary keywords and active drafts, injecting an exclusion constraint into the research prompt so every execution produces a 100% net-new angle.
2. Tiered Multi-LLM Fallback Router
Not every task requires a heavyweight reasoning model. The engine abstracts model selection into cognitive tiers:
- fast Tier: High-speed parsing, schema validation, and lightweight classification.
- smart Tier: Keyword intent analysis, 60-second video scene scripting, and technical SEO auditing.
- writer Tier: Long-form, 5-section technical and B2B article synthesis (~1,500 words).
If the primary model in any tier times out or fails JSON schema validation, the router automatically fails over to secondary backup models without interrupting the parent run.
3. Parallel Content, Video Script & SEO Synthesis
Once a topic is locked, specialized modules execute sequentially and update a unified state record anchored by run_id:
- Long-Form Writer Module: Generates a deeply structured 5-section article with clean H2/H3 hierarchy, actionable takeaways, and metadata.
- Media Scripting Module: Converts the core thesis of the article into a 5-scene, 60-second video script with visual cues, spoken voiceover hooks, and a clear call-to-action.
- Technical SEO Optimizer: Audits the generated draft against primary and secondary keywords, calculating an objective SEO score (0–100), checking keyword density (1%–3%), validating title/meta character limits, and suggesting internal linking anchors.
4. Telegram Human-in-the-Loop (HITL) Approval & Revision Loop
Automated publishing without human oversight is a brand risk. When the SEO audit completes, the Approval Module serializes a clean Markdown summary and sends it to the owner's Telegram with inline callback controls:
- ✅ Approve: Locks the version state and triggers the Publisher pipeline.
- ✏️ Revise: Captures natural-language editorial feedback directly from Telegram, routes the draft + instructions back to the Writer Module, increments the version counter ($v_1 \rightarrow v_2$), and sends the revised draft back to Telegram within seconds.
- ❌ Reject: Safely halts the run and logs the rejection reason for future tuning.
5. Headless MDX & B2B Syndication
To maintain fast static edge delivery with zero server maintenance costs, approved articles are formatted directly for a static MDX frontend architecture alongside professional B2B syndication on LinkedIn, while logging run telemetry (tokens, latency, cost in USD, and manual minutes saved).
Under the Hood: Core Architectural Patterns
Below are sanitized, production-grade patterns that power the engine's reliability, state management, and human-in-the-loop control.
1. Idempotent Step-Guard (Self-Healing Execution State)
Every module checks in with a centralized Step-Guard before executing. If a run is retried after a network drop, completed modules are automatically skipped (action: "skip"), preventing duplicate LLM calls and protecting database integrity.
// Sanitized Step-Guard Initialization Pattern
const payload = $input.first().json;
const config = payload.config || {};
if (!payload.run_id) {
throw new Error("Orchestrator Error: Missing immutable run_id anchor.");
}
const version = Number(payload.version) || 1;
const round = Number(payload.round) || 1;
return [{
json: {
run_id: payload.run_id,
module: payload.module,
version,
round,
op: "begin",
step_key: `${payload.run_id}|${payload.module}|v${version}-r${round}`,
max_attempts: config.retry?.max ?? 3,
stale_timeout_min: config.stale_timeout_min ?? 60,
started_ms: Date.now()
}
}];
2. Tiered Multi-LLM Router with Schema Enforcement
Instead of coupling business logic to a single AI vendor, modules request a cognitive tier (writer, smart, or fast) and enforce strict JSON output validation before committing state updates.
// Sanitized SEO Auditor Prompt & Router Dispatch Payload
const initState = $("Init").first().json;
const seoConfig = initState.config.seo || {};
return [{
json: {
run_id: initState.run_id,
agent: "seo_auditor",
tier: seoConfig.tier ?? "smart",
json_mode: true,
temperature: 0.3,
max_tokens: Number(seoConfig.max_tokens ?? 1500),
system_prompt: [
"You are a Technical SEO Auditor.",
"Audit the draft for keyword density (target 1-3%), H2/H3 depth, and meta quality.",
"Return ONLY valid JSON matching the schema: { seo_score, keyword_density_pct, issues[], overall_verdict }."
].join(" "),
user_prompt: `TITLE: ${blogTitle}\nPRIMARY KEYWORD: ${primaryKeyword}\nBODY:\n${fullText.slice(0, 4000)}`
}
}];
3. Asynchronous Telegram HITL Webhook & Auto-Revision Parser
When the founder taps an inline button or replies with /feedback on Telegram, the suspended execution resumes immediately via a webhook listener, parses the callback payload, and either finalizes the post or triggers a recursive revision cycle.
// Sanitized Telegram Callback & Revision Parser
const webhookPayload = $input.first().json.body || $input.first().json;
const context = $("Init").first().json;
let rawAction = "";
let feedback = "";
if (webhookPayload.callback_query?.data) {
// Handle 1-Tap Inline Button: "approve|<id>", "revise|<id>", "reject|<id>"
rawAction = String(webhookPayload.callback_query.data).toLowerCase();
} else if (webhookPayload.message?.text) {
// Handle Natural Language Revision Command: "/feedback Make section 2 more technical"
const text = String(webhookPayload.message.text).trim();
if (text.toLowerCase().startsWith("/feedback")) {
rawAction = "revise";
feedback = text.slice(9).trim();
}
}
const [normalizedAction, parsedApprovalId] = rawAction.split("|").map(s => s.trim());
const validActions = ["approve", "revise", "reject"];
if (!validActions.includes(normalizedAction)) {
throw new Error(`Invalid editorial action: ${normalizedAction}`);
}
return [{
json: {
approval_id: parsedApprovalId || context.approval_id,
run_id: context.run_id,
action: normalizedAction,
feedback: feedback.slice(0, 2000),
version: context.version,
round: context.round,
responded_at: new Date().toISOString()
}
}];
Production Results & ROI Breakdown
By combining event-driven orchestration, tiered model routing, and static MDX publishing, the system reduced content production costs by 99.9% while maintaining strict human editorial standards:
| Operational Metric | Traditional Agency / Editorial | Arivra Autonomous Content Autopilot | Measured Lift |
|---|---|---|---|
| End-to-End Turnaround | 4 to 6 Hours per article + manual video brief | < 2 Minutes (Article + 60s Script + SEO Audit) | 99% Time Saved |
| Direct Production Cost | ₹2,500 – ₹8,000 per packaged piece | ₹0.20 – ₹0.30 (~$0.003 USD) in raw tokens | 99.9% Cost Reduction |
| Topic Duplication & Cannibalization | High (overlapping keywords across multiple writers) | 0% (Automated Exclusion Constraint via Topic Memory) | Zero Cannibalization |
| Editorial Review Experience | Clunky WordPress/Docs logins & back-and-forth emails | 1-Tap Inline Telegram Approval & /feedback revisions | 10x Faster Founder Review |
| CMS Hosting Infrastructure | ₹1,500 – ₹5,000/mo Database server + plugins | ₹0 (Static Headless MDX on Cloudflare Pages Edge) | Fast Edge Delivery |
Key Takeaways for B2B Teams
- AI Needs State Machines, Not Just Prompts: Reliable automation requires idempotent step-guards, version tracking, and structured JSON validation at every boundary.
- Human-in-the-Loop is the Sweet Spot: Full autonomy without review risks brand reputation; a 1-tap Telegram micro-client gives founders 100% editorial control in 10 seconds from their phone.
- Static MDX Beats Bloated Databases: Pairing an automated content pipeline with a lightweight MDX frontend delivers instant page loads, effortless scaling for hundreds of SEO pages, and zero recurring database costs.
