Restricting Knowledge articles searches in Virtual Agents on the basis of Static Choice Selection.

tayalk17
Tera Contributor

I am looking for a solution where i want to restrict the knowledge base search in Virtual Agent.

Lets say for example I have a topic Self Help and in that i have options A,B,C.

so if the user selects A then the data from the Knowledge Articles relevant to A should only be visible.

3 REPLIES 3

LAKKAR
Kilo Contributor

I think you can achieve this by capturing the user's selection in a Virtual Agent variable and using that value to filter the Knowledge Articles.

For example, if the user selects A, you can pass the corresponding Knowledge Base or filtering criteria to the search. The same approach can be followed for B and C.

If you are using the Contextual Search topic block, it already provides a Knowledge Base input, which can help restrict the search to a particular Knowledge Base.

If all three options belong to the same Knowledge Base but have different categories, you may need to implement custom search filtering based on the selected option.

I would suggest handling this within the Virtual Agent topic rather than creating separate search implementations for every option.

 

kmohammed
Tera Guru

Hi,

 

Yes, this is doable - but the restriction has to be based on a real field on the articles, not on the Static Choice label itself. The pattern is: choice -> variable -> filtered search.

 

1. First create the mapping on the Knowledge side. A, B and C must correspond to something stored on kb_knowledge, for example separate Categories (or Topic values, or separate Knowledge Bases if the split is strict). Tag every article accordingly and make that field mandatory on publish - an article with no A/B/C classification will either show up nowhere or leak into the wrong branch, so this step decides whether the solution actually works.

 

2. In the Self Help topic, keep your Static Choice input (A / B / C) and store the selection in a topic variable, storing the VALUE that matches the article field (the category value), not just the display label.

 

3. Do not then hand the user the out-of-the-box unfiltered Knowledge Search / fallback search - that searches everything the user can read, regardless of your choice. Instead branch on the variable and scope the search you run next:

- If you use a search step in the topic, pass the variable as an additional filter on top of the user's search text, e.g. category = <selected value>, so only articles in that category are searched/returned.

- Or, more deterministic for this use case, skip free-text search in this topic: use a script/lookup step to fetch published articles matching the choice and present them as a list/card choice for the user to pick. Query kb_knowledge with workflow_state = published and category = the selected value, and return the article title/sys_id pairs.

 

4. One caution on the script option: a plain GlideRecord on kb_knowledge does not by itself enforce Knowledge User Criteria (Can Read). Use GlideRecordSecure and check the article is readable by the current user before returning it, or let the out-of-the-box search do the security filtering. The out-of-the-box search always respects user criteria, and your category filter must be added to it, not used as a replacement for it.

 

So: choice A only shows A articles because every A article is categorised A, the topic stores A, and the search/lookup is explicitly filtered category = A - all three parts are needed.

sanjaygupta
Tera Guru

You can do this by using the user's Static Choice selection to filter the Knowledge Articles returned by Virtual Agent.

  • Open Knowledge > Administration > Knowledge Bases.

  • Identify the field used to categorize your articles.

  • Make sure articles have the correct category assigned.

  • Open your Self Help topic in Virtual Agent Designer.

  • Configure the Static Choice options (A, B, and C).

  • Store the selected option in a topic variable.

  • Pass that variable to the Knowledge Search step.

  • Apply the matching category filter to the search results.

For example, selecting A should return only articles belonging to category A.

Make sure the search also respects Knowledge User Criteria (Can Read). Don't bypass the existing knowledge access rules when implementing a custom search.

This lets you filter articles based on the user's selection without creating a separate topic for each option.

 

Hope you find this helpful.