Tag Archives: langsmith

๐Ÿค– AI Customer Support using an Agentic Framework

In this blog, Iโ€™ll walk you through the design, development, and lessons learned while building a multi-agent AI customer support assistant using the LangChain framework and related AI tools. ๐ŸŽฎ๐Ÿ’ฌ


๐ŸŽฏ Motivation: Why Build This?

At KGeN, a game aggregation platform connecting publishers and gamers, our primary users are gamers and clan chiefs (micro-community leaders).

These users often ask questions about:

  • Platform features
  • Game-specific achievements
  • Player and clan statistics

Some answers come from a static knowledge base, while others depend on dynamic user-specific data.

โšก We wanted an intelligent, scalable AI assistant that could:

  • Understand natural language queries
  • Route them to the appropriate data sources
  • Continuously improve through feedback

Based on the poc feedback, I wanted to take this to production.

๐Ÿง  The use case generalizes to any industry with static documentation and dynamic user dataโ€”only the context changes.


๐Ÿ”— Application & Code

The poc application is deployed in Render, you can try this out. The Github also contains instructions to run it locally or in cloud.


๐Ÿ“Œ Business Goals

I wanted a system with following business goals:

  • ๐Ÿ—ฃ Answer queries conversationally
  • โš™๏ธ Route questions to the right agent (static/dynamic/hybrid)
  • ๐Ÿงพ Escalate unresolved issues via Jira tickets
  • โญ Collect feedback for iterative improvements
  • ๐Ÿ“š Learn from feedback to enhance performance

๐Ÿงช Prototyping Approach

I followed a “vibe coding” model:

  • Start fast with a working prototype
  • Use AI to assist (ChatGPT + Cursor editor)
  • Iterate with real feedback

๐Ÿ’ก Tools Used:

  • ChatGPT to generate mock data (static + SQL)
  • Langchain/Langsmith as agentic framework
  • Cursor for AI-assisted coding
  • Render for cloud deployment

โš ๏ธ Tip: Feed detailed requirements to AI code editors. Without clarity, they produce unreliable or messy code.


๐Ÿงญ Agent Flow: How It Works

Each user query is first routed by a Main AI Agent, which classifies the query as:

  • ๐Ÿ“˜ Static: Uses vector search on documentation (FAISS)
  • ๐Ÿ—„ Dynamic: Converts to SQL query on structured data
  • ๐Ÿ” Hybrid: Mixes both static + dynamic sources
  • ๐Ÿ“ฅ Follow-Up: Needs more user input
  • ๐Ÿšจ Escalation: Routed to a human via Jira

Each type has a specialized agent with its own system prompt.

๐Ÿง  LangChain powers the routing, agents, and execution logic.

๐Ÿ“Œ Architecture Diagram: Agent Flow


๐Ÿงฑ Architecture & Tech Stack

ComponentTool / FrameworkReasoning
Agent FrameworkLangChainModular, battle-tested
MonitoringLangSmithEasy trace/debug for agents
Vector DBFAISSSimple to set up for POC
LLMsOpenAI (pluggable)Can switch to others like Claude
Backend APIFastAPILightweight, async-friendly
Frontend (POC)StreamlitQuick prototyping
DeploymentRenderEasy cloud deployment
TicketingJira APIFor support escalations
DB (Local/Test)SQLiteLightweight
DB (Production)PostgresScalable

๐Ÿž Issues & Learnings

This whole application took me around 8-10 hours over a period of 2 weeks. I got time to spend only on weekends to do this.. Following are some issues I faced:

  • ๐Ÿงฉ Dependency Hell: LangChain and LLM libs change fast. Cursor couldnโ€™t resolve pip issues well. I had to request cursor to get latest details in internet to resolve it.
  • ๐Ÿงช Streamlit Cloud Problems: Ended up moving to Render for better compatibility.
  • ๐ŸŒ Env File Confusion: Environment-specific bugs were hard to debug in prod as Cursor does not integrate with Render deployment.

๐Ÿ” Debugging with LangSmith

Langsmith is great to understand if the agentic workflow is working as expected. I was able to fix the following issues with Langsmith:

  • ๐Ÿ”Ž Identified issue that search from vector database is giving the whole static knowledge base instead of giving the specific context. Adding semantic analysis to vector database match helped solve this.
  • ๐Ÿงฉ Fix hybrid agentโ€™s output merging logic
  • ๐Ÿ” Debug why hybrid/support queries didnโ€™t escalate to Jira

๐Ÿ“‚ Sample Queries along with Langsmith trace

Static query example: What are legendary items?

From the above trace, we can see that there are 2 LLM chain calls and 1 call to vector database. The first chain call is to identity the type of query and the second chain call is to summarize the response from vector database.

Hybrid query example: How many gold achievements has DragonSlayer99 earned and what rewards do they give?


From the above trace, we can see that there are 6 chain calls in the above query:

  • first to identity type of query
  • second to summarize results of vector database
  • third to check if there is username in the query
  • fourth to generate sql query and get results from postgres db
  • fifth to take the results from sql query and generate summarized response
  • sixth to combine the summarized static data and dynamic data to give response to the user

๐Ÿ“‹ Requirements Summary (Generated via ChatGPT)

I fed these requirements as initial prompt into cursor after few iterations of discussions with chatgpt.

๐Ÿ’ณ Business Requirements

  • Build an AI system that can:
    • ๐Ÿ“˜ Answer static queries from documentation
    • ๐Ÿ—„ Query live backend data
    • ๐Ÿ” Combine static + dynamic sources
    • ๐Ÿ“ฅ Handle follow-up interactions
    • ๐Ÿšจ Escalate to Jira when needed
  • Serve two user roles:
    • ๐Ÿ‘ค Gamers (general players)
    • ๐Ÿ‘‘ Clan Chiefs (advanced users)
  • Goals:
    • Reduce manual tickets by 70%
    • Improve first-response time
    • Maintain conversational accuracy

๐Ÿ“ˆ Functional Requirements

  1. Static Question Answering
    • Vectorize and index knowledge base with FAISS
    • Use RAG (Retrieval-Augmented Generation) to answer
  2. Dynamic Question Answering
    • Use LangChain SQL Agent to convert natural language to SQL
    • Query SQLite (for testing) and Postgres (in prod)
  3. Hybrid Handling
    • Mix RAG results with SQL data for composite answers
  4. Follow-Up Logic
    • Prompt for missing data (e.g., usernames)
  5. Escalation
    • Auto-create Jira ticket with conversation context if unresolved
  6. Multi-Agent System
    • Router โ†’ specialized agents (static, dynamic, hybrid, etc.)
  7. API & UI
    • FastAPI for backend
    • Streamlit for POC frontend; React for future UI

๐Ÿš€ Technical Requirements

  • LangChain (Python)
  • FAISS or ChromaDB for vector storage
  • OpenAI or Claude LLMs
  • SQLite (via LangChain SQL agent) as simulated backend
  • JIRA API for ticket creation
  • FastAPI (backend API layer)
  • Streamlit (prototyping UI)
  • React (future UI)

๐Ÿ” Security & Testing

  • Role-based access (gamers vs. clan chiefs)
  • Environment variable protection
  • Unit tests, evaluation prompts, and simulated load

โœ… Success Criteria

  • 90%+ accurate responses in test cases โœ…
  • Sub-3-second latency โœ…
  • Smooth Jira escalation pipeline โœ…
  • API ready for frontend integrations โœ…

๐Ÿš€ Final Thoughts

This project demonstrates how AI agents, vector databases, LLMs, and good system design can solve real-world support problems.

There are many improvements needed to take this into production. Following are some of them:

  • Use Langchain conversation memory. This is maintained at streamlit level to stitch a conversation.
  • RBAC based on user login and queries based on the user.
  • Performance improvement using caching at different levels, database connection optimisation.
  • Agent self learnings from user feedback
  • Improve UI/UX

๐Ÿ”„ This customer support agent is a template that can be adapted across industriesโ€”from gaming to banking to e-commerce.