Knowledge base

Enhance your conversational agent with custom knowledge.

Knowledge bases allow you to equip your agent with relevant, domain-specific information.

Overview

A well-curated knowledge base helps your agent go beyond its pre-trained data and deliver context-aware answers.

Here are a few examples where knowledge bases can be useful:

  • Product catalogs: Store product specifications, pricing, and other essential details.
  • HR or corporate policies: Provide quick answers about vacation policies, employee benefits, or onboarding procedures.
  • Technical documentation: Equip your agent with in-depth guides or API references to assist developers.
  • Customer FAQs: Answer common inquiries consistently.

The agent on this page is configured with full knowledge of ElevenLabs’ documentation and sitemap. Go ahead and ask it about anything about ElevenLabs.

Usage

1# First create the document from text
2knowledge_base_document_text = elevenlabs.conversational_ai.knowledge_base.documents.create_from_text(
3 text="The airspeed velocity of an unladen swallow (European) is 24 miles per hour or roughly 11 meters per second.",
4 name="Unladen Swallow facts",
5)
6
7# Alternatively, you can create a document from a URL
8knowledge_base_document_url = elevenlabs.conversational_ai.knowledge_base.documents.create_from_url(
9 url="https://en.wikipedia.org/wiki/Unladen_swallow",
10 name="Unladen Swallow Wikipedia page",
11)
12
13# Or create a document from a file
14knowledge_base_document_file = elevenlabs.conversational_ai.knowledge_base.documents.create_from_file(
15 file=open("/path/to/unladen-swallow-facts.txt", "rb"),
16 name="Unladen Swallow Facts",
17)
18
19# Then add the document to the agent
20agent = elevenlabs.conversational_ai.agents.update(
21 agent_id="agent-id",
22 conversation_config={
23 "agent": {
24 "prompt": {
25 "knowledge_base": [
26 {
27 "type": "text",
28 "name": knowledge_base_document_text.name,
29 "id": knowledge_base_document_text.id,
30 },
31 {
32 "type": "url",
33 "name": knowledge_base_document_url.name,
34 "id": knowledge_base_document_url.id,
35 },
36 {
37 "type": "file",
38 "name": knowledge_base_document_file.name,
39 "id": knowledge_base_document_file.id,
40 }
41 ]
42 }
43 }
44 },
45)
46
47print("Agent updated:", agent)

Best practices

Content quality

Provide clear, well-structured information that’s relevant to your agent’s purpose.

Size management

Break large documents into smaller, focused pieces for better processing.

Regular updates

Regularly review and update the agent’s knowledge base to ensure the information remains current and accurate.

Identify knowledge gaps

Review conversation transcripts to identify popular topics, queries and areas where users struggle to find information. Note any knowledge gaps and add the missing context to the knowledge base.

Enterprise features

Non-enterprise accounts have a maximum of 20MB or 300k characters.

Need higher limits? Contact our sales team to discuss enterprise plans with expanded knowledge base capabilities.