Skip to content
LovekeshAnandPublic

Latest commit

 

History

41 Commits

Folders and files

Repository files navigation

⏳ Kairos — Autonomous Agency Operations Engine (Notion Track)

"Your code is the engine. Notion is the interface."
Kairos is an enterprise autonomous operating system for agencies, consultancies, and modern teams. It ingests communications across Gmail, WhatsApp, Google Meet transcripts, and Google Docs — structures them with AI — stages human approvals inside an 8-database Notion workspace — and executes real-world dispatches with an immutable audit trail.


🎯 Core Philosophy

  1. Runs Autonomously — Triggered by real-time webhooks, background pollers, and Google Doc links. No manual intervention required.
  2. Humans Control & Approve in Notion — Critical business actions (invoicing clients, dispatching meeting responses) pause at a human-facing Notion status gate before real-world execution.
  3. Closed-Loop Task Tracking — When team members reply "Done" or "In progress" to WhatsApp or Email task alerts, Notion automatically updates task status and appends timestamped progress logs.
  4. Zero-Crash Resilience — Defensive schema mapping, multi-strategy session resolvers, 4-tier AI key rotation, and global process guards ensure zero downtime.
  5. High-Signal Noise Filter — Filters out casual WhatsApp greetings (gm, k, thanks, lol), OTP codes, and marketing newsletters, keeping your Notion workspace clean and business-focused.

🏗️ System Architecture

flowchart TD
    subgraph INBOUND ["1. Inbound Channels"]
        G["📧 Gmail Ingress<br/>(OAuth2 + Cloud Stream)"]
        W["💬 WhatsApp Inbound<br/>(OpenWA Gateway :2785)"]
        M["🎙️ Google Meet / Google Doc<br/>(Gemini Notes & Public Links)"]
        AI_CMD["⚡ AI Command Bar<br/>(Prompt-to-Notion)"]
    end

    subgraph ENGINE ["2. Kairos Multi-Tenant Core (Node.js + Express :3000)"]
        Ingest["📥 Event Ingest & Normalizer"]
        NoiseFilter["🛡️ High-Signal Noise Filter"]
        LLM["🤖 OpenRouter Multi-Model Layer<br/>(4-Key Auto-Failover + NLP Fallback)"]
        Roster["👥 Team Roster Entity Matcher"]
        Telemetry["📊 Live Telemetry & Observability Engine"]
        NotionBridge["🔄 Notion API Bridge<br/>(8 Relational Databases)"]
        Poller["⏱️ Multi-Tenant State Poller<br/>(Every 15s)"]
        Executors["🚀 Autonomous Action Runners"]
    end

    subgraph NOTION ["3. Notion Workspace (Human Control Hub)"]
        DB_MEET[("🎙️ Meetings & Transcripts DB")]
        DB_TASKS[("📋 Tasks DB")]
        DB_TEAM[("👥 Team Roster DB")]
        DB_CLIENTS[("🏢 Clients & Accounts DB")]
        DB_INVOICES[("🧾 Invoices DB")]
        DB_COMMS[("💬 Requests & Reminders DB")]
        DB_DOCS[("📁 Documents & Assets DB")]
        DB_LOGS[("⚡ Run Log & Audit DB")]
        HumanGate{"🙋 Human Review & Approval<br/>(Status Property Edit)"}
    end

    subgraph ACTIONS ["4. Real-World Autonomous Outbound"]
        WASend["📤 WhatsApp Dispatch<br/>(Invoices, Task Alerts, Chat Replies)"]
        GmailSend["✉️ Gmail Delivery<br/>(Task Assignments & Draft Replies)"]
        ClosedLoop["🔄 Closed-Loop Status Updater<br/>('Done' -> Auto-update Notion Task)"]
    end

    INBOUND --> Ingest
    Ingest --> NoiseFilter
    NoiseFilter -->|Actionable| LLM
    LLM --> Roster
    Roster --> NotionBridge
    NotionBridge --> NOTION
    NOTION --> HumanGate
    HumanGate -->|Status: Approved| Poller
    Poller --> Executors
    Executors --> WASend
    Executors --> GmailSend
    WASend & GmailSend --> ClosedLoop
    ClosedLoop -->|Team Reply| DB_TASKS
    Executors --> DB_LOGS
    Executors --> Telemetry
Loading

⚡ The Core Automated Flows

Flow Channel & Trigger AI Intelligence Role Human Approval Gate Autonomous Real-World Action
Flow A — Invoices Invoice created in Notion (Status: New) or via AI Command Bar Extracts invoice metadata, validates amount, formats WhatsApp number Awaiting Approval $\rightarrow$ Approved Dispatches invoice notification & PDF via WhatsApp
Flow B — Meet to Tasks Google Meet transcript or Google Doc URL (POST /webhooks/transcript or AI prompt) Extracts call summary, decisions, and action items (* [Assignee] Task) Assigned in Notion Tasks DB Matches team roster, assigns tasks in Notion, dispatches WhatsApp & Email alerts
Flow C — Inbound Comms Inbound WhatsApp chat or Gmail message arrives Classifies intent (Meeting, Billing, Support), drafts reply, filters noise Awaiting Approval $\rightarrow$ Approved Dispatches drafted reply back to sender via WhatsApp or Gmail
Flow D — Document Hub Contract, NDA, receipt, or brand asset uploaded Indexes file metadata, tags category, extracts AI summary Staged in Documents DB Searchable archive linked to client & project CRM
Flow E — AI Command Center Natural language prompt typed in web dashboard Detects target database, parses entities, or ingests Google Doc transcripts Staged in corresponding DB 1-click execution with direct Notion page link
Closed-Loop Progress Team member replies "Done", "Working on it", or "Blocked" on WhatsApp/Email Classifies progress intent & matches active task Automatic status update Updates Notion task to Done & appends timestamped progress note

🗄️ Enterprise 8-Database Notion Schema

Kairos provisions and connects 8 relational databases in your Notion workspace:

  1. 🎙️ Meetings & Transcripts DB (Meeting Title, Date, Google Doc URL, Executive Summary, Key Decisions, Action Items Count)
  2. 📋 Tasks DB (Task, Source Meeting, Owner, Priority, Due Date, Status, AI Reasoning, Progress Log)
  3. 👥 Team Roster DB (Member Name, Email, WhatsApp Number, Role, Departments, Skills)
  4. 🏢 Clients & Accounts DB (Company Name, Primary Contact, Email, WhatsApp, Status, Total Billed)
  5. 🧾 Invoices DB (Invoice Name, Recipient Name, Phone Number, Amount, Due Date, Status, File)
  6. 💬 Requests / Reminders DB (Item, Source, Sender, Category, Priority, Status, Summary, Human Response)
  7. 📁 Documents & Assets DB (Document Name, File, Source, Sender, Category, File Type, AI Summary)
  8. ⚡ Run Log & Audit DB (Summary, Timestamp, Flow, Trigger Type, Status, Related Item, Error)

📂 Project Structure

Kairos/
├── backend/
│   ├── server.js                     # Express server & process guards (:3000)
│   ├── start.js                      # Unified stack launcher
│   ├── routes/
│   │   ├── aiCommand.js              # Prompt-to-Notion & Google Doc ingestion API
│   │   ├── auth.js                   # Google OAuth, Notion onboarding wizard, WA status
│   │   ├── org.js                    # Multi-tenant workspace management
│   │   ├── team.js                   # Team member roster API
│   │   ├── telemetry.js              # Live telemetry, KPI stats & test-ping API
│   │   └── webhooks.js               # WhatsApp, Gmail & transcript ingress webhooks
│   ├── services/
│   │   ├── aiCommandService.js       # Natural language parser & transcript router
│   │   ├── aiService.js              # High-signal noise filter & response drafter
│   │   ├── dbService.js              # MongoDB Atlas multi-tenant layer
│   │   ├── gmailService.js           # Gmail OAuth2, Watch, & unread inbox poller
│   │   ├── meetingService.js         # Google Doc fetcher & Gemini Notes parser
│   │   ├── notionService.js          # 8-database Notion client with schema resilience
│   │   ├── pipelineService.js        # Multi-tenant periodic poller & flow orchestration
│   │   ├── taskTrackingService.js    # Closed-loop WhatsApp/Email progress updater
│   │   └── whatsappService.js        # OpenWA gateway client with auto-discovery & +91 format
│   ├── models/
│   │   ├── AuditEvent.js             # Telemetry & execution diagnostic schema
│   │   ├── NotionConfig.js           # Multi-tenant Notion 8-DB credentials
│   │   ├── Organization.js           # Workspace metadata
│   │   ├── TeamMember.js             # Team roster with WhatsApp & skills
│   │   ├── User.js                   # Authenticated user accounts
│   │   └── WhatsAppSession.js        # OpenWA companion session registry
│   └── tests/
│       ├── test-pipeline.js          # Full end-to-end pipeline validation
│       ├── test-noise-filter.js      # Noise rejection & business filter test
│       └── test-meet-to-task.js      # Meeting extraction test
│
├── frontend/
│   ├── src/
│   │   ├── App.jsx                   # Modern glassmorphism dashboard & tab navigation
│   │   ├── components/
│   │   │   ├── AICommandCenter.jsx   # Glowing Prompt-to-Notion bar with target badges
│   │   │   ├── OperationsTelemetry.jsx# Real-time KPI counters & diagnostic log stream
│   │   │   ├── TeamManager.jsx       # Team roster with 1-click Ping WA & Ping Email
│   │   │   └── DocumentHub.jsx       # Searchable document & asset gallery
│   └── vite.config.js                # Vite frontend bundler (:5173)
│
├── guide.md                          # Comprehensive architecture & user testing manual
├── package.json
└── README.md

🚀 Quick Start Guide

1. Prerequisites

  • Node.js: v18+ (tested on Node v20/v24)
  • MongoDB Atlas or local MongoDB
  • Notion Account: With an Internal Integration Secret (ntn_...)

2. Installation

# Clone repository
git clone https://github.com/LovekeshAnand/Kairos.git
cd Kairos

# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install

3. Launching Kairos

# In backend terminal: Starts OpenWA Gateway (:2785) + Kairos Core (:3000)
cd backend
node start.js

# In frontend terminal: Starts Vite Dashboard (:5173)
cd frontend
npm run dev

4. Setup in Dashboard

  1. Open http://localhost:5173/ and sign in with Google.
  2. Go to Setup Wizard $\rightarrow$ Paste your Notion Integration Secret and Parent Page URL.
  3. Kairos automatically provisions all 8 Notion databases in seconds!
  4. Pair WhatsApp by scanning the QR code in the Setup tab.
  5. Add your team members in the 👥 Team tab.

🧪 Testing Features

Test 1: Ingest Google Doc Meeting Notes

Paste this command into the AI Command Center bar in the dashboard:

Process meeting transcript from https://docs.google.com/document/d/1pK_vgDqZPTsVuUx0pOsgzY6Y2SQuS6AtCd_HmdPNBE8/edit?usp=sharing
  • Creates call record in Meetings & Transcripts DB.
  • Extracts tasks and assigns to dua saeed in Tasks DB.
  • Dispatches WhatsApp & Email alerts to Dua Saeed.

Test 2: Closed-Loop Progress Reply

Reply to the task email or WhatsApp alert with:

Done, finished the deliverables!
  • Notion task status automatically transitions from Assigned $\rightarrow$ Done!

Test 3: 1-Click Team Connectivity Ping

  1. Go to the 👥 Team tab.
  2. Click Ping WA or Ping Email on any team member card to verify real-time connectivity with millisecond latency metrics.

📜 License

MIT License. Built for autonomous agency operations and modern distributed teams.

Releases

Packages

Contributors

Languages