If I had to do it, I would use Raw Input to retrieve the user's question.
Then, I would create a prompt in an AI Task Card to analyze the user's request, categorize the demand, and create a prompt dynamically.
A really simple example of an AI Prompt (this needs further refinement):
-----------------------------
Objective: Identify the specific intent mentioned in the user query and create a simple query for the database.
Categories and Inquiry Types:
- Budget
- Contact info
- ...
Action Steps:
- Get the user intent from the input.
- Categorize the information into one of the categories.
- Create a query based on the user's needs.
- ...
Examples:
Budget Query Example:
- User input: What are the products sold under $500?
- Query: Find price under 500.
- User input: My budget is between $250 and $295.
- Query: Find price between 250 and 295.
Contact Info Query Example:
- User input: What is the company where Albert is working?
- Query: Find company where contactInfo contains Albert.
Notes:
- Ensure accuracy in identifying the information the user is seeking.
- If the user's inquiry overlaps multiple categories, prioritize directing them based on the most prominent or first-mentioned need.
-----------------------------
Save the AI Task result in a variable.
Then, use a Code Card to create the database request using this variable as the Dynamic Query
workflow.rows = await Data2Table.findRecords({
filter: AI.apply(this, [workflow.dynamicQuery] as any)
})
The code for the dynamic Query came from another post where the Botpress Team shared how to do the database request with AI.
Here is the link:
https://discord.com/channels/1108396290624213082/1261019677879177249
Let me know if that help