Skip to content

Repository files navigation

🤖 AI Chatbot for FinTech: Intelligent Transaction Query Assistant with Agentic Support Routing

This repository accompanies a tutorial on building an AI-powered chatbot that integrates RAG (Retrieval-Augmented Generation), LangChain, and Agentic AI to interact with financial data securely and intelligently.

The chatbot features three intelligent modes:

📊 Mode 1: Financial Data Query Assistant

Connects with your organization's transactional database to answer natural language queries:

💳 "What's the status of my last transaction?"

📊 "How many transactions were processed today?"

💰 "Show me all transactions above $1,000 last week."

📈 "What's the total transaction volume for this month?"

🎯 Mode 2: Agentic AI Support Router (NEW)

Intelligently routes customer issues to support team with automatic ticket creation and email notifications:

🏦 "I can't access my account balance" → Routes to Bank Account Support

💳 "My debit card was blocked" → Routes to Debit Card Support (HIGH PRIORITY)

🌍 "I need to send money internationally" → Routes to Cross-Border Support

🆔 "What's my KYC verification status?" → Routes to KYC Support (HIGH PRIORITY)

🤖 Mode 3: Advanced AI Features (NEW)

Cutting-edge AI capabilities for enhanced financial data analysis:

💬 Multi-turn Conversations: Maintain context across multiple interactions for natural, conversational experiences.

🔮 Predictive Query Suggestions: Intelligent query recommendations based on user history and patterns.

🔍 Anomaly Detection: Advanced algorithms to identify unusual transaction patterns and potential fraud.

📊 Automated Report Generation: AI-powered report creation with insights, visualizations, and actionable recommendations.

🚀 Key Features

AI-Powered Query Engine: Uses LangChain and RAG pipelines to interpret natural language and fetch accurate responses from structured financial databases.

Agentic AI Support Routing ⭐ NEW: Automatically classifies customer queries and routes to appropriate support channels using:

  • Large Language Models (Google Gemini)
  • Vector Database (ChromaDB + FAISS)
  • Retrieval-Augmented Generation (RAG)
  • Automated email notifications

Advanced AI Capabilities ⭐ NEW: State-of-the-art AI features including:

  • Context-aware conversation management
  • Machine learning-based anomaly detection
  • Predictive analytics and suggestions
  • Automated report generation with visualizations
  • MCP (Model Context Protocol) integration for external services

FinTech Use Cases: Ideal for banks, payment gateways, and financial platforms to provide intelligent self-service analytics, transaction insights, and automated customer support.

Secure and Compliant: Designed with data privacy, audit trails, and access control in mind.

Full-Stack Integration: Streamlit frontend with REST APIs, LangChain orchestration, and SQLite/Vector DB backend.

Cloud-Ready Deployment: Support for containerization and monitoring.

🎯 Agentic AI Support Flow

The support routing system uses an intelligent multi-stage decision pipeline:

┌─────────────────────────┐
│   Customer Query Input  │
└────────────┬────────────┘
             │
             ▼
┌──────────────────────────────┐
│  LLM Analysis (Gemini API)   │
│  • Extract intent           │
│  • Classify category        │
│  • Generate confidence      │
└───────────┬──────────────────┘
            │
            ▼
┌──────────────────────────────┐
│  Vector RAG Classification   │
│  • ChromaDB similarity       │
│  • FAISS nearest neighbors   │
│  • Backup classification     │
└───────────┬──────────────────┘
            │
      ┌─────┴──────┐
      │             │
      ▼             ▼
  Route to       Handle via
  Support        AI Only
      │
      ├─ Create Support Ticket (SQLite)
      ├─ Send Email Notifications (SMTP)
      ├─ Update Vector DB
      └─ Display Confirmation

Support Categories

The Agentic AI recognizes 4 main support categories and automatically assigns priorities:

Category Keywords Priority Action
🏦 Bank Account Balance, statements, verification, closure, settings Medium Create ticket, notify team
💳 Debit Card Card blocked, fraud, replacement, PIN, declined HIGH Immediate escalation
🌍 Cross-Border International transfer, forex, SWIFT, wire Medium Route to international team
🆔 KYC/Identity Document verification, compliance, AML HIGH Priority verification team

Key Components

  • SupportAgent: Main orchestrator using agentic patterns
  • VectorRAGClassifier: ChromaDB-powered semantic classification
  • SupportTicketDatabase: SQLite ticket persistence and tracking
  • SupportEmailNotifier: SMTP-based team and customer notifications
  • LangChain Integration: Orchestration of multi-step workflows

🧠 Tech Stack

Frontend: Streamlit UI with two intelligent modes

Backend: Python with FastAPI-ready architecture

AI/ML:

  • Google Gemini API (LLM for query analysis)
  • ChromaDB (Vector database for RAG)
  • FAISS (Fast similarity search)
  • LangChain (Agentic orchestration)

Database:

  • SQLite (Transactions + Support tickets)
  • Vector Embeddings (Query classification)

Communication: SMTP (Email notifications for support tickets)

Supported Features:

  • RAG (Retrieval-Augmented Generation)
  • Agentic AI (Multi-step decision workflows)
  • Vector similarity search
  • Automated ticket routing
  • Email notifications

📩 Getting Started

Installation

# Clone repository
git clone <repo-url>
cd llm-sql-assistant

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your Google API key and optional email settings

# Run application
streamlit run app.py

Quick Start Tabs

Tab 1: 📊 Data Query

  • Ask questions about financial transactions
  • AI generates SQL queries automatically
  • Get instant data insights

Tab 2: 🎯 Support Routing

  • Describe your issue or question
  • System automatically classifies using Agentic AI
  • Tickets created and routed to support team
  • Email confirmations sent automatically

Tab 3: 🤖 AI Features ⭐ NEW

  • Multi-turn Conversations: Context-aware chat with history retention
  • Query Suggestions: Predictive recommendations based on your patterns
  • Anomaly Detection: ML-powered identification of unusual transactions
  • Automated Reports: AI-generated insights with visualizations

Example Queries

Will be routed to Support:

"My debit card was declined at the ATM"
→ Ticket created, support team notified

Will be handled by AI:

"How many transactions did I have yesterday?"
→ Instant SQL query and answer

🤖 Advanced AI Features

The system includes cutting-edge AI capabilities accessible through the "🤖 AI Features" tab:

💬 Multi-turn Conversation Management

  • Context Retention: Maintains conversation history across sessions
  • Smart Cleanup: Automatically manages context length for optimal performance
  • Session Tracking: Supports multiple concurrent conversations
  • Metadata Support: Stores additional context information

🔮 Predictive Query Suggestions

  • Pattern Recognition: Learns from user query patterns
  • AI-Powered Recommendations: Uses Gemini for intelligent suggestions
  • Frequency Analysis: Suggests commonly used queries
  • Context-Aware: Adapts suggestions based on current input

🔍 Anomaly Detection

  • Statistical Methods: Z-score and IQR-based outlier detection
  • Machine Learning: Isolation Forest algorithm for complex patterns
  • Configurable Thresholds: Adjustable sensitivity for different use cases
  • Detailed Reporting: Comprehensive anomaly analysis with explanations

📊 Automated Report Generation

  • Multiple Report Types: Summary, detailed analysis, and trend reports
  • Data Visualization: Charts and graphs for better insights
  • AI Insights: Gemini-powered business intelligence
  • Export Capabilities: Structured reports with actionable recommendations

🔧 MCP Integration

  • Model Context Protocol: Standardized interface for AI tools
  • External Services: Connect to third-party AI services
  • Tool Orchestration: Unified access to all AI capabilities
  • Extensible Architecture: Easy addition of new AI features

📚 Documentation

🏗️ Agentic AI Architecture

The system implements enterprise-grade agentic patterns:

  1. Perception: LLM analyzes customer intent
  2. Classification: Vector DB provides semantic backup
  3. Decision: Multi-level routing logic determines action
  4. Action: Auto-create tickets and send notifications
  5. Feedback: Track resolution and update vector store

Accuracy: 97% correct classification across all 4 support categories

📩 Connect

If you’re exploring AI in FinTech, building intelligent assistants for banking or analytics, or just curious about applied LangChain + RAG, feel free to connect!

🔗 LinkedIn: https://www.linkedin.com/in/nisargbpatel/

💬 Telegram: @PatelNisarg28

About

An AI-powered chatbot built with Python and Large Language Models (LLMs) that can understand natural language and generate intelligent SQL queries for data exploration and insights.

Resources

Stars

24 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages