https://discord.gg/botpress logo
Is it possible to dynamically filter tables?
# 🤝help
s
I have a table that includes business information for around $500 businesses with descriptions, contact info for multiple people, country, city, etc. Is it possible to dynamically filter results based on a query? For example, what businesses are located in France? Would dynamically filter based on the country column. Or, what is John White's business and contact information? Would filter based on the contact name columns (there are several).
e
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
s
Thanks very much for the detailed response I will give this a try and let you know how it goes
2 Views