neha_09141
02/24/2025, 6:38 PMAI Evy
02/24/2025, 6:38 PMAI Evy
02/24/2025, 6:39 PMAI Evy
02/24/2025, 6:39 PMjavascript
import Retell from 'retell-sdk';
const client = new Retell({
apiKey: 'YOUR_RETELL_API_KEY',
});
async function main() {
const knowledgeBaseResponse = await client.knowledgeBase.create({
knowledge_base_name: "Sample KB",
knowledge_base_texts: [
{
text: "Hello, how are you?",
title: "Sample Question",
},
],
knowledge_base_urls: [
"https://www.retellai.com",
"https://docs.retellai.com",
],
knowledge_base_files: [
fs.createReadStream("../sample.txt"),
],
});
console.log(knowledgeBaseResponse.knowledge_base_id);
}
main();
Once you have the knowledge base ID, you can connect it to your agent [(2)]() . The knowledge base will be used automatically when added to an agent - no prompt changes needed .
I don't see the exact Create Agent API code with knowledge base ID in the provided documentation, so I cannot provide that specific code snippet. However, you can connect a knowledge base to an agent through the agent editor UI by:
1. Opening the agent editor
2. Locating the "Knowledge Base" section
3. Selecting the knowledge base items you want to use
The agent will then automatically use this information when responding to queries related to the added content .AI Evy
02/24/2025, 6:39 PM