CASE STUDY

AI-Powered Natural Language to SQL Chatbot

For Logistics Shipment Management

Conversational Analytics for Role-Based Shipment Insights. An intelligent NL-to-SQL chatbot that empowers logistics teams to ask questions in plain English and get real-time, role-based shipment insights with summaries, alerts and visualizations.

DatabaseAlertsAnalyticsShipmentsReal-time APIsRole-based Access
Logistics Assistant
Show me delayed shipments this week.
Here are the delayed shipments this week.
Delayed Shipments128
In Transit Shipments642
On Time Deliveries1,324
Shipment IDOriginDestinationDelay (Days)Status
SHP10023MumbaiDelhi2Delayed
SHP10087ChennaiBengaluru1Delayed
SHP10091KolkataAhmedabad1Delayed
Ask anything about your shipments...

Business Challenges

Data accessibility gapbusiness users (Admin, Shipments Viewer, etc.) needed shipment insights but lacked SQL skills, creating dependency on technical teams for even simple reports.

Delayed decision-makingmanual report generation for delayed shipments, transit status, and delivery predictions slowed operational response times.

Fragmented visibilityshipment alerts, transit states, and delivery performance data lived in disparate systems (LangSmith API, custom APIs, database), making a unified view difficult.

Role-based access controldifferent stakeholders needed different levels of data visibility and action permissions, which plain SQL access could not enforce.

No predictive insightteams could see historical data but had no easy way to compare expected vs. actual delivery performance or anticipate delays.

Solution Provided

Built an AI-powered natural language to SQL chatbot that lets users query shipment data conversationally, removing the SQL knowledge barrier.

Implemented role-based access (Admin, Shipments Viewer, etc.) so query results and available actions are scoped to the user's permissions.

Used AI prompt engineering to translate human language into accurate SQL queries against the logistics database, with Python handling execution and data retrieval.

Integrated LangSmith API and custom APIs to pull real-time shipment alerts and enrich query responses with live status data.

Added a data interpretation layer that converts raw query results into meaningful summaries and visualizations (delayed shipments, transit status, expected vs. actual delivery).

Delivered the entire experience through a Gradio-based chat interface combining conversational Q&A with inline graphs and summaries in one screen.

Workflow: From Question to Insight

1

User Query

Business user types a question in plain English in the Gradio chat interface. "Show me delayed shipments this week."

2

Role Check

System checks the user's role (Admin, Shipments Viewer, etc.) to scope what data and actions are permitted.

3

AI Prompt to SQL

An AI prompt converts the natural language question into an accurate SQL query tailored to the logistics schema.

4

Python Data Fetch

Python executes the generated SQL against the database and retrieves the relevant shipment records.

5

Alert Enrichment

Live shipment alerts are pulled in parallel from the LangSmith API and custom APIs to enrich the result set.

6

Interpretation Layer

Raw results are interpreted into summaries, delay flags, and expected-vs-actual delivery predictions.

7

Gradio Output

Final graphs, summaries, and alerts are rendered back to the user inside the same chat interface.

User query → Role check → AI prompt to SQL → Python data fetch → LangSmith / custom API alerts → Interpretation layer → Gradio dashboard output.

Value Delivered

Democratized Data Access

Non-technical users across roles can now query shipment data conversationally, cutting dependency on data/IT teams for routine reports.

Faster Operational Response

Real-time visibility into delayed shipments and transit status enables quicker corrective action.

Improved Delivery Forecasting

Expected vs. actual delivery comparisons give logistics teams an early-warning signal on performance gaps.

Unified Alerting

Consolidating LangSmith and custom API alerts into one chat interface eliminated the need to check multiple systems.

Governed Access

Role-based permissions ensured Admins and Shipments Viewers see only what's relevant to their function.

Better User Experience

Gradio-based chat plus visual summaries reduced the learning curve, making shipment analytics accessible on demand rather than through static, delayed reports.

Ask in natural language. Get instant shipment insights.
Smarter decisions. Faster operations.
AI (LLM)PythonLangSmith APIGradio UI