Query Templates

Create reusable query templates for common analytics tasks. Save time, ensure consistency, and automate reporting.

📝 What Are Query Templates?

Query templates are:

🎯 Use Cases

📊 Daily Reports

Revenue, signups, and key metrics delivered every morning

🔍 Common Analyses

Customer cohort, product performance, funnel analysis

📈 Executive Dashboards

High-level KPIs for leadership

⚡ Ad-hoc Queries

Template with parameters for custom analysis

✨ Creating Templates

From an Existing Query

  1. Run a query in the chat interface
  2. Click "Save as Template"
  3. Give it a name and description
  4. Add parameters (optional)
  5. Set sharing permissions

From Scratch

  1. Navigate to Templates
  2. Click "+ New Template"
  3. Write your natural language query
  4. Test the query
  5. Add parameters
  6. Save

🔧 Template Configuration

Basic Information

Template Name: Daily Sales Summary

Description: Total revenue, order count, and 
average order value for the selected date.

Category: Sales Reports

Agent: Sales Performance Agent

Query Definition

Show me total revenue, number of orders, 
and average order value for {{date}}. 
Break down by product category.

Parameters

Make templates dynamic with parameters:

Example Parameters:

{{date}} - Date (default: today)
{{region}} - Text (default: all)
{{min_value}} - Number (default: 0)
{{product_category}} - Dropdown (options: Electronics, Clothing, Books)
Parameter Syntax

Use double curly braces: {{parameter_name}}

Parameters can be used anywhere in your query.

📊 Example Templates

1. Daily Revenue Summary

Template: Show me total revenue, order count, 
and average order value for {{date}}

Parameters:
- date (Date, default: today)

Schedule: Daily at 8 AM
Recipients: sales-team@company.com

2. Top Customers by Region

Template: Show me top {{limit}} customers 
in {{region}} by revenue for {{period}}

Parameters:
- limit (Number, default: 10)
- region (Text, default: all)
- period (Dropdown: Last Month, Last Quarter, Last Year)

Schedule: Weekly on Monday
Recipients: account-managers@company.com

3. Product Performance Analysis

Template: Analyze performance for {{product_category}} 
products. Show revenue, units sold, and inventory levels 
for {{time_period}}.

Parameters:
- product_category (Dropdown: All, Electronics, Clothing)
- time_period (Dropdown: Last 7 days, Last 30 days, Last Quarter)

Schedule: On-demand

4. Customer Cohort Analysis

Template: Show cohort retention analysis for customers 
who signed up in {{month}}. Track their activity over 
{{cohort_months}} months.

Parameters:
- month (Month picker)
- cohort_months (Number, default: 6)

Schedule: Monthly on 1st day

⏰ Scheduling Templates

Schedule Options

Configuration Example

Schedule Type: Daily
Time: 08:00 AM (UTC)
Time Zone: America/New_York

Send results to:
- team@company.com
- manager@company.com

Format: Excel (.xlsx)
Include: Chart visualizations
Email Notifications

Requires SMTP settings configured by admin.

See email configuration for setup.

👥 Sharing Templates

Sharing Options

Permissions

🎨 Output Formats

Available Formats

📊 Table View

Interactive table in the app

📈 Charts

Auto-generated visualizations

📑 Excel

.xlsx file for download/email

📄 CSV

.csv file for data export

📧 Email

Results embedded in email

🔗 API

JSON via REST API

📚 Template Library

Browse pre-built templates for common use cases:

Sales & Revenue

Customer Analytics

Product Performance

Marketing

🔄 Template Versioning

Version History

Best Practices

⚡ Running Templates

Manual Execution

  1. Go to Templates
  2. Find your template
  3. Click "Run"
  4. Fill in parameters (if any)
  5. Execute

Via API

POST /api/templates/{template_id}/execute
{
  "parameters": {
    "date": "2024-01-15",
    "region": "North America"
  }
}

See API documentation for details.

🎓 Best Practices

✅ Clear Names

Use descriptive, searchable names

✅ Good Defaults

Set sensible default parameter values

✅ Documentation

Add clear descriptions and usage notes

✅ Test Regularly

Verify templates still work as schema changes

✅ Categorize

Use categories for easy discovery

✅ Version Control

Document changes and maintain history

🚀 Next Steps