title: Modular n8n Workflow Architecture

content: The system uses a modular n8n workflow architecture where specific stages of the pipeline (e.g., email processing, voice calling, billing) are distinct workflows triggered by webhooks or internal messages. This avoids a single mega-workflow to prevent maintenance and debugging nightmares.


title: State Management Strategy: PostgreSQL & Redis

content: PostgreSQL is used for persistent state (leads, bookings, audit logs), while Redis is used for transient state and queues (call queues, demo generation queues) to handle high-throughput asynchronous processing.


title: Voice Agent Provider: Telnyx AIVA

content: The system uses Telnyx AIVA for initiating and managing outbound voice calls. Telnyx is configured to make HTTP requests back to the n8n orchestration layer for function calls (e.g., book_demo_call), enabling real-time conversational AI.


title: Intent Classification with Gemini Ultra

content: The 'Instantly_Reply_Processor' workflow utilizes the n8n LLM Node with Gemini-Ultra to perform Intent Classification, Entity Extraction, and Sentiment Analysis on incoming email replies, routing leads based on the LLM's output.


title: Sunaiva Autonomous Revenue Pipeline

content: Sunaiva is defined as a 100% autonomous revenue engine that automates the entire sales cycle. Key features include intent classification from email replies, autonomous voice calling via Telnyx AIVA, RAG-based email responding, Cal.com demo booking, personalized demo video generation, and automated Stripe billing/dunning.


title: Lead to Revenue Automation Flow

content: The core strategic sequence starts with an Instantly.ai email reply, triggers n8n for intent classification, routes high-intent leads to a Redis call queue, executes a Telnyx voice call, books a demo via Cal.com, generates a personalized video, and finalizes payment through Stripe.

steps:
Inbound Email Reply (Instantly)
Intent Classification (LLM)
Routing (Call vs Email)
Voice Call (Telnyx AIVA)
Demo Booking (Cal.com)
Video Generation (Gemini/Veo)
Payment/Dunning (Stripe)


title: Billing and Dunning Automation

content: Stripe webhooks trigger a billing sequence: successful payments provision licenses via FastAPI; failed payments add the customer to a Redis dunning queue, triggering retries and eventually voice calls for collection before revoking access.

steps:
Stripe Webhook
Check Payment Status
Success: Provision License
Failure: Add to Dunning Queue
Retry Logic (Email/Call)
Exhaustion: Revoke Access


title: Modular Architecture as Scalability Moat

content: The modular architecture allows independent scaling of components. For example, the Video Generation workflow can be scaled up during marketing campaigns without affecting the Voice Call latency, preventing system-wide bottlenecks and ensuring high reliability.


title: Speed-to-Lead via Intent Routing

content: Leads classified with high intent (e.g., 'call_now') are immediately added to a Redis queue for urgent processing. This 'Speed-to-Lead' tactic prioritizes real-time voice contact over email, leveraging the psychological principle of immediacy to maximize conversion rates.


title: Hyper-Personalized Video Demos

content: The system generates unique, 2-3 minute video scripts for each booked demo using Gemini, incorporating the lead's company name and pain points. This high-effort personalization builds trust and significantly increases the likelihood of attendance and conversion.


title: Telnyx Function Call Webhooks

content: Telnyx AIVA is integrated with n8n via function call webhooks. During a voice call, AIVA requests n8n to check Cal.com availability or book a slot. n8n processes this, updates PostgreSQL, and returns the result to AIVA to confirm the booking with the human lead.


title: Stripe Webhook to Provisioning

content: Stripe is integrated via webhooks into the n8n 'Stripe_Webhook_Processor'. It listens for 'checkout.session.completed' to trigger the 'Provision License' code node (via internal FastAPI call) and 'invoice.payment_failed' to trigger the dunning workflow.


title: Personalized Demo Video Generation Recipe

content: The 'Demo_Video_Generator' workflow first generates a script via Gemini-Ultra. It then creates custom imagery using Gemini Vision (Imagen 3) and voiceover using Telnyx TTS (NaturalHD). These assets are assembled into an MP4 using FFmpeg on an Elestio VPS and emailed to the lead via Resend.


title: RAG Email Responder Workflow

content: The 'RAG_Email_Responder' workflow embeds the lead's reply using text-embedding-004, performs a semantic search in Qdrant (top 3 results), and passes the context to Gemini-Ultra to generate a contextual reply, which is sent via the Resend API.


title: Instantly Reply Processor Node Sequence

content: The entry point is an Instantly.ai webhook. n8n inserts the raw event into PostgreSQL, extracts key data, runs intent classification via LLM, updates the lead record, and uses a Switch node to route to either the Voice Call Queue, RAG Email Responder, or Unsubscribe handler.