Chatbot knowledge base

I figured out the issue with the knowledge base search. The workflow I wanted to implement was as follows: the user enters the chat and can either choose one of the options or ask a question in free form. If the question doesn’t contain specific words like “purchase” (which would immediately direct them to sales), the bot would start searching for relevant information.
However, the problem is that the search trigger works differently. It uses the input provided after the trigger is activated for the search. The question the user asked before that is not processed by the chat in any way.
So, the interaction flow with the user will not be like this:
Start → Trigger with question options → Free-form user input → Search in the database → Display result
but rather like this:
Start → Trigger with question options (where we disable free-form input and add an option to “Ask a question”) → Search in the database → Display result.

Maybe we can do smth with this using js snippets? Save message for example