Ruben
Ruben7h ago

Knowledgebase

Is there a way to specify where the agent should search in the knowledge base? I have uploaded a table with metadata through the API with upload table, and in certain situations, I want the AI agent to only look at that specific source in the knowledge base, skipping all other sources, such as URL links. I also tried using metadata, specifying to the agent that it could only search certain sources with those metadata fields, but it still searched and recommended items based on other sources instead of the table. How can this be implemented?
1 Reply
Tico | Voiceflow Assistant
You can – but it has to be done with a filtered KB-Query call, not by simply telling the LLM to ignore other sources. 1️⃣ Tag the rows you uploaded via upload/table with a clear metadata field that marks them as the source you want to isolate, e.g.
{
"schema": {
"searchableFields": ["question","answer"],
"metadataFields": ["dataset"] // <- add a flag field
},
"items": [
{
"question": "…",
"answer": "…",
"dataset": "pricing-table" // <- value used later in the filter
}
]
}
{
"schema": {
"searchableFields": ["question","answer"],
"metadataFields": ["dataset"] // <- add a flag field
},
"items": [
{
"question": "…",
"answer": "…",
"dataset": "pricing-table" // <- value used later in the filter
}
]
}
2️⃣ When you need the agent to only look at that table, bypass the built-in KB step and fire the Knowledge-Base Query API yourself (API Step or Function) with a filters object:
POST /v1/knowledge-base/query
{
"question": "What is the monthly fee?",
"chunkLimit": 4,
"filters": {
"dataset": { "$eq": "pricing-table" } // restrict retrieval
}
}
POST /v1/knowledge-base/query
{
"question": "What is the monthly fee?",
"chunkLimit": 4,
"filters": {
"dataset": { "$eq": "pricing-table" } // restrict retrieval
}
}
The query engine will now retrieve chunks only from documents whose dataset metadata equals pricing-table; URL uploads or any other docs are ignored. 3️⃣ Pass the returned chunks to your LLM step (or to a System prompt) to generate the final answer. Important notes • The default Knowledge-Base action inside an agent currently searches every document in the project; there is no UI switch to set filters. Using the Query API (or keeping the table in its own KB) is the recommended way to scope results at runtime. • Make sure the field you filter on appears in metadataFields in the original upload – otherwise it won’t be indexable for filters. • Filters use the same syntax as MongoDB operators ($eq, $in, $and, etc.) so you can combine multiple conditions if needed. Docs for reference • Advanced KB ‑ Filters with metadata: https://docs.voiceflow.com/v2.0/docs/advanced-knowledge-base#filter-with-metadata • KB Query endpoint: https://developer.voiceflow.com/reference/post_knowledge-base-query

Did you find this page helpful?