{"id":30366962,"url":"https://github.com/salman-aziz-4425/support-chatbot","last_synced_at":"2025-08-26T23:37:22.623Z","repository":{"id":306692968,"uuid":"1026953788","full_name":"salman-aziz-4425/support-chatbot","owner":"salman-aziz-4425","description":"A Support Chatbot demonstrating Autogen handoff pattern","archived":false,"fork":false,"pushed_at":"2025-07-28T05:14:48.000Z","size":83088,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-19T23:17:30.096Z","etag":null,"topics":["ai-agents","autogen","fastapi","gen","ollama","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/salman-aziz-4425.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-27T01:43:49.000Z","updated_at":"2025-07-28T05:20:20.000Z","dependencies_parsed_at":"2025-07-27T05:01:45.260Z","dependency_job_id":null,"html_url":"https://github.com/salman-aziz-4425/support-chatbot","commit_stats":null,"previous_names":["salman-aziz-4425/support-chatbot"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/salman-aziz-4425/support-chatbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salman-aziz-4425%2Fsupport-chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salman-aziz-4425%2Fsupport-chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salman-aziz-4425%2Fsupport-chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salman-aziz-4425%2Fsupport-chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/salman-aziz-4425","download_url":"https://codeload.github.com/salman-aziz-4425/support-chatbot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/salman-aziz-4425%2Fsupport-chatbot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272267639,"owners_count":24903742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agents","autogen","fastapi","gen","ollama","python"],"created_at":"2025-08-19T23:11:03.768Z","updated_at":"2025-08-26T23:37:22.591Z","avatar_url":"https://github.com/salman-aziz-4425.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🤖 Multi-Agent Customer Support System\n\nA sophisticated customer support system with AI agents, human agents, and seamless handoffs between them.\n\n## 📁 Project Structure\n\n```\nautogen-project/\n├── main.py                          # Main application entry point\n├── requirements.txt                  # Python dependencies\n├── README.md                        # This file\n├── src/                             # Source code\n│   ├── agents/                      # Agent implementations\n│   │   ├── __init__.py\n│   │   ├── ai_agent.py             # AI agent base class\n│   │   ├── tools.py                # Function tools and delegate tools\n│   │   └── websocket_agents.py     # WebSocket agents for human/user\n│   ├── api/                         # API endpoints\n│   │   ├── __init__.py\n│   │   ├── routes.py               # REST API routes\n│   │   └── websockets.py           # WebSocket endpoints\n│   ├── models/                      # Data models\n│   │   ├── __init__.py\n│   │   └── message_models.py       # Pydantic models for messages\n│   ├── services/                    # Business logic services\n│   │   ├── __init__.py\n│   │   ├── agent_runtime.py        # Agent runtime initialization\n│   │   ├── connection_manager.py   # WebSocket connection management\n│   │   └── transfer_service.py     # Human-to-AI transfer logic\n│   └── utils/                       # Utility functions\n│       ├── __init__.py\n│       └── serialization.py        # Message serialization utilities\n├── static/                          # Static files\n│   ├── index.html                   # Customer chat interface\n│   ├── agent_dashboard.html         # Human agent dashboard\n│   ├── style.css                    # Stylesheets\n│   └── script.js                    # Frontend JavaScript\n└── autogen_env/                     # Virtual environment\n```\n\n## 🚀 Quick Start\n\n1. **Install dependencies:**\n   ```bash\n   pip install -r requirements.txt\n   ```\n\n2. **Start the server:**\n   ```bash\n   python main.py\n   ```\n\n3. **Access the interfaces:**\n   - Customer Chat: http://localhost:8000\n   - Agent Dashboard: http://localhost:8000/agent-dashboard\n\n## 🏗️ System Architecture\n\n```mermaid\ngraph TB\n    %% Client Layer\n    subgraph \"Client Layer\"\n        Customer[\"👤 Customer WebApp\"]\n        Agent[\"👨‍💼 Human Agent Dashboard\"]\n    end\n\n    %% API \u0026 WebSocket Layer\n    subgraph \"Communication Layer\"\n        API[\"🌐 FastAPI Routes\"]\n        WS_Customer[\"🔗 Customer WebSocket\"]\n        WS_Agent[\"🔗 Agent WebSocket\"]\n    end\n\n    %% Core Agent Runtime\n    subgraph \"AutoGen Agent Runtime\"\n        Runtime[\"⚡ SingleThreadedAgentRuntime\"]\n        \n        subgraph \"AI Agents\"\n            Triage[\"🎯 Triage Agent\"]\n            Technical[\"🔧 Technical Agent\"]\n            Billing[\"💳 Billing Agent\"]\n            Sales[\"🛒 Sales Agent\"]\n        end\n        \n        subgraph \"WebSocket Agents\"\n            WSHuman[\"👤 WebSocket Human Agent\"]\n            WSUser[\"📱 WebSocket User Agent\"]\n        end\n    end\n\n    %% Tools \u0026 Services\n    subgraph \"Tools \u0026 Services\"\n        RegularTools[\"🛠️ Regular Tools\"]\n        TransferTools[\"🔄 Transfer Tools\"]\n    end\n\n    %% Data \u0026 State Management\n    subgraph \"Services Layer\"\n        ConnMgr[\"📊 Connection Manager\"]\n        TransferSvc[\"🔀 Transfer Service\"]\n        LLM[\"🤖 Ollama LLM Client\"]\n    end\n\n    %% Message Flow\n    Customer --\u003e WS_Customer\n    Agent --\u003e WS_Agent\n    Agent --\u003e API\n    \n    WS_Customer --\u003e WSUser\n    WS_Agent --\u003e WSHuman\n    API --\u003e ConnMgr\n    \n    WSUser --\u003e Runtime\n    WSHuman --\u003e Runtime\n    \n    Runtime --\u003e Triage\n    Runtime --\u003e Technical\n    Runtime --\u003e Billing\n    Runtime --\u003e Sales\n    \n    Triage -.-\u003e|transfer_to_technical| Technical\n    Triage -.-\u003e|transfer_to_billing| Billing\n    Triage -.-\u003e|transfer_to_sales| Sales\n    Triage -.-\u003e|escalate_to_human| WSHuman\n    \n    Technical -.-\u003e|transfer_back| Triage\n    Billing -.-\u003e|transfer_back| Triage\n    Sales -.-\u003e|transfer_back| Triage\n    \n    Technical --\u003e RegularTools\n    Billing --\u003e RegularTools\n    Sales --\u003e RegularTools\n    \n    Triage --\u003e TransferTools\n    Technical --\u003e TransferTools\n    Billing --\u003e TransferTools\n    Sales --\u003e TransferTools\n    \n    Runtime --\u003e LLM\n    Runtime --\u003e ConnMgr\n    WSHuman --\u003e TransferSvc\n    \n    %% Response Flow\n    WSUser --\u003e WS_Customer\n    WSHuman --\u003e WS_Agent\n    \n    %% Styling\n    classDef clientLayer fill:#3498db,stroke:#2980b9,stroke-width:2px,color:#fff\n    classDef commLayer fill:#e74c3c,stroke:#c0392b,stroke-width:2px,color:#fff\n    classDef agentLayer fill:#f39c12,stroke:#d68910,stroke-width:2px,color:#fff\n    classDef serviceLayer fill:#27ae60,stroke:#229954,stroke-width:2px,color:#fff\n    classDef aiAgent fill:#9b59b6,stroke:#8e44ad,stroke-width:2px,color:#fff\n    classDef wsAgent fill:#1abc9c,stroke:#16a085,stroke-width:2px,color:#fff\n    \n    class Customer,Agent clientLayer\n    class API,WS_Customer,WS_Agent commLayer\n    class Runtime agentLayer\n    class Triage,Technical,Billing,Sales aiAgent\n    class WSHuman,WSUser wsAgent\n    class ConnMgr,TransferSvc,LLM,RegularTools,TransferTools serviceLayer\n```\n\n### Component Details\n\n**🎯 Triage Agent**\n- Routes customer requests to appropriate specialists\n- Tools: Account lookup, transfer functions\n- Handles initial customer contact and request routing\n\n**🔧 Technical Support Agent** \n- Hardware, software, and system troubleshooting\n- Tools: Ticket creation, system status checks\n- Provides step-by-step solutions and escalation handling\n\n**💳 Billing Support Agent**\n- Payment, subscription, and billing inquiries  \n- Tools: Account lookup, ticket creation\n- Handles payment guidance and refund assistance\n\n**🛒 Sales Support Agent**\n- Product information and purchase assistance\n- Tools: Account lookup\n- Provides feature explanations and pricing information\n\n**👤 Human Support Agent**\n- Complex issue resolution and escalation handling\n- Full system override with AI agent transfer capabilities\n- Dedicated dashboard with real-time customer assignment\n\n## Key Components\n\n### 🎯 **Triage Agent**\n- **Role**: Initial customer contact and request routing\n- **Tools**: Account lookup, transfer functions\n- **System Message**: Routes customers to appropriate specialists\n- **Transfers To**: Technical, Billing, Sales, or Human agents\n\n### 🔧 **Technical Support Agent**\n- **Role**: Hardware, software, and system troubleshooting\n- **Tools**: Ticket creation, system status checks\n- **Capabilities**: Step-by-step solutions, escalation handling\n- **Transfers**: Back to triage or human escalation\n\n### 💳 **Billing Support Agent**\n- **Role**: Payment, subscription, and billing inquiries\n- **Tools**: Account lookup, ticket creation\n- **Capabilities**: Payment guidance, refund assistance\n- **Security**: Recommends human verification for sensitive data\n\n### 🛒 **Sales Support Agent**\n- **Role**: Product information and purchase assistance\n- **Tools**: Account lookup\n- **Capabilities**: Feature explanations, pricing information\n- **Approach**: Helpful without being pushy\n\n### 👤 **Human Support Agent**\n- **Role**: Complex issue resolution and escalation handling\n- **Capabilities**: Full system override, AI agent transfers\n- **Tools**: Transfer back to any AI agent with context\n- **Interface**: Dedicated dashboard with real-time customer assignment\n\n## Message Flow Architecture\n\n### Customer to AI Flow\n```\nCustomer Input → WebSocket → Context Building → Triage Agent → LLM Processing → Tool/Transfer Decision → Response/Transfer\n```\n\n### AI Agent Processing\n```mermaid\nsequenceDiagram\n    participant C as Customer\n    participant WS as WebSocket\n    participant T as Triage Agent\n    participant TA as Technical Agent\n    participant LLM as Ollama LLM\n\n    C-\u003e\u003eWS: \"My laptop won't boot\"\n    WS-\u003e\u003eT: UserTask with context\n    T-\u003e\u003eLLM: Process with system message + tools\n    LLM-\u003e\u003eT: transfer_to_technical()\n    T-\u003e\u003eTA: UserTask with transfer context\n    TA-\u003e\u003eLLM: Process technical issue\n    LLM-\u003e\u003eTA: create_support_ticket()\n    TA-\u003e\u003eTA: Execute tool\n    TA-\u003e\u003eLLM: Get response with ticket info\n    LLM-\u003e\u003eTA: Final response\n    TA-\u003e\u003eWS: AgentResponse\n    WS-\u003e\u003eC: Technical solution + ticket ID\n```\n\n### Human Escalation Flow\n```mermaid\nsequenceDiagram\n    participant C as Customer\n    participant AI as AI Agent\n    participant H as Human Agent\n    participant M as Connection Manager\n\n    C-\u003e\u003eAI: Complex request\n    AI-\u003e\u003eAI: escalate_to_human()\n    AI-\u003e\u003eM: Check available agents\n    M-\u003e\u003eH: Assign customer + context\n    H-\u003e\u003eC: Direct communication\n    H-\u003e\u003eAI: transfer_to_technical()\n    AI-\u003e\u003eC: Continues with context\n```\n\n## Technology Stack\n\n- **Framework**: Microsoft AutoGen Core\n- **LLM**: Ollama (llama3.1:latest)\n- **Backend**: FastAPI + WebSockets\n- **State Management**: In-memory with Connection Manager\n- **Agent Types**: RoutedAgent with message handlers\n- **Tools**: Function-based with JSON schema\n- **Communication**: Real-time bidirectional WebSocket\n\n## Key Features\n\n- ✅ **Intelligent Routing**: Context-aware customer request routing\n- ✅ **Stateful Conversations**: Full context preservation across transfers\n- ✅ **Seamless Escalation**: Human agents can take over any conversation\n- ✅ **Bidirectional Transfers**: Humans can transfer back to AI specialists\n- ✅ **Real-time Communication**: WebSocket-based instant messaging\n- ✅ **Agent Specialization**: Domain-specific tools and prompts\n- ✅ **Error Handling**: Graceful degradation and retry mechanisms\n- ✅ **Monitoring Dashboard**: Real-time system status and agent availability\n\n## Agent Capabilities Matrix\n\n| Agent Type | Account Lookup | Ticket Creation | Status Check | Transfer | Human Escalation |\n|------------|---------------|----------------|--------------|----------|------------------|\n| Triage     | ✅            | ❌             | ❌           | ✅       | ✅               |\n| Technical  | ❌            | ✅             | ✅           | ✅       | ✅               |\n| Billing    | ✅            | ✅             | ❌           | ✅       | ✅               |\n| Sales      | ✅            | ❌             | ❌           | ✅       | ✅               |\n| Human      | ✅            | ✅             | ✅           | ✅       | N/A              |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalman-aziz-4425%2Fsupport-chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsalman-aziz-4425%2Fsupport-chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsalman-aziz-4425%2Fsupport-chatbot/lists"}