retail-analytics-concierge

SkillDatabases & data

Translates natural language questions into SQL queries, executes against the connected data warehouse, and presents results with visualizations. Enables non-technical retail users to self-serve analytics without writing SQL. Use when asked to 'how many units did we sell', 'show me returns by category', 'what is our revenue trend', 'top selling products', 'compare regions', 'query the data', or any analytical question about retail metrics.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the retail-analytics-concierge skill

What this skill tells your AI

The instructions your AI receives, as published by amazon-quick/amazon-quick-official-catalog in skills/data-analytics/retail-analytics-concierge/SKILL.md and read by ahel’s review.

Overview

Enables any retail business user to ask data questions in plain English and get instant answers with charts. Translates natural language into SQL, executes read-only queries against the customer's data warehouse or uploaded files, and presents results with auto-generated visualizations. Includes strict safety guardrails to prevent any data modification.

Workflow

<Definition - Data Source Cascade> Try in order, stop at first success:

  1. Amazon Quick Dataset Q&A (if a QuickSight dataset is configured): ask questions directly in natural language against the full dataset with automatic SQL generation and security enforcement.
  2. SQL-compatible MCP connector detected (any database connector): use for live queries.
  3. Local SQLite or DuckDB file: query directly with run_python.
  4. CSV or Excel file provided: load into in-memory DuckDB via run_python for SQL querying.
  5. Nothing available: ask user to upload a data file or connect their warehouse in Settings. </Definition - Data Source Cascade>

<Definition - Blocked SQL Keywords> These keywords are NEVER allowed in any generated query: DROP, DELETE, UPDATE, INSERT, ALTER, TRUNCATE, CREATE, REPLACE, MERGE, GRANT, REVOKE, EXECUTE, CALL, SET, LOCK, UNLOCK, RENAME, LOAD, COPY INTO. If the user's question would require a write operation, explain that this skill is read-only and suggest they work with their data team for modifications. </Definition - Blocked SQL Keywords>

<Definition - Chart Type Selection> Based on result shape, auto-select visualization:

  • Time series (date column + numeric): line chart.
  • Categories + single metric: horizontal bar chart.
  • Proportions (parts of whole): pie/donut chart.
  • Two numeric dimensions: scatter plot.
  • Ranking (top N): vertical bar chart, sorted descending.
  • Comparison (2-3 groups over time): multi-line or grouped bar. If ambiguous, default to bar chart. </Definition - Chart Type Selection>

<Definition - Schema Context> A description of the customer's data structure that helps generate accurate SQL:

  • Table names and their purpose.
  • Column names with data types and business meaning.
  • Key relationships (foreign keys, join paths).
  • Common filters (date ranges, status values, region codes). Stored in {{config_directory}}/analytics-schema-context.json after first-run discovery. </Definition - Schema Context>

<Workflow - Setup description="First-run schema discovery and connectivity check." tools=[run_python, file_read] triggers=["connect my data", "setup analytics", "get started with analytics", "connect to my database"]

[Decide] Check if {{config_directory}}/analytics-schema-context.json exists:

  • EXISTS: Load saved schema context. Proceed to Answer Question workflow.
  • DOES NOT EXIST: Continue with setup below. Validate: File existence determined. If fails: Assume first run.

[Ask user] "I am your Self-Service Analytics Concierge. I translate your business questions into data queries and visualizations. To get started, I need to connect to your data. Do you have: (1) A CSV or Excel file to upload? (2) A SQLite or DuckDB database file? (3) A data warehouse connector already configured? Tell me what you are working with." Validate: User responds with a data source option. If fails: Re-prompt with examples of supported formats.

[Decide] Detect data source type per <Definition - Data Source Cascade>:

  • SQL MCP connector detected: probe with SELECT 1 or equivalent.
  • Local database file: verify with file_read.
  • CSV/Excel: load into DuckDB with run_python.
  • Nothing: re-ask user. Validate: Connection verified (test query returns a result). If fails: [Ask user] "I could not connect. Please check the file path or connector status in Settings."

[Agent] Discover schema. For SQL connector: query information_schema or equivalent for table names, column names, and types. For CSV/Excel: infer from headers and first 100 rows. Build schema summary: table name, columns (name, type, sample values), row count. Validate: At least 1 table with 2+ columns discovered. If fails: [Ask user] "I found the data but could not read its structure. Can you describe which tables or columns are important?"

[Decide] Is schema_context input provided (a file with table documentation)?

  • Yes: [Agent] Read the file and merge with discovered schema (documentation enriches the raw structure).
  • No: Use discovered schema as-is. Validate: Schema context available (discovered or provided). If fails: Proceed with discovered schema only.

[Agent] Save schema context to {{config_directory}}/analytics-schema-context.json. Include: tables, columns, types, sample values, relationships (if detected), and any user-provided documentation. Validate: File written. If fails: Hold schema in memory for this session.

[Ask user] "Connected! I found [N] tables with [M] total columns. Here is what I see: [table summary] Try asking me a question like: 'How many units did we sell last week?' or 'Show me returns by category.'" Validate: User acknowledges or asks their first question. If fails: N/A.

</Workflow - Setup>

<Workflow - Answer Question description="Translate natural language question to SQL, validate safety, get approval, execute, visualize." tools=[run_python, file_write, open_in_session_tab] triggers=["how many", "show me", "what is", "compare", "top selling", "total revenue", "average", "trend", "breakdown", "which", "list all"]

[Agent] Load {{config_directory}}/analytics-schema-context.json for table/column context. Validate: Schema loaded. If fails: Route to Setup workflow.

[Think] Interpret the user's question. Identify:

  • Target metric (what they want to measure).
  • Dimensions (how they want it grouped/sliced).
  • Filters (time range, category, region, etc.).
  • Comparison (vs prior period, vs another segment?). If ambiguous, prepare a clarifying question. Validate: Clear interpretation or clarifying question ready. If fails: Ask user to rephrase.

[Decide] Is the question ambiguous?

  • Yes: [Ask user] "I want to make sure I get this right. Did you mean [interpretation A] or [interpretation B]?"
  • No: Proceed to SQL generation. Validate: Unambiguous intent established. If fails: Proceed with most likely interpretation, note assumption in response.

[Agent] Generate SQL query using run_python. Apply:

  • Schema context for correct table/column names.
  • LIMIT clause (max_rows).
  • Date casting if date columns are strings.
  • Appropriate aggregations (SUM, COUNT, AVG) based on question. Validate: Valid SQL syntax generated. If fails: Simplify query and retry.

[Agent] Safety check: scan generated SQL for any keyword in <Definition - Blocked SQL Keywords>. Also verify all referenced tables are in approved_schemas (if set). Validate: No blocked keywords found. All tables approved. If fails: Reject query. [Ask user] "This question would require a [blocked operation] which I cannot perform. I am read-only. Can I help with a different question?"

[Ask user] Present the SQL for approval: "Here is the query I will run:

[generated SQL]

This will return [description of expected output]. Shall I execute it?" Validate: User approves (yes, run it, looks good, etc.). If fails: [Ask user] what to change, regenerate SQL, re-present.

[Agent] Execute the approved SQL using run_python:

  • SQL connector: call the connector's query tool.
  • DuckDB/local: execute via duckdb.sql() in run_python. Capture results as a dataframe. Validate: Query returned results (0+ rows without error). If fails: Report the specific error message. Suggest possible fixes (wrong column name, date format, etc.).

[Decide] Did the query return zero rows?

  • Yes: [Agent] Explain possible reasons: date range too narrow, filter too restrictive, column name mismatch. Suggest a broader query.
  • No: Proceed to visualization. Validate: Branch determined. If fails: Present whatever result exists.

[Agent] Generate visualization per <Definition - Chart Type Selection>. Use run_python with highcharts/html_design to create an interactive HTML chart. Save to {output_directory}/analytics-chart-{timestamp}.html. Validate: Chart file created. If fails: Present results as a formatted table instead.

[Agent] Open chart in session tab using open_in_session_tab. Validate: Tab opened. If fails: Provide file path.

[Agent] Present results using <Template - Three Part Result>. Validate: All three parts presented. If fails: Present whatever parts are available.

[Agent] Store this query context (question, SQL, result shape) in session memory so follow-up questions (e.g., "now filter that by region") work without re-stating the full question. Validate: Context stored. If fails: N/A (follow-ups may require re-stating context).

</Workflow - Answer Question>

<Template - Three Part Result>

1. **Direct answer:** {{direct_answer_sentence}}
2. **Visualization:** I have opened an interactive chart in your session tab. See the {{chart_type}} chart showing {{chart_description}}.
3. **Supporting data:**

{{top_10_rows_table}}

</Template - Three Part Result>

Signals

GitHub stars
49
Forks
2
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
retail-analytics-concierge
Source
github.com/amazon-quick/amazon-quick-official-catalog