Documentation agent
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 an API Request tool for document retrieval
- Create an assistant with Claude Sonnet 4.6 and attach the tool
- Use the Web SDK to create a React voice widget
- Review completed calls and improve the quality of your assistant over time
Prerequisites
- Vapi account with a private API key for the server examples and a public API key for the Web SDK example
- LlamaCloud account on a Starter, Pro, or Enterprise plan, plus an API key
- A Vapi Bearer Token custom credential configured with your LlamaCloud API key,
Authorizationas the header name, and the Bearer prefix enabled - Documentation files in a format supported by LlamaCloud
Get started
Index your documentation
Create a searchable index with LlamaCloud Index v2:
- Create a directory and add the documentation files you want to search.
- Create an index that uses the directory as its source.
- Wait until the index status is
ready, then copy the index ID. You use this ID when you configure the Vapi tool.
Index v2 parses, chunks, embeds, and indexes the files automatically. LlamaCloud manages the chunking and embedding settings. For more details, see the LlamaCloud Index getting started guide.
Create the retrieval tool
Create an API Request tool that connects your assistant to your LlamaCloud index.
Dashboard
TypeScript (Server SDK)
Python (Server SDK)
cURL
- Navigate to Tools in your Vapi Dashboard.
- Click Create Tool.
- Select API Request as the tool type.
- Under Base Configuration, enter:
- Tool Name:
docsquery - Description:
Search the documentation index for relevant information - Request URL:
https://api.cloud.llamaindex.ai/api/v1/retrieval/retrieve - Request HTTP Method:
POST
- Tool Name:
- Under Authorization, select the Bearer Token custom credential that contains your LlamaCloud API key.
- Under Request Body, add a required String property named
querywith the descriptionThe search query to find relevant documentation. - Under Static Body Fields, add a String field named
index_idand set its value to your LlamaCloud index ID. - Add a Number field named
top_kand set its value to5. - Select Publish, then copy the tool ID.
Replace YOUR_LLAMACLOUD_INDEX_ID and YOUR_LLAMACLOUD_CREDENTIAL_ID with the values for your LlamaCloud index and saved Vapi credential. The index_id field identifies the index, and top_k limits each retrieval to five results. The model supplies query for each retrieval.
LlamaCloud returns matches in results; the retrieved text is available in each result’s content field.
Create an assistant with the tool
Create an assistant with the API Request tool attached.
Dashboard
TypeScript (Server SDK)
Python (Server SDK)
cURL
- Navigate to Assistants in your Vapi Dashboard.
- Click Create Assistant.
- Configure the assistant:
- Name:
Docs agent - Model: Claude Sonnet 4.6 (Anthropic)
- Voice: Elliot (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
- Name:
- Add the
docsquerytool in the Tools section. - Publish the assistant.
Replace YOUR_TOOL_ID with the tool ID from the previous step. Save the assistant ID from the response for the next step.
Update the assistant's first message
Change your assistant’s first message after creation.
Dashboard
TypeScript (Server SDK)
Python (Server SDK)
cURL
- Navigate to your assistant in the Vapi Dashboard.
- Change the first message to
Hello! I am your documentation assistant. What would you like to know about our platform?. - Select Publish to make the draft current.
Dashboard edits remain in a draft until you publish them. See Versioning with assistants for the complete publishing workflow.
Test the assistant
Test important decisions and complete conversation outcomes before sharing the assistant with users.
Start with a greeting, a supported documentation question, an ambiguous question, a tool error, and an unrelated request. See testing voice agents for guidance on building and maintaining coverage.
Create a React voice widget
In an existing React project, use the Vapi Web SDK to create a voice widget for your documentation assistant.
React (Web SDK)
Replace YOUR_PUBLIC_API_KEY and YOUR_ASSISTANT_ID with your actual values:
For a complete implementation with waveform visualization, real-time transcripts, and responsive design, check out our voice widget component on GitHub.
Review calls and improve your prompts
After a call ends, review its transcript, messages, and tool activity. Look for the questions users ask, how the assistant searches the index, and where its answers need improvement.
Dashboard
TypeScript (Server SDK)
Python (Server SDK)
cURL
- Navigate to Observe > Logs, then select Calls.
- Select a completed call to view its details.
- Review the transcript, messages, and tool activity.
- Use insights to improve your assistant’s prompts and responses.
Review several calls before drawing conclusions. Update the system prompt when the same misunderstanding appears repeatedly. Refine the docsquery description or request schema when the assistant searches with incomplete or irrelevant queries. For automated summaries and evaluations, configure structured outputs.