https://retellai.com/?utm_source=discord&utm_medium=seo logo
can you give the reference for how to build a work...
# ❓・ai-evy-support
d
@AI Evy can you give the reference for how to build a working knowledge base for retell and tell me how to use it correctly and also can you tell me the job of the knowledge base and the global prompt and which one guides the agent and which one gives it the examples and how he handles objections and all of that
a
Thanks for tagging me @deadlybadd. I'll look through relevant sources and get back to you shortly.
### Answer ## How to Build and Use a Knowledge Base ### Creating a Knowledge Base You can create a knowledge base using the Retell AI SDK [(1) ]() :
Copy code
javascript
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%22,>
 "<https://docs.retellai.com%22,>
 ],
 knowledge_base_files: [
 fs.createReadStream("../sample.txt") ,
 ],
 }) ;
 console.log(knowledgeBaseResponse.knowledge_base_id) ;
}
main() ;
### What Knowledge Base Does Knowledge bases are a collection of information sources that your agent can access to retrieve relevant information during calls [(2) ]() . They provide additional context to conversations and greatly improve response quality, especially when there's too much information to include in prompts . The system automatically chunks sources, embeds them, and stores them in a vector database . During calls, the agent uses the transcript to find the most relevant chunks from the knowledge base and feeds them to the LLM as context . Retrieved knowledge base content appears under the header "///## Related Knowledge Base Contexts" . ### Knowledge Base vs Global Prompt Knowledge Base: - Supplies supporting information to the agent - Should not be used to provide instructions or prompts to the agent - Automatically retrieves relevant information during conversations Global Prompt: - Used for the agent's overall personality, tone, and universal rules [(3) ]() - Should contain instructions and prompts for the agent [(2) ]() ### Best Practices for Knowledge Base Structure For objections handling, you can structure your knowledge base in different ways. One community member asked whether to put each objection in its own document or combine them into one long document [(4) ]() . For better results: - Use markdown format with clear paragraphs [(2) ]() - Group relevant information together in one chunk - Avoid ambiguity and use specific references like names and dates - For tabular data like pricing, consider reformatting CSV into FAQ-style entrie
s or building custom functions instead of relying on free-text search [(5) ]() ### Using Knowledge Base with Agents To connect a knowledge base to your agent: 1. Open the agent editor [(2) ]() 2. Locate the "Knowledge Base" section 3. Select the knowledge base items you want to use No prompt changes are needed - the knowledge base works automatically when added to an agent . ### Pricing Knowledge base usage costs $0.005 per minute of calls that have knowledge base enabled . The first 10 knowledge bases are free, with additional ones at $8/month per knowledge base .
​ To learn more, see the sources I considered: [[1] Create Knowledge Base](https://docs.retellai.com/api-references/create-knowledge-base) [[2] Knowledge Base](https://docs.retellai.com/build/knowledge-base) [[3] CONVERSATION FLOW AGENT - GLOBAL PROMPT](https://discord.com/channels/1186424376300679209/1371534043157500025) [[4] Discord message from @pkleb on 2025-04-18](https://discord.com/channels/1186424376300679209/1294891368505937952/1362644989699559696) [[5] Using knowledge base not how I wanted](https://discord.com/channels/1186424376300679209/1357009953247727808) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
can you give me an example of how a knowledge base is constructed or built like give me a knowledge base to see and learn from
@AI Evy
a
Thanks for the follow-up, @deadlybadd. I'll get back to you soon.
### Answer ## Knowledge Base Construction Examples Based on the Retell AI documentation, here are examples of how to construct a knowledge base: ### Creating a Knowledge Base with JavaScript SDK
Copy code
javascript
import Retell from 'retell-sdk';
const client = new Retell({
 apiKey: 'YOUR_RETELL_API_KEY',
}) ;
const knowledgeBaseResponse = await client.knowledgeBase.retrieve('kb_1234567890') ;
console.log(knowledgeBaseResponse.knowledge_base_id) ;
[(1) ]() ### Knowledge Base Structure Examples The knowledge base supports multiple input types [(2) ]() : **URL Sources**: Import content from web pages, either single pages or entire sites **File Uploads**: Upload documents in supported formats, such as PDFs, TXT, or DOCX **Text Input**: Add custom content directly to the Knowledge Base ### Sample Knowledge Base Response Structure Here's what a knowledge base looks like when retrieved:
Copy code
json
{
 "knowledge_base_id": "knowledge_base_a456426614174000",
 "knowledge_base_name": "Sample KB",
 "status": "in_progress",
 "knowledge_base_sources": [
 {
 "type": "document",
 "source_id": "<string>",
 "filename": "<string>",
 "file_url": "<string>"
 }
 ],
 "enable_auto_refresh": true,
 "last_refreshed_timestamp": 1703413636133
}
[(1) ]() ### Practical Content Examples The documentation suggests these file types for feeding your knowledge base [(3) ]() : - **FAQs**: Help the AI instantly address common customer inquiries - **Company Information**: Provide customers with essential operational details - **Product Information**: Offer detailed and up-to-date information - **Troubleshooting Guides**: Help customers independently resolve issues - **Policy Documents**: Ensure quick access to important legal information ### Setup Process The step-by-step process involves : 1. Navigate to the "Knowledge Base" tab and click "Add" 2. Choose from URL, File, or Text options 3. Add the Knowledge Base to your agent in the agent editor 4. Test in the playground by asking related questions ### Important Considerations Be aware that knowledge base responses can be cached, and there may be situations where outdated information persists even after updates [(4) ]() . Additionally, for websites with mostly images and short words (like menu websites) , the LLM may have difficulty understanding the content [(5) ]() .
​ To learn more, see the sources I considered: [[1] Get Knowledge Base](https://docs.retellai.com/api-references/get-knowledge-base) [[2] Empower AI with Dynamic Knowledge Bases | Retell AI](https://www.retellai.com/features/knowledge-base) [[3] Simplify Support with Retell AI’s Knowledge Base | Retell AI](https://www.retellai.com/blog/knowledge-base-feature) [[4] knowledge base caching](https://discord.com/channels/1186424376300679209/1360231379933069362) [[5] Knowledge base feature does not seem to work](https://discord.com/channels/1186424376300679209/1298885502123905067) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
d
and what about the global prompt can you give a similar structures for it too @AI Evy
a
Thanks for the follow-up, @deadlybadd. I'll get back to you soon.
### Answer ## Global Prompt Structure and Examples ### Purpose of Global Prompt The global prompt is where you specify the agent's persona, identity, and guardrails [(1) ]() . This set of text will be available in every node and will influence all response generation . ### Best Practice for Global vs Node Prompts According to Retell's guidance, node prompts take precedence over the global prompt when both are present [(2) ]() . The recommended approach is : - Use the Global Prompt for tone, identity, and general rules - Use Node Prompts for specific actions or logic per step - Avoid duplication—Global = default, Node = override ### Global Prompt in API Structure When creating a conversation flow via API, the global prompt is included as part of the configuration [(3) ]() :
Copy code
json
{
  "global_prompt": "You are a helpful customer service agent."
}
### Configuration Location In the conversation flow setup, you write the global prompt in Step 4 of the global settings configuration [(1) ]() . This is where you specify the agent's persona, identity, guardrails, etc . ### Example from Community Discussion One community member mentioned using 17 pages of instructions in a single prompt agent, demonstrating that global prompts can be quite comprehensive when needed [(4) ]() . The global prompt serves as the foundational instruction set that guides your agent's behavior across all interactions, while node-specific prompts handle particular conversation states or actions.
​ To learn more, see the sources I considered: [[1] Step 1: Configure global settings](https://docs.retellai.com/build/conversation-flow/global-setting) [[2] Which takes precedence: The Global Prompt OR Nodes?](https://discord.com/channels/1186424376300679209/1400673644065325149) [[3] Create Conversation Flow](https://docs.retellai.com/api-references/create-conversation-flow) [[4] Discord message from @development_org_26839 on 2025-07-04](https://discord.com/channels/1186424376300679209/1186462578310910112/1390774938679378011) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.