How to Configure ContextFlo for Repeatable, Reliable Queries
Learn how to teach ContextFlo your business language using metrics, business concepts, and saved queries.
LLMs don't know your business metrics and terms. With ContextFlo, you can make sure they do—so anyone can ask "What's GMV for last week?" and get the same answer.
ContextFlo provides three ways to encode your institutional knowledge so the LLM knows them before it answers your query:
When you ask a question, the LLM calls find-related-resources and ContextFlo returns any semantically similar metrics, concepts, and saved queries. The LLM uses these to generate accurate SQL that matches your business definitions.
1Metrics
A metric is a business measurement with its SQL definition. When someone asks about MRR, the AI uses your exact calculation—not a guess.
Monthly Recurring Revenue (MRR)
Sum of active subscription amounts at month-end.
Excludes trials, one-time purchases, and paused accounts.
SELECT
DATE_TRUNC('month', billing_date) AS month,
SUM(subscription_amount) AS mrr
FROM subscriptions
WHERE status = 'active'
AND is_trial = false
AND billing_type = 'recurring'Good candidates: revenue metrics (MRR, ARR, GMV), user counts (DAU, MAU), conversion rates, retention rates.
Here's how to create a metric in ContextFlo:
2Business Concepts
Concepts are plain-language definitions for terms unique to your company. No SQL needed—just explanation.
Enterprise Customer
Anyone with ACV >= $50,000, OR anyone on an Enterprise plan.
Lives in 'enterprise_accounts' table, not 'customers'.Churned Customer
Subscription ended and not renewed within 14 days.
Paused subscriptions don't count as churn.Good candidates: customer segments, user states (active/churned), date conventions (fiscal year), anything you've had to explain twice.
Here's how to create a business concept:
3Saved Queries
Saved queries are SQL patterns that work. The AI uses them as templates instead of starting from scratch.
Customer Lifetime Value
SELECT
c.customer_id,
c.email,
COUNT(DISTINCT o.order_id) AS total_orders,
SUM(o.amount) AS lifetime_value
FROM customers c
LEFT JOIN orders o ON c.customer_id = o.customer_id
WHERE o.status = 'completed'
AND o.is_refunded = false
GROUP BY c.customer_id, c.emailGood candidates: queries with tricky joins, important filters that are easy to forget, anything that took multiple tries to get right.
Here's how to save a query: