Movie chatbot

Ask a movie database questions in plain English. Four Bedrock agents turn them into safe, audited SQL.

Tools
Amazon Bedrock Agents, Claude Opus 4.6, AWS Lambda (Python 3.12), Redshift Serverless, Redshift Data API, Amazon S3, AWS Secrets Manager, API Gateway
A black 1930s Gaumont Kalee 35mm cinema projector
LLM agents. A photograph of the setting, not the project itself.

The problem

Movie Chatbot for Structured Data is an AI-powered conversational application that allows users to query a structured movie database using natural language instead of writing SQL.

Watch the movie chatbot work

An animated walkthrough, not the live chatbot. Pick a question to replay how four Bedrock agents clarify what you mean, write the SQL, wait for your confirmation, run it safely, and explain the answer in plain English.

  1. Orchestrator (done)
  2. SQL Generator (done)
  3. Execution (done)
  4. Explainer (done)

Replay with sample data. Nothing here is sent anywhere.

Which genres made the most at the box office since 2000?

Do you want total box office for each genre, or the average per film?

Confirmed by you
  • Validating the SQL: read-only, movies schema only
  • Checking the cost with EXPLAIN
  • Running on Redshift Serverless through the Data API
  • Writing the audit record to S3

Done. Cancelled automatically if a query ever runs past 110 seconds.

WITH genre_revenue AS (
  SELECT g.genre_name,
         SUM(m.box_office_revenue) AS revenue,
         COUNT(*)                     AS films
  FROM movies.movies m
  JOIN movies.movie_genres g ON g.movie_id = m.movie_id
  WHERE m.release_year >= 2000
    AND m.box_office_revenue IS NOT NULL
  GROUP BY g.genre_name
),
ranked AS (
  SELECT genre_name, revenue, films,
         RANK() OVER (ORDER BY revenue DESC) AS rnk
  FROM genre_revenue
  WHERE films >= 50
)
SELECT genre_name, revenue, films
FROM ranked
WHERE rnk <= 3
ORDER BY rnk;

$41.2B

Action leads on total box office since 2000, ahead of Adventure and Comedy, which release more films but earn less each.

GenreTotal box officeFilms
Action$41.2B612
Adventure$37.9B448
Comedy$29.4B901

Debug: statement_id 3f2a…c91e · exec_time_ms 1,284 · row_count 3

98% answer accuracy100% SQL execution successEvery query confirmed by a human

A visual representation with sample data, not connected to the live chatbot. How it’s built

How I built it

  • Orchestrator.

    The supervisor agent owns the conversation. It asks a clarifying question when a request is ambiguous, delegates to the other three agents, and never runs SQL without explicit confirmation.

  • SQL Generator.

    Writes the query against the movies schema, with every table fully qualified, and a short summary of why that SQL answers the question.

  • Execution.

    The only agent with a tool. It calls a Python 3.12 Lambda that validates the SQL, checks its cost with EXPLAIN, runs it through the Redshift Data API, and cancels it if it passes the time limit.

  • Explainer.

    Explains the result in plain English and always shows a debug panel: the SQL, statement ID, execution time, row count, and correlation IDs.

  • Confirmed twice.

    The Orchestrator requires the user to confirm, and the action itself is marked as requiring confirmation, a second gate against prompt injection.

  • Read-only by design.

    A dedicated read-only database user, credentials in Secrets Manager, and a validator that allows only the movies schema (plus information_schema for lookups) and blocks INSERT, UPDATE, DELETE, DROP, COPY, and UNLOAD.

  • Cost and time guards.

    An EXPLAIN-based cost check before anything runs, a default LIMIT of 200 on non-aggregate queries, and cancellation after 110 seconds.

  • Audited and traceable.

    Every request, allowed or blocked, is written to S3 as an immutable JSONL record, and tracing shows each agent step and tool call.

Results

98%

answer accuracy in project evaluations.

100%

SQL execution success.

2

confirmation gates before any query runs.

In hindsight

Safety and auditing first, the UI last. Next: a column allowlist per table, and a Knowledge Base so the SQL Generator stops inventing columns.
Talk about a project like this