Get startedGet started for free

Adding example queries

1. Adding example queries

Your space is connected to data, but how do you ensure Genie answers common questions correctly every time? That's where example queries come in.

2. Why example queries matter

Example queries are pre-written SQL that Genie uses when users ask certain types of questions. Genie won't know your baseline logic, like how Bakehouse defines "approved supplier" or which joins to use across sales_transactions, sales_franchises, and sales_suppliers. Add examples whenever a calculation is non-standard, involves multiple joins, or has business-specific filters, such as defining what "Active User" means in your context. When a user's question matches an example pattern, Genie uses your verified SQL instead of guessing. Think of it as the SOPs that ensure 100% accurate answers based on your code, not AI guesswork.

3. Static vs parameterized examples

There are two types of example queries. Static examples are for fixed business facts, like "Total sales in Q4 2024?", a one-time reference with hardcoded SQL. Parameterized examples are the most powerful tool. Instead of a static query for "London sales," write "Sales in city" with a placeholder. Now Genie can answer for London, Paris, or Tokyo using your verified join logic. Same logic, different values: that's when parameterization shines.

4. Creating an example query

Here's the Example Queries section in the space configuration. Each example has two parts: a natural language description, phrased how users actually ask, like "Suppliers in city," and the verified SQL that Genie should use. You can add parameters using double curly braces, so the same query works for London, Paris, or any value the user provides. This panel is where you define the "company way" of answering common questions.

5. How Genie routes to examples

Here's how routing works. User asks: "How many muffins did we sell in New York?"

6. How Genie routes to examples

Step one: Genie checks your Example Queries.

7. How Genie routes to examples

Step two: It finds a match: "Sales for product in location."

8. How Genie routes to examples

Step three: It populates "New York" and "muffins" into your verified SQL template.

9. How Genie routes to examples

Result: a 100% accurate answer based on your code, not AI guesswork. The better your description matches how users phrase questions, the more often your example gets used.

10. Best practices

Good examples are focused, documented, and use common business terms. Show a complex join or calculated field like Gross Margin. Add examples that enforce business rules, for instance, counting approved coffee suppliers from sales_suppliers where ingredient equals coffee and approved equals Y. Anti-patterns: using SELECT star teaches nothing; adding easy queries like SELECT count star clutters the system. Only create examples for questions that need your verified logic.

11. Let's practice!

See how example queries shape Genie's responses, and when to use static versus parameterized examples. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.