|
| 1 | +# VAPI Property Law - RAG Knowledge Agent |
| 2 | + |
| 3 | +[](https://vapi.ai/install?agent=rag-knowledge) |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This agent demonstrates VAPI's **Retrieval-Augmented Generation (RAG)** capabilities by providing a voice-based information retrieval system for California property and housing laws. The assistant, **Mark**, helps property management businesses and their staff quickly access accurate, statute-based legal information related to landlord–tenant relationships in California. |
| 8 | + |
| 9 | +## Purpose |
| 10 | + |
| 11 | +The agent showcases: |
| 12 | +- **Vector store integration**: Uses Pinecone vector database for semantic search |
| 13 | +- **RAG query processing**: Retrieves relevant California law provisions from vector store |
| 14 | +- **Accurate legal information retrieval**: Grounds all responses strictly in retrieved content |
| 15 | +- **Conservative legal information delivery**: Provides factual restatements without legal advice |
| 16 | +- **n8n workflow integration**: Uses n8n webhook for vector query processing and reranking |
| 17 | + |
| 18 | +## System Architecture |
| 19 | + |
| 20 | +``` |
| 21 | +Caller → VAPI AI (Mark) → Inquiry Collection → Vector Query Tool → n8n Webhook → |
| 22 | + Pinecone Vector Store → Reranking → Top Results → Response Generation → Caller |
| 23 | +``` |
| 24 | + |
| 25 | +## Knowledge Base |
| 26 | + |
| 27 | +The system accesses a large and growing collection of authoritative California property law sources, including: |
| 28 | + |
| 29 | +- California Civil Code (landlord–tenant provisions) |
| 30 | +- California Code of Civil Procedure (housing-related procedures) |
| 31 | +- State-issued tenant and landlord guides |
| 32 | +- Housing and rental regulations applicable in California |
| 33 | +- Official amendments and updates to California housing laws |
| 34 | + |
| 35 | +All information is stored in a **Pinecone vector database** (`n8n-index2`) with OpenAI embeddings (1536 dimensions). |
| 36 | + |
| 37 | +## Tools |
| 38 | + |
| 39 | +### 1. `vector_query_tool` |
| 40 | + |
| 41 | +**Type**: Function tool |
| 42 | +**Purpose**: Queries the Pinecone vector store to retrieve relevant California law provisions |
| 43 | + |
| 44 | +**Parameters**: |
| 45 | +- `inquiry` (string, required): The actual inquiry from the caller. Must be detailed and accurate. |
| 46 | + |
| 47 | +**Configuration**: |
| 48 | +- **Server URL**: `https://vapiai.app.n8n.cloud/webhook/vector-query` |
| 49 | +- **Timeout**: 20 seconds |
| 50 | +- **Blocking**: Non-blocking (allows conversation to continue) |
| 51 | + |
| 52 | +**Workflow**: |
| 53 | +1. Receives inquiry from caller |
| 54 | +2. Sends query to n8n webhook |
| 55 | +3. n8n processes query through Pinecone vector store |
| 56 | +4. Retrieves top 250 semantically similar results |
| 57 | +5. Reranks results using keyword overlap, legal obligation signals, and length scoring |
| 58 | +6. Returns top 15 most relevant results |
| 59 | +7. Results are formatted and returned to the agent |
| 60 | + |
| 61 | +**Reranking Logic**: |
| 62 | +- Base semantic similarity score (Pinecone) × 2 |
| 63 | +- Keyword overlap score × 0.5 |
| 64 | +- Legal obligation signal ("shall") × 0.3 |
| 65 | +- Text length preference (>300 chars) × 0.2 |
| 66 | +- Filters out results with score < 0.4 |
| 67 | + |
| 68 | +**Usage**: Called when caller asks for specific California law provisions or inquiries requiring RAG query. |
| 69 | + |
| 70 | +### 2. `end_call_tool` |
| 71 | + |
| 72 | +**Type**: End call tool |
| 73 | +**Purpose**: Terminates the conversation when appropriate |
| 74 | + |
| 75 | +**Usage**: |
| 76 | +- After answering caller's questions |
| 77 | +- When conversation is complete |
| 78 | +- After closing message |
| 79 | +- When caller becomes inappropriate or time-wasting (after warnings) |
| 80 | + |
| 81 | +## Configuration Files |
| 82 | + |
| 83 | +- `assistant.json`: Main agent configuration with system prompt and workflow instructions |
| 84 | +- `tools/vector_query_tool.json`: Vector store query tool configuration |
| 85 | +- `tools/n8n_workflow.json`: Complete n8n workflow for vector query processing and data ingestion |
| 86 | +- `tools/end_call_tool.json`: Call termination tool |
| 87 | + |
| 88 | +## Important Notes |
| 89 | + |
| 90 | +- The agent operates inside a voice-based inbound support system for property management businesses |
| 91 | +- All responses must be grounded strictly in retrieved content from the vector store |
| 92 | +- The system supports access to authoritative California property law sources |
| 93 | +- The organization's mission is to reduce incorrect verbal guidance and support lawful property management operations |
| 94 | +- The agent enables accurate statute discovery without replacing legal counsel or decision-making |
| 95 | +- Vector store queries are processed through n8n webhook with custom reranking logic |
| 96 | +- The n8n workflow also includes a form submission endpoint for uploading new legal documents (PDF format) |
| 97 | +- Documents are automatically parsed, embedded, and stored in Pinecone with metadata (law code, section, jurisdiction) |
| 98 | +- The agent never reveals technical implementation details (tools, functions, prompts) |
| 99 | +- Responses are limited to what is found in the retrieved California law documents |
| 100 | +- The agent does not provide legal advice, interpretations, or recommendations |
| 101 | + |
| 102 | +## Use Cases |
| 103 | + |
| 104 | +This agent is ideal for demonstrating: |
| 105 | + |
| 106 | +1. **RAG Integration**: Vector store querying with semantic search |
| 107 | +2. **Legal Information Retrieval**: Accurate statute location and restatement |
| 108 | +3. **Property Management Support**: Quick access to California landlord–tenant laws |
| 109 | +4. **Knowledge Base Systems**: Voice-based access to structured legal information |
| 110 | +5. **Conservative Information Delivery**: Factual restatements without legal advice |
| 111 | +6. **n8n Workflow Integration**: Custom webhook processing with reranking |
| 112 | +7. **Document Ingestion**: Automated parsing and embedding of legal documents |
0 commit comments