Enhance KB Answers with KB Metadata
Adding metadata to your Knowledge Base (KB) can greatly improve the relevance and accuracy of responses generated by the conversational engine. Metadata serve as connections between business objects and KB data sources or data source elements, enabling more meaningful interactions with users.
Using KB Metadata
In DRUID, metadata is natively managed within the Knowledge Base. This allows seamless linking between KB elements (such as KBDataSource or KBWebsitePage) and your business objects.
By leveraging KB Metadata, you can categorize KB data sources using metadata applied at various levels within the data source hierarchy.
To use the KB metadata, follow these steps:
Step 1: Import the KB Toolkit solution (Versions Prior to 9.31)
For Druidversions prior to 9.31:
- Navigate to the Solution Library.
- Search for the 'KB Toolkit2' solution template and import it.
- Go to Apps and click on the druid-kb2 app.
- In the Base URL field, provide your tenant URL.
- Set the necessary connection strings for the druid-kb2 connector app.
In the variable table, set the password, userNameOrEmailAddress, tenant_name and tenant_id.
Step 2: Establish nomenclature
You can add either tags (simple string metadata) or nomenclature metadata to your KB data sources / elements. However, relying solely on string metadata (tags) may not always be the most effective approach, especially when dealing with multiple nodes or leafs. Instead, consider using metadata nomenclature linked to existing business entities, such as product lists, for more accurate categorization.
Establishing nomenclature within your Knowledge Base (KB) is crucial for linking specific business objects and enhancing content relevance:
- Add the desired business objects (entities) in your solution to serve as KB metadata nomenclatures.
- Add fields of type Entity in the [[KBMetadata]] entity referring to the desired business objects.
- Go to Knowledge Base > Knowledge Base Settings and click Metadata Integrations.
- Select the desired KB Metadata field and choose the integration that brings its values.
Step 3A: Add KB metadata for standard data sources
To add KB Metadata for data sources other than custom data sources:
- Navigate to the desired KB data source and switch to Split view.
- Select the relevant node, leaf, or root.
- Click the Metadata (New) tab.
- Click + Add new. A new Metadata section appears on the page.
- Select the metadata field you want to use and select value.
- Click Save at the bottom of the page.
The legacy Metadata tab remains available to allow validation against the new KB Metadata experience.
You can add multiple metadata records to the same data source, node, or leaf based on your business needs. For example: If you want specific content within a data source to be taken into consideration based on different client type and product type, add multiple metadata records.
Step 3B: Add KB metadata for custom data sources
When working with custom data sources, go to the integration for data extraction and update the Custom Code task to include KB metadata tags.
Example
(function main() {
let responseEntity = EntityFactory.CreateEntityByName("KBCustomDSProcessNodeTask");
responseEntity.Node = EntityFactory.CreateEntityByName("KBWebsitePage");
responseEntity.Node.Context = {};
responseEntity.Node.Context.FileContent = Context.GetResponseEntity().Node.Content;
// Add KB Metadata
responseEntity.Node.Context.Metadata = [{"tag":"personal","Age":23},{"tag":"public"}];
Context.SetResponseEntity(responseEntity);
Context.CompleteAction();
})();
Step 4: Update flows to refine Conversational Engine search
- Adapt flows to gather necessary user information before the user starts asking questions (e.g., client type, product type).
- Set metadata filters within the conversation context based on user data by setting the user-related data in the [[Intent]] entity that handles the predict. The Conversation Engine will search within the KB only based on the metadata filters set in the flow.
- The name property must contain the field name (for example, DocType or ProcessType), without the [[KBMetadata]] prefix.
- The value property must contain the actual metadata value (for example, 'Lease contract' or 'Risk assessment').
- This configuration ensures that the prediction is made only on data sources or nodes that contain the specified metadata values.
- Ensure consistent updating of metadata filters throughout the conversation as needed. The metadata filters set in the flow are stored in the conversation context. If you want to widen or narrow the knowledge base search scope, add or remove metadata filters at different points in the conversation.
Example: Filter by ProductType and ClientType and Tag.
You can set complex metadata filters within the conversation context by setting [[Intent]].KBQueryObject in the Set Variables component and using Code extension to define tailored conditions based on specific metadata fields.
(
function ()
{
let JResult=
{
operator : "AND",
children : [
]
}
JResult.children.push (
{ operator: "=",
name: "DocType",
value: "Lease contract"
}
);
JResult.children.push (
{
operator: "=",
name: "ProcessType",
value: "Risk assessment"
}
)
return JResult;
}
)()






