Complete guide to creating knowledge bases, uploading documents, crawling websites, and setting up webhook sources for auto-updating AI agent context.
Knowledge bases give your AI agents the context they need to have informed conversations with leads. Instead of relying solely on the system prompt, agents can retrieve relevant information from your knowledge base during each conversation turn using RAG (Retrieval-Augmented Generation).This guide covers every way to build and maintain a knowledge base: manual document uploads, automated website crawling, and webhook sources for live-updating content.
For proprietary content such as product documentation, pricing sheets, FAQs, and sales playbooks. Content is uploaded manually or via webhook sources.
External
For publicly available content such as website pages, blog posts, and help center articles. Content is typically ingested via sitemap crawling.
The type is informational and does not affect how the AI retrieves content. Choose the type that best describes the source of your content so your team can manage knowledge bases effectively.
For content you already have as text (FAQs, product specs, sales scripts), upload documents directly.
1
Upload a document
2
Each document is chunked and synced to the vector store so the AI can retrieve relevant sections during conversations.
3
curl
curl -X POST https://your-api.naturalead.com/api/knowledge-bases/KB_ID/documents \ -H "X-API-Key: nl_live_your_key" \ -H "Content-Type: application/json" \ -d '{ "title": "Pricing FAQ", "content": "Q: What plans do you offer?\nA: We offer Starter ($29/mo), Pro ($99/mo), and Enterprise (custom pricing).\n\nQ: Is there a free trial?\nA: Yes, all plans include a 14-day free trial with no credit card required.", "sourceType": "text" }'
Python
response = requests.post( f"https://your-api.naturalead.com/api/knowledge-bases/{kb_id}/documents", headers={ "X-API-Key": "nl_live_your_key", "Content-Type": "application/json", }, json={ "title": "Pricing FAQ", "content": "Q: What plans do you offer?\nA: We offer Starter ($29/mo), Pro ($99/mo), and Enterprise (custom pricing).\n\nQ: Is there a free trial?\nA: Yes, all plans include a 14-day free trial with no credit card required.", "sourceType": "text", },)doc = response.json()print(f"Uploaded document: {doc['_id']}")
Node.js
const response = await fetch( `https://your-api.naturalead.com/api/knowledge-bases/${kbId}/documents`, { method: "POST", headers: { "X-API-Key": "nl_live_your_key", "Content-Type": "application/json", }, body: JSON.stringify({ title: "Pricing FAQ", content: "Q: What plans do you offer?\nA: We offer Starter ($29/mo), Pro ($99/mo), and Enterprise (custom pricing).\n\nQ: Is there a free trial?\nA: Yes, all plans include a 14-day free trial with no credit card required.", sourceType: "text", }), });const doc = await response.json();console.log(`Uploaded document: ${doc._id}`);
4
Verify your documents
5
List all documents in the knowledge base to confirm the upload.
Launch a crawl job to fetch and ingest the pages. You can control the scope with maxPages and optionally enable LLM distillation to extract clean content from HTML.
Step 5: Set up webhook sources for auto-updating content
Webhook sources let you automatically pull content from external APIs on a schedule. This is useful for keeping your knowledge base in sync with content that changes frequently, such as a CMS, helpdesk, or product catalog.
1
Create a webhook source
2
A webhook source can be a simple URL fetch or a multi-step flow. At minimum, provide a name and either a url or steps array.
Webhook sources store authentication credentials (headers, auth config) in the database. Use dedicated service accounts with minimal permissions for external API access, and rotate credentials regularly.
When a conversation is active, the AI agent queries the attached knowledge base on each inbound message to retrieve relevant context before generating a response.