[URGENT] Custom Knowledge Base Unavailable
# support
g
I created a custom knowledge base and connected it to the Agent. Queries are received correctly from vapi and answers are generated correctly via Qdrant. However, the Agent often produces fabricated answers without waiting for these answers. How can I make the Agent wait for the answer? Prompt didn't work for me. I want to use a custom knowledge base, not a query tool.
v
**Optimize your custom knowledge base endpoint for speed**—slow responses cause the agent to fabricate answers. Make sure your endpoint always responds quickly, even if Qdrant is slow or returns no results. Here’s a code snippet to ensure fast, safe responses:
Copy code
javascript
app.post('/kb/search', async (req, res) => {
  try {
    const results = await searchQdrant(query);
    res.json({ documents: results || [] });
  } catch (error) {
    res.json({ documents: [], error: "Search temporarily unavailable" });
  }
});
This prevents timeouts and ensures the agent waits for your actual data. See [Vapi documentation](https://docs.vapi.ai/knowledge-base/custom-knowledge-base) for more details. Source: - [Custom Knowledge Base | Vapi Documentation](https://docs.vapi.ai/knowledge-base/custom-knowledge-base)
g
Qdrant always returns a response, and response times on n8n are always under 1 second. However, the vapi logs always show "documentCount": 0.
@User Can anyone help with this? The query is successfully sent from vapi and the qdrant response is returned. However, this document is not used on the vapi side and the documentcount is 0.
c
Hi Gokhan, If you need assistance with setting up or configuring a custom knowledge base for your Vapi voice AI assistant, here are some guidelines that might help: 1. Creating a Custom Knowledge Base: - Use the Vapi API to create a custom knowledge base. You'll need to set up a webhook-style integration where Vapi forwards search requests to your server. You can find detailed steps [here](https://docs.vapi.ai/knowledge-base/custom-knowledge-base). 2. Attaching to Your Assistant: - Custom knowledge bases need to be attached via the API. This involves updating the assistant's model configuration, including the full configuration object. Follow the instructions [here](https://docs.vapi.ai/knowledge-base/custom-knowledge-base#step-2-attach-to-your-assistant) for more details. 3. Implementing the Endpoint: - Your server should handle POST requests and return structured responses. Sample implementations can be found in various programming languages like Node.js and Python [here](https://docs.vapi.ai/knowledge-base/custom-knowledge-base#implementing-the-custom-endpoint). 4. Best Practices: - Ensure your API responds quickly, ideally within 50ms, to maintain a smooth conversational flow. - Consider caching frequently requested documents and implementing fast retrieval techniques. If you encounter issues related to data retrieval or the endpoint not being called, make sure the webhook URL is correctly set up and accessible. You may also want to verify that your server is correctly handling the request formats expected by Vapi. For further customization options and advanced configurations, consult the [Custom Knowledge Base](https://docs.vapi.ai/knowledge-base/custom-knowledge-base) documentation.
g
Custom Knowledgebase didn't work consistently. I overcame this issue by using the Custom Tool.
3 Views