Building an Autonomous Voice Medical Agent with FalkorDB: 14ms Emergency Triage

Developer uses FalkorDB graph database to build an emergency voice agent that completes 5-hop queries in 14ms and autonomously reserves ICU beds.
CareGraph AI is an autonomous voice emergency triage agent built by developer Roshni Mishra during FalkorDB Graph Hacks. The article notes that vector search excels at text similarity but cannot handle structured graph constraints, while relational SQL latency spikes at 5+ hop joins. FalkorDB, based on a Redis module and GraphBLAS sparse matrices, transforms multi-hop traversal into matrix operations, keeping 5-hop queries around 14 milliseconds. The system models a medical knowledge graph with patients, symptoms, diseases, drugs, hospitals, doctors, and beds, and a single Cypher query can accomplish symptom matching, allergy contraindication checking, hospital and specialist location, and bed reservation. After the query returns, the agent reassures the patient by voice, calls the hospital emergency desk via Twilio, mutates bed status in real time, and creates a queryable session memory node with 24-hour automatic follow-up. The tech stack integrates FalkorDB, Deepgram, Murf Falcon, Twilio, LiveKit, and Next.js, open-sourced and deployed on Vercel.
Most healthcare AI projects are just polite Q&A bots: you say you have a fever, and they suggest drinking water and seeing a doctor. But real emergency triage requires connecting symptoms, allergy history, hospital beds, and specialists in real time—and taking action before the ambulance even departs. Developer Roshni Mishra built CareGraph AI during FalkorDB Graph Hacks—an autonomous voice agent powered by a graph database that completes a 5-hop relationship query in 14 milliseconds, automatically reserves an ICU bed, and notifies the doctor.

Why vector search and SQL fail in emergency scenarios
Before building, the author considered using Pinecone or Postgres. But vector embeddings excel at text similarity (like "what are the symptoms of pneumonia") while being powerless against structured graph constraints: finding a hospital within 15 km that has an available ICU bed, an on-duty pulmonologist, and a flag for the patient's penicillin allergy—this requires graph connections, not vector retrieval.
Relational SQL performance degrades sharply at 5-hop joins. Connecting Patient->Symptom->Disease->Contraindicated Drug->Hospital->Specialist->Available Bed requires 6 levels of nested JOINs, and latency spikes under concurrent emergency queries. FalkorDB, as a Redis module, stores graphs using sparse matrices and GraphBLAS linear algebra; multi-hop traversal is essentially matrix multiplication, keeping latency stably under 15 milliseconds.
Cypher query language is a declarative query language widely adopted in the graph database field, designed specifically for the property graph model. Syntactically, it describes node and edge pattern matching using clauses like MATCH, WHERE, and RETURN, for example (p:Patient)-[:HAS_SYMPTOM]->(s:Symptom). Unlike SQL, which requires explicitly writing multi-table JOINs, Cypher expresses multi-hop paths intuitively through arrows and parentheses, and the database engine can automatically optimize traversal order accordingly. FalkorDB is compatible with the OpenCypher standard, so developers familiar with Neo4j can migrate at low cost. In scenarios like emergency triage that require rapid expansion along multiple relationships, Cypher's expressiveness and the engine's multi-hop optimization capability directly determine end-to-end latency.
GraphBLAS is a standard interface for linear algebra used in graph algorithms, whose core idea is to represent graphs as sparse adjacency matrices and transform operations like breadth-first search and multi-hop reachability into matrix multiplication or semiring operations. FalkorDB is implemented as a Redis module, storing nodes and edges as sparse matrices at the底层 (underlying level), so multi-hop traversal can be executed in parallel using highly optimized C-language matrix kernels, avoiding the overhead of pointer-by-pointer jumps in traditional graph databases. This is precisely the technical foundation for "5-hop queries stably under 15 milliseconds": as hop count increases, computation grows with matrix dimensions rather than exploding nested loops, resulting in a flatter latency curve suitable for concurrent emergency queries.
Architecture design of the medical knowledge graph
The core of CareGraph AI is a medical knowledge graph whose nodes include patients, symptoms, diseases, drugs, hospitals, doctors, and beds, with edges representing relationships like "exhibits," "indicates," "contraindicates," "employs," and "has bed." For example, patient Ramesh is allergic to penicillin, his high fever symptom indicates acute pneumonia, pneumonia requires a pulmonologist, and BHU Center employs Dr. Verma and has available ICU beds.
This explicit relationship modeling avoids stuffing large hospital directories and allergy guidelines into the LLM context window, thereby reducing hallucinations. The agent's decision history is also stored in the graph as AgentSession nodes, forming queryable structured memory rather than messy chat logs.
Triage and resource matching in a single Cypher query
When a patient describes symptoms by voice and the audio is converted to text via Deepgram, the agent executes a 5-hop Cypher query: matching the patient's symptoms to high-risk diseases, cross-referencing allergy contraindications, traversing to find hospitals that simultaneously have the appropriate specialist and an available ICU bed, and returning the diagnosis, allergy warnings, target hospital, on-duty doctor, and bed count.
This query accomplishes diagnosis, contraindication checking, hospital selection, doctor assignment, and bed location all at once. According to the author's testing, the query executes in approximately 14 milliseconds on FalkorDB.
From conversation to action: closed-loop emergency response
Finding a hospital is only the first step. A patient with breathing difficulty at midnight needs action, not advice. After the query returns, the agent immediately:
- Reassures the patient by voice: Using Murf Falcon's sub-250ms speech synthesis (hi-IN-shweta), it informs the patient in Hindi or English that an ICU bed is being reserved.
- Autonomously makes a PSTN outbound call: Via Twilio, it calls the hospital emergency desk, announcing patient information, allergy warnings, and on-duty doctor notification.
- Graph state mutation: Marks the bed node as unavailable in real time and associates it with the patient.
- Persistent session memory: Creates an
AgentSessionnode that automatically triggers a follow-up call 24 hours later to check on the patient's recovery.
PSTN (Public Switched Telephone Network) outbound calling refers to proactively initiating voice calls over the traditional telephone network rather than relying on internet protocols. Twilio's REST API encapsulates this capability as a programmable interface: developers submit the callee number and TwiML instructions, and Twilio dials on their behalf and plays voice or executes interactive logic upon connection. In emergency scenarios, this means the agent can directly call the hospital emergency desk without human intervention, announcing the patient's allergy history and bed reservation request. Compared to SMS or app push notifications, PSTN's advantage is reaching any landline or mobile phone, and hospital on-duty desks typically use this as their primary contact channel, ensuring critical information is delivered within seconds.
Tech stack and deployment
- Graph engine: FalkorDB (Cypher query language + GraphBLAS linear algebra)
- Voice pipeline: Murf Falcon (multilingual Indian TTS) + Deepgram Nova-2 STT
- Communication: Twilio REST API + LiveKit WebRTC
- Frontend: Next.js 14 + Tailwind CSS + interactive Canvas graph physics
- Deployment: Vercel edge network
LiveKit WebRTC is an open-source real-time audio/video infrastructure that provides low-latency audio track transmission, room management, and server-side SDKs based on the WebRTC protocol. In the voice agent architecture, it establishes bidirectional audio streams between the patient's browser or mobile device and the backend agent process, enabling STT (speech-to-text) and TTS (text-to-speech) to run in a near-real-time loop. Compared to traditional telephony voice gateways, the WebRTC path typically has lower end-to-end latency and natively supports web frontend integration, complementing the Next.js frontend and Twilio outbound calling: the former serves online patients, while the latter reaches hospital phone systems.
Three insights from graph databases
Context doesn't bloat: Relationships are explicitly enforced by graph edges, eliminating the need to stuff large documents into the LLM context and reducing hallucination risk.
Graph memory is scalable: Storing sessions and decisions as nodes turns memory into structured history queryable with Cypher.
Speed determines life and death: FalkorDB's C-language matrix implementation keeps multi-hop emergency queries stably around 14 milliseconds, meeting real-time requirements.
The project is deployed on Vercel with open-source code on GitHub, and the author invites developers to discuss practices around agentic memory and graph coordination.
One-line Summary
Developer builds an emergency voice agent with FalkorDB graph database, completing 5-hop queries in 14 milliseconds and autonomously reserving ICU beds.
Paragraph Summary
CareGraph AI is an autonomous voice emergency triage agent built by developer Roshni Mishra during FalkorDB Graph Hacks. The article notes that vector search excels at text similarity but cannot handle structured graph constraints, while relational SQL latency spikes at 5+ hop joins. FalkorDB, based on a Redis module and GraphBLAS sparse matrices, transforms multi-hop traversal into matrix operations, keeping 5-hop queries stably around 14 milliseconds. The system models patients, symptoms, diseases, drugs, hospitals, doctors, and beds as a medical knowledge graph, and a single Cypher query accomplishes symptom matching, allergy contraindication checking, hospital and specialist location, and bed reservation. After the query returns, the agent reassures the patient by voice, makes a Twilio outbound call to the hospital emergency desk, mutates bed status in real time, and creates a queryable session memory node that automatically follows up 24 hours later. The tech stack integrates FalkorDB, Deepgram, Murf Falcon, Twilio, LiveKit, and Next.js, and is open-sourced and deployed on Vercel.
Related articles

Build an AI Super Employee System at Zero Cost: A Full Breakdown of Automated Agent Workflows
A deep breakdown of the AI super employee system demoed on Bilibili: agent orchestration, digital human voiceovers, map and enterprise lead generation, 24/7 customer service, and legal modules. We analyze the business logic and compliance risks behind zero-cost signup to help entrepreneurs judge the real ROI of this AI digital employee system.

The Essential Difference Between Chatbots and AI Agents: Crossing from Conversation to Execution
What's the difference between a chatbot and an AI agent? Based on the MCP series on the Learn Tech channel, this article uses examples like booking flights and summarizing notes to explain: a chatbot only gives answers, while an agent actually completes tasks through a think-act-observe loop. It breaks down the four core components—model, tools, memory, and goal—as well as MCP's role as a bridge, and discusses agents' applicable boundaries and permission risks.

Free GitHub Repo: 342 Hours of AI Courses, from Math to MCP Servers
A free GitHub repo offers 342 hours of AI courses: 523 lessons across 20 phases, from math fundamentals to agent building and MCP servers. Nearly 100,000 learners have started.