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.
| Shipment ID | Origin | Destination | Delay (Days) | Status |
|---|---|---|---|---|
| SHP10023 | Mumbai | Delhi | 2 | Delayed |
| SHP10087 | Chennai | Bengaluru | 1 | Delayed |
| SHP10091 | Kolkata | Ahmedabad | 1 | Delayed |
Business Challenges
Data accessibility gap – business users (Admin, Shipments Viewer, etc.) needed shipment insights but lacked SQL skills, creating dependency on technical teams for even simple reports.
Delayed decision-making – manual report generation for delayed shipments, transit status, and delivery predictions slowed operational response times.
Fragmented visibility – shipment alerts, transit states, and delivery performance data lived in disparate systems (LangSmith API, custom APIs, database), making a unified view difficult.
Role-based access control – different stakeholders needed different levels of data visibility and action permissions, which plain SQL access could not enforce.
No predictive insight – teams 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
User Query
Business user types a question in plain English in the Gradio chat interface. "Show me delayed shipments this week."
Role Check
System checks the user's role (Admin, Shipments Viewer, etc.) to scope what data and actions are permitted.
AI Prompt to SQL
An AI prompt converts the natural language question into an accurate SQL query tailored to the logistics schema.
Python Data Fetch
Python executes the generated SQL against the database and retrieves the relevant shipment records.
Alert Enrichment
Live shipment alerts are pulled in parallel from the LangSmith API and custom APIs to enrich the result set.
Interpretation Layer
Raw results are interpreted into summaries, delay flags, and expected-vs-actual delivery predictions.
Gradio Output
Final graphs, summaries, and alerts are rendered back to the user inside the same chat interface.
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.
Smarter decisions. Faster operations.
