Documentation agent

Build a voice assistant that answers questions about your docs

Try our live implementation using the voice widget in the bottom-right corner of this page.

Overview

Build a voice-powered documentation assistant step by step. Choose between using the Dashboard interface or programmatic APIs to suit your workflow.

You’ll learn to:

  • Index your docs with LlamaCloud
  • Create a RAG tool for document retrieval
  • Create an assistant with Claude 3.5 Sonnet and attach the tool
  • Use the Web SDK to create a widget
  • Analyze user sessions and improve the quality of your agent overtime

Prerequisites

Get started

1

Index your documentation

Upload and index your documentation in LlamaCloud using text-embedding-3-small.

  1. Create a new project in LlamaCloud
  2. Upload your documentation files (you can use a single consolidated file like llms-full.txt)
  3. Configure embedding model to text-embedding-3-small
  4. Set chunking to 512 tokens with 50 token overlap
  5. Note your index ID and API credentials

Consolidate your documentation into a single text file for better RAG performance. You can see our example at docs.vapi.ai/llms-full.txt.

2

Create the RAG tool

Create a tool that connects your assistant to your LlamaCloud index.

  1. Navigate to Tools in your Vapi Dashboard
  2. Click Create Tool
  3. Select API Request as the tool type
  4. Configure the tool:
    • Name: docsquery
    • Function Name: docsquery
    • Description: Search through documentation to find relevant information
    • URL: https://api.cloud.llamaindex.ai/api/v1/pipelines/YOUR_PIPELINE_ID/retrieve
    • Method: POST
    • Headers: Add Authorization: Bearer YOUR_LLAMACLOUD_API_KEY
    • Body: Configure to send the query parameter
  5. Save the tool and note the tool ID

Replace YOUR_PIPELINE_ID with your LlamaCloud pipeline ID and YOUR_LLAMACLOUD_API_KEY with your API key. Save the tool ID from the response for the next step.

3

Create an assistant with the tool

Create an assistant with the RAG tool attached.

  1. Navigate to Assistants in your Vapi Dashboard
  2. Click Create Assistant
  3. Configure the assistant:
    • Name: Docs agent
    • Model: Claude Sonnet 4 (Anthropic)
    • Voice: Harry (Vapi)
    • First Message: Hey I'm Harry, a support agent. How can I help you today? You can ask me questions about Vapi, how to get started or our documentation.
    • System Prompt: Use a helpful documentation assistant prompt with guidelines for using the docsquery tool
  4. Add the docsquery tool in the Tools section
  5. Configure analysis plan for call monitoring
  6. Publish the assistant

Replace YOUR_PIPELINE_ID with your LlamaCloud pipeline ID and YOUR_LLAMACLOUD_API_KEY with your API key. Save the tool ID from the response for the next step.

4

Update assistant properties

Customize your assistant’s behavior and responses after creation.

  1. Navigate to your assistant in the Vapi Dashboard
  2. Edit any properties like system prompt, first message, or voice settings
  3. Changes apply immediately - no republishing needed

SDK changes apply immediately. Unlike Dashboard publishing, programmatic updates take effect right away.

5

Create test suite

Create test scenarios to validate your documentation assistant’s responses.

  1. Navigate to Test > Voice Test Suites in your dashboard
  2. Click Create Test Suite
  3. Add test scenarios with expected behaviors
  4. Run tests to validate assistant performance

Test suites can only be executed through the Dashboard. Navigate to Test > Voice Test Suites to run your created tests.

6

Create a web component

Use the Vapi Web SDK to create a voice widget for your documentation assistant.

$npm install @vapi-ai/web

Replace YOUR_PUBLIC_API_KEY and YOUR_ASSISTANT_ID with your actual values:

1import { useState, useEffect } from 'react';
2import Vapi from '@vapi-ai/web';
3
4export default function VoiceWidget() {
5 const [vapi, setVapi] = useState(null);
6 const [isConnected, setIsConnected] = useState(false);
7 const [transcript, setTranscript] = useState([]);
8
9 useEffect(() => {
10 // Initialize Vapi Web SDK for client-side voice interactions
11 const vapiInstance = new Vapi('YOUR_PUBLIC_API_KEY');
12 setVapi(vapiInstance);
13
14 // Handle call lifecycle events
15 vapiInstance.on('call-start', () => setIsConnected(true));
16 vapiInstance.on('call-end', () => setIsConnected(false));
17
18 // Handle real-time conversation messages
19 vapiInstance.on('message', (msg) => {
20 if (msg.type === 'transcript') {
21 setTranscript(prev => [...prev, { role: msg.role, text: msg.transcript }]);
22 }
23 });
24
25 // Cleanup on component unmount
26 return () => vapiInstance?.stop();
27 }, []);
28
29 // Start voice conversation with documentation assistant
30 const startCall = () => vapi?.start('YOUR_ASSISTANT_ID');
31 const endCall = () => vapi?.stop();
32
33 return (
34 <div style={{ position: 'fixed', bottom: 24, right: 24, background: '#000', color: '#fff', borderRadius: 12, padding: 20, width: 300 }}>
35 {!isConnected ? (
36 <button onClick={startCall} style={{ background: '#12A594', color: '#fff', border: 'none', borderRadius: 8, padding: '12px 24px' }}>
37 Start Voice Chat
38 </button>
39 ) : (
40 <div>
41 <div style={{ maxHeight: 200, overflowY: 'auto', marginBottom: 16 }}>
42 {transcript.map((msg, i) => (
43 <div key={i} style={{ marginBottom: 8, textAlign: msg.role === 'user' ? 'right' : 'left' }}>
44 <span style={{ background: msg.role === 'user' ? '#12A594' : '#333', padding: '8px 12px', borderRadius: 12, display: 'inline-block' }}>
45 {msg.text}
46 </span>
47 </div>
48 ))}
49 </div>
50 <button onClick={endCall} style={{ background: '#e5e7eb', color: '#000', border: 'none', borderRadius: 8, padding: '8px 16px' }}>
51 End Call
52 </button>
53 </div>
54 )}
55 </div>
56 );
57}

For a complete implementation with waveform visualization, real-time transcripts, and responsive design, check out our voice widget component on GitHub.

7

Improve your prompts with call analysis

Vapi automatically analyzes every call. The assistant above includes an analysisPlan with summary and success evaluation configured.

  1. Navigate to Logs > Calls in your dashboard
  2. Click on any completed call to view analysis
  3. Review summary and success evaluation
  4. Use insights to improve your assistant’s prompts and responses

Iterative improvements:

  • Review analysis summaries to identify common user questions
  • Use structured data to track conversation patterns
  • Monitor success evaluations to optimize assistant performance
  • Update your system prompt based on recurring issues
  • Refine RAG retrieval based on query success patterns