Query Templates
Create reusable query templates for common analytics tasks. Save time, ensure consistency, and automate reporting.
📝 What Are Query Templates?
Query templates are:
- Parameterized queries: Reusable with different inputs
- Scheduled reports: Run automatically and send results
- Team assets: Share best practices across your organization
- Version controlled: Track changes and improvements
🎯 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
- Run a query in the chat interface
- Click "Save as Template"
- Give it a name and description
- Add parameters (optional)
- Set sharing permissions
From Scratch
- Navigate to Templates
- Click "+ New Template"
- Write your natural language query
- Test the query
- Add parameters
- 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)
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
- On-demand: Run manually when needed
- Daily: Every day at specified time
- Weekly: Specific day(s) of week
- Monthly: Specific day of month
- Custom cron: Advanced scheduling
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
👥 Sharing Templates
Sharing Options
- Private: Only you can use this template
- Team: Share with specific users or groups
- Organization: Available to all users
Permissions
- View & Run: Can execute the template
- Edit: Can modify the template
- Admin: Can delete and manage 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
Results embedded in email
🔗 API
JSON via REST API
📚 Template Library
Browse pre-built templates for common use cases:
Sales & Revenue
- Daily revenue summary
- Sales pipeline report
- Win/loss analysis
- Quota attainment tracker
Customer Analytics
- Customer lifetime value
- Churn risk analysis
- Cohort retention
- NPS score tracking
Product Performance
- Best/worst sellers
- Inventory levels
- Product affinity
- Return rate analysis
Marketing
- Campaign ROI
- Channel attribution
- Email performance
- CAC by source
🔄 Template Versioning
Version History
- Track all changes to templates
- See who made changes and when
- Revert to previous versions
- Compare versions side-by-side
Best Practices
- Document changes: Add notes when updating templates
- Test thoroughly: Verify results after modifications
- Communicate updates: Notify users of significant changes
⚡ Running Templates
Manual Execution
- Go to Templates
- Find your template
- Click "Run"
- Fill in parameters (if any)
- 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