Intelligent ERP Chatbot — Multi-Agent System
Production multi-tenant ERP chatbot answering natural-language business questions against live MySQL with SQL tools, forecasting, Plotly dashboards, and client isolation.
Overview
Built for Royal Soft as a production GenAI system. Multi-tenant clients get a ChatbotID, isolated MySQL access, and a LangChain tool-calling agent that safely queries ERP views, forecasts trends, and returns tables, charts, and and complicated ERP reports in English or Urdu.
Problem
ERP users waste time navigating menus and writing ad-hoc SQL for inventory, sales, and vouchers. Non-technical staff need safe natural-language access without risking production data.
Business challenge
Support hundreds of daily business queries across tenants while enforcing schema allowlists, SQL safety, and per-client database isolation.
Solution
Django application with LangChain AgentManager, schema-aware tools, conversation memory, file-upload context, health monitoring, and multi-modal response formatting.
Architecture
User → Django views → AgentManager (LangChain tools) → per-client MySQL engine + ML/visualization tools → localized multi-modal reply (text, tables, Plotly charts, Excel/PDF).
Implementation
Tool-calling agents with read-only SQL validation, forecasting (Scikit-learn / XGBoost / Prophet), Plotly visualizations, ReportLab/openpyxl reports, ChromaDB where needed, and admin approval flows that mint ChatbotIDs.
Challenges
Multi-tenant connection isolation, preventing unsafe SQL, and returning answers that match each user’s language and technical level.
How we solved them
Per-client engines keyed by chatbot_id, table allowlists, validate_sql_safety checks, language detection, and structured response intelligence for charts vs tables vs summaries.
Security
Admin approval for clients, schema allowlists, SQL safety validation, query row limits, and authenticated chatbot login with isolated database engines.
Results
Live enterprise ERP AI assistant at Royal Soft handling inventory lookups, business Q&A, and KPI dashboards for daily operations.
Key modules
- AgentManager (LangChain tool-calling)
- Client / ChatbotID auth
- SQL + forecast + visualization tools
- Dashboard & health APIs
Features
- Multi-tenant onboarding: apply → admin approve → ChatbotID → isolated DB
- Agent tools: safe SQL, forecasting, Plotly charts, Excel/PDF reports, schema discovery
- File upload into chat context (CSV, Excel, PDF, TXT, JSON)
- English/Urdu language detection and localized responses
- Dashboard health checks and configuration validation
- Conversation persistence and agent logging
My responsibilities
- Designed multi-agent orchestration and tool safety
- Integrated live MySQL ERP views and forecasting stack
- Built Plotly KPI and report generation paths
- Hardened multi-tenant isolation and admin workflows
Outcomes
- Unlimited natural-language business queries
- ~80% fewer manual data lookups
- ~75% faster query resolution
Related projects
AI-Powered Enterprise PHP Code Generation System
Django platform that learns Royal ERP PHP conventions from uploaded codebases and generates deployment-ready modules with validation and ZIP packaging.
SDLC Automation Bot — Meeting to Tasks
Next.js control panel plus n8n workflows that turn meeting transcripts into Claude-treated requirements and TMS tasks via Recall.ai bots.
