Skip to content
raitulhPublic

About

CallFlow is a smart voice assistant that makes real phone calls to get everyday tasks done for you

Resources

Stars

5 stars

Watchers

0 watching

Forks

Repository files navigation

CallFlow — Self-Improving Autonomous Voice Telephony Platform

CallFlow Banner

An enterprise-grade telephony platform that executes real-world phone calls through CALL-E, evaluates dialogue outcomes against strict schemas, diagnoses failures with an 11-class taxonomy, mutates calling strategies (v1 → v2), and retries until verified task completion.

Built for the CALL-E Phone Call Agents Hackathon

Next.js 15 CALL-E MCP TypeScript 5.7 Prisma 6 Tailwind CSS 3.4 License: MIT Build: Passing Tests: 6/6 Passing

Overview • Key Features • Architecture • CALL-E Protocol • Failure Taxonomy • Strategy Evolution • Three-Tier Memory • Quickstart • Demo Video • Safety & Compliance


🎬 Watch the Full Demo & Pitch (3 Min)

CallFlow Video Walkthrough

▶ Click Here to Watch on YouTube • Demonstrates CALL-E integration, live speech telemetry, failure diagnosis, and self-improving strategy mutation (v1 → v2).


The Problem & The Solution

The Brittle Reality of Open-Loop Voice Bots

Most voice agents follow a rigid, open-loop script:

User Request -> Dial Number -> Speak Script -> Fail Silently on Obstacles

In real-world telecommunications:

  • Schedule Clashes: Contractors and receptionists are frequently booked solid for the requested timeframe.
  • Ambiguity: Receptionists misunderstand open-ended date requests or ask unexpected qualifying questions.
  • Refusals & Friction: Front-desk dispatchers withhold labor rates or demand callbacks.
  • Fragility: When conventional bots encounter any of these real-world barriers, they fail or execute the exact same flawed prompt on the next call.

The CallFlow Closed-Loop Telephony Engine

CallFlow elevates voice agents from blind scripted callers into a deterministic, self-improving closed loop:

graph TD
    Plan["1. Plan Goal & Parameters"] --> Dial["2. CALL-E MCP Dialing"]
    Dial --> Extract["3. Extract Structured Data"]
    Extract --> Eval{"4. 5-Dimension Evaluation"}
    
    Eval -->|Passed: Score >= 0.70 & Available| Verified["8. Verified Recommendation"]
    Eval -->|Failure Detected: Score < 0.70| Fail["5. 11-Class Failure Taxonomy"]
    
    Fail --> Mutate["6. Mutate Strategy (v1 -> v2)"]
    Mutate --> Retry["7. Autonomous Retry Next Provider"]
    Retry --> Dial
Loading

Core Capabilities

  • Direct CALL-E MCP Protocol Integration: Native client for CALL-E's Model Context Protocol tools (plan_call, run_call, get_call_run) with auto-discovered CLI authentication.
  • Dual Telephony Execution Modes:
    • Live Carrier Mode (CALLE_MODE=real): Initiates actual carrier phone calls to destination numbers via CALL-E.
    • Deterministic Simulation Mode (CALLE_MODE=simulated): Zero-cost, high-fidelity multi-turn conversational simulator with speech audio activities for offline testing and hackathon evaluation.
  • 11-Class Failure Taxonomy: Standardized diagnostic engine classifying call impediments into actionable remedies (PROVIDER_UNAVAILABLE, MISUNDERSTANDING, MISSING_INFORMATION, COMPLIANCE_STOP, etc.).
  • Dynamic Strategy Mutation (v1 → v2): Transforms open-ended inquiries into front-loaded, confirmation-first conversational sequences based on diagnostic feedback.
  • Three-Tier Persistent Memory:
    • Tier 1 (Task Memory): Active task scope, structured constraints, and call execution state machine.
    • Tier 2 (Provider Memory): Vendor reputation, historical quotes, scheduling reliability, and opt-out statuses.
    • Tier 3 (Strategy Memory): Cross-task heuristic repository tracking success rates across prompt templates and question orderings.
  • Low-Latency Telemetry & Waveforms: Server-Sent Events (SSE) stream speech turns, diagnostic evaluations, and visual audio waveforms in real time.
  • Built-in Carrier Safety & Ethics: Mandatory identity disclosure, strict E.164 phone whitelisting, zero financial commitments without human consent, and instantaneous Do-Not-Call (COMPLIANCE_STOP) enforcement.

System Architecture

graph TD
    Client([Modern Web Console / SSE Stream]) <--> API[Next.js 15 API Layer]
    
    subgraph Core Orchestration
        API --> Orchestrator[Call Orchestrator FSM]
        Orchestrator --> Planner[Task Planning Engine]
        Orchestrator --> Evaluator[5-Dimension Call Evaluator]
        Orchestrator --> StratGen[Strategy Mutation Generator]
        Orchestrator --> RetryPol[Smart Retry Policy]
    end
    
    subgraph Three-Tier Memory Layer
        Planner <--> TaskMem[(Tier 1: Task Memory)]
        Orchestrator <--> ProvMem[(Tier 2: Provider Memory)]
        StratGen <--> StratMem[(Tier 3: Strategy Memory)]
    end
    
    subgraph Telephony Adapter Layer
        Orchestrator --> AdapterFactory{Adapter Factory}
        AdapterFactory -->|CALLE_MODE=real| RealAdapter[RealCalleAdapter - MCP Streamable HTTP]
        AdapterFactory -->|CALLE_MODE=simulated| SimAdapter[SimulatedCalleAdapter - Multi-Turn Sim]
    end
    
    subgraph External Networks
        RealAdapter -->|Bearer Auth| CalleNetwork[CALL-E PSTN Voice Gateway]
        CalleNetwork --> TelephonyPSTN[Carrier Mobile / Landline]
    end
Loading

Directory Structure

CallFlow/
|-- app/                              # Next.js 15 App Router & API Endpoints
|   |-- api/                          # REST & SSE Streaming Routes
|   |   |-- calls/                    # Call logs & transcript inspectors
|   |   |-- evaluations/              # Evaluation diagnostic records
|   |   |-- memory/                   # Three-tier memory stats
|   |   |-- providers/                # Approved contractor directory
|   |   |-- settings/                 # Telephony & guardrail configurations
|   |   |-- strategies/               # Strategy heuristics & version records
|   |   \-- tasks/                    # Task planning, execution & SSE streams
|   |-- dashboard/                    # KPI metrics, live monitor & CSV exports
|   |-- tasks/                        # Task launcher & scenario templates
|   |   \-- [id]/                     # Real-time mission control & audio visualizer
|   |-- calls/                        # Call inspector & transcripts
|   |-- evaluations/                  # Failure taxonomy reference & logs
|   |-- memory/                       # Memory tiers visualization
|   |-- providers/                    # Contractor management
|   |-- settings/                     # Telephony mode & credentials
|   |-- layout.tsx                    # Dark enterprise root layout
|   \-- page.tsx                      # Landing page with interactive loop simulator
|-- backend/                          # Autonomous Core Telephony Engine
|   |-- agents/                       # TaskPlanner & CallOrchestrator state machine
|   |-- db/                           # Prisma client singleton & schema
|   |-- evaluations/                  # 11-class failure taxonomy & 5D evaluator
|   |-- events/                       # Typed in-memory SSE event bus
|   |-- integrations/calle/           # Unified CalleAdapter, Real & Simulated adapters
|   |-- memory/                       # Three-tier memory persistence store
|   |-- strategies/                   # StrategyGenerator & RetryPolicy
|   \-- types/                        # Core TypeScript domain models
|-- prisma/                           # Database Schema & Seed Script
|   |-- schema.prisma                 # SQLite / PostgreSQL formal schema
|   \-- seed.ts                       # Realistic contractor & strategy seed data
|-- tests/                            # Automated Verification Test Suite
|   |-- unit/                         # Evaluator, Strategy & Planner unit tests
|   \-- e2e/                          # End-to-end 2-call adaptive loop integration test
\-- README.md                         # Comprehensive documentation

CALL-E MCP Integration Protocol

CallFlow communicates with CALL-E using the official Model Context Protocol (MCP) toolset.

1. Planning Phase (plan_call)

Prepares call parameters, sets the objective, and applies safety checks:

{
  "to_phones": ["+15550102"],
  "goal": "Inquire about service availability for tomorrow afternoon and compare hourly rates.",
  "user_input": "Schedule an emergency plumbing service tomorrow between 1:00 PM and 5:00 PM.",
  "language": "English"
}

Server returns: plan_id and confirmation token.

2. Execution Phase (run_call)

Dispatches the verified plan to the carrier network:

{
  "plan_id": "plan_9xK21L8",
  "confirm_token": "tok_m89Q1a"
}

Server initiates outbound carrier phone call and returns run_id.

3. Monitoring Phase (get_call_run)

Polls call progress and streams real-time speech activities into the transcript:

{
  "run_id": "run_01HK94",
  "limit": 100
}

11-Class Failure Taxonomy

When a call concludes, CallFlow diagnoses the specific failure mode using an 11-class taxonomy and prescribes an automated remediation:

Code Description Automated Recovery Action
PROVIDER_UNAVAILABLE Provider is fully booked for requested timeframe Switch to next highest-ranked eligible contractor
MISUNDERSTANDING Recipient misunderstood dates, times, or scope Mutate strategy to Confirmation-First schedule framing
MISSING_INFORMATION Call completed without critical quote/schedule Inject explicit bracketed questions into next attempt
COMMUNICATION_FAILURE Dropped line, noise, or speech unintelligibility Simplify turn lengths and articulate introductory brief
COMPLIANCE_STOP Recipient requested Do-Not-Call (DNC) Immediate halt, record audit log, mark contractor DNC
CALL_REJECTED Callee declined or sent call directly to voicemail Wait backoff window or reroute to alternative provider
INVALID_PHONE_NUMBER Malformed or unreachable E.164 destination Invalidate contractor number and flag for human review
GATEKEEPER_BLOCKED Front desk receptionist refuses transfer Reframe caller brief to emphasize authorized client request
UNREASONABLE_TERMS Quoted pricing exceeds budget or terms violate policy Disqualify quote and contact next candidate
CALLBACK_REQUESTED Provider requests callback from client Record callback window and alert user in summary
TIMEOUT_EXCEEDED Call exceeded duration limits without resolution Synthesize partial findings and trigger compact retry

5-Dimension Evaluation Scoring Rubric

Every call is evaluated against a weighted mathematical scoring rubric (0.00 to 1.00):

Score = (0.35 * Task) + (0.25 * Completeness) + (0.15 * Correctness) + (0.15 * Quality) + (0.10 * Efficiency)

  • Threshold for Success: Score >= 0.70 and Available = true
  • Calls falling below 0.70 automatically trigger the Failure Taxonomy Analyzer and Strategy Mutation Generator.

Strategy Evolution in Action

Real-World Case Study: Emergency Service Coordination

Attempt 1: Strategy v1 (Direct Inquiry Baseline)

  • Spoken Prompt: "Hello! Are you available tomorrow afternoon, and what is your hourly rate?"
  • Receptionist Response: "We're completely slammed tomorrow afternoon, sorry."
  • Evaluation Score: 48% • Status: FAILED
  • Diagnosis: PROVIDER_UNAVAILABLE / MISUNDERSTANDING
  • Mutation Rule: When schedule conflicts arise, front-load the exact window into the opening sentence.

Attempt 2: Strategy v2 (Confirmation-First Schedule Framing)

  • Spoken Prompt: "Hello, this is CallFlow dispatch calling on behalf of our client. To confirm upfront: our client needs a licensed technician tomorrow between 1:00 PM and 5:00 PM. Do you have an opening in that specific window?"
  • Receptionist Response: "Yes, we have a 2:30 PM opening tomorrow. Our standard rate is $95/hr."
  • Evaluation Score: 94% • Status: VERIFIED SUCCESS
  • Verified Outcome: 2:30 PM confirmed @ $95/hr labor rate. Learned strategy saved to Strategy Memory.

Three-Tier Memory Architecture

Memory Tier Scope Storage Mechanism Contents
Tier 1: Task Memory Per-Task Lifecycle In-Memory FSM + DB Current goal, parsed constraints, attempt counter, active call ID, live SSE events.
Tier 2: Provider Memory Persistent Contractor Repository SQLite / PostgreSQL Reliability ratings, pricing quotes, historical response rates, and DNC opt-out whitelist.
Tier 3: Strategy Memory Cross-Task Heuristic Store SQLite / PostgreSQL Phrasing variations, prompt templates, success/failure ratios, and version evolution history.

Local Quickstart

Prerequisites

  • Node.js: v18.0+ (Tested on Node v20 & v24)
  • npm: v9.0+

1. Clone & Install

git clone https://github.com/raitulh/Call-Flow.git
cd Call-Flow
npm install

2. Configure Environment

cp .env.example .env

Default settings operate in zero-cost Simulation Mode using local SQLite.

3. Initialize Database & Seed

npm run db:push
npm run db:seed

4. Run Automated Test Suite

npm test

Runs all 6 unit and end-to-end integration tests with zero errors.

5. Launch the Platform

# Development mode
npm run dev

# Production build and run
npm run build
npm run start

Open http://localhost:3000 in your browser.


Hackathon Demo Video & Walkthrough

CallFlow Video Walkthrough

📺 Watch on YouTube: https://youtu.be/_kr42c5WH64

Interactive 3-Minute Demo Flow

  1. Platform Overview (/): View the closed-loop comparison and test the interactive loop simulator.
  2. Launch Task (/tasks): Select the pre-configured emergency plumbing template and click Build Call Plan.
  3. Live Execution (/tasks/[id]):
    • Watch the 8-stage state machine transition through Planning → Calling → Conversation.
    • Listen to the speech activities and observe real-time waveform oscillations.
    • Call 1: QuickFix Technicians reports afternoon is booked solid → PROVIDER_UNAVAILABLE diagnosed.
    • Mutation: Strategy v1 mutates into Confirmation-First Strategy v2.
    • Call 2: Apex Elite Services confirms 2:30 PM opening @ $95/hr → Evaluator registers 94% verified pass.
    • Review the final Verified Recommendation with extracted evidence.

Safety, Compliance & Carrier Guardrails

  • Mandatory Caller Disclosure: Every call automatically discloses caller identity and scope.
  • Immediate DNC Enforcement: If a contact says "Do not call", the agent triggers an instant COMPLIANCE_STOP, terminates the call, and permanently excludes the number.
  • E.164 Destination Whitelist: Calls to unapproved phone numbers are rejected before dialing.
  • Zero Financial Authority: CallFlow collects quotes and availability but never commits payment without explicit human confirmation.

License

This project is open-sourced under the MIT License. Built for the CALL-E Phone Call Agents Hackathon.

About

CallFlow is a smart voice assistant that makes real phone calls to get everyday tasks done for you

Resources

Stars

5 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages