A production-grade Conversational AI Agent that allows users to order Starbucks drinks through natural, multi-turn conversations.
Built using NestJS, LangChain LangGraph, Google Gemini, and MongoDB, this project demonstrates how to design stateful AI agents with memory, tool execution, and schema-driven reasoning.
This AI agent behaves like a smart Starbucks barista.
It understands user intent, asks follow-up questions, validates structured order data, confirms the order, and finally persists it in a database — all while maintaining conversational context across multiple turns.
The system is designed using LangGraph, enabling fine-grained control over agent workflows, decision-making, and tool invocation.
- 🧩 Conversational AI Agent for Starbucks drink ordering
- 📦 LangGraph-powered state machine for controlled multi-step conversations
- 🛠️ Tool calling to create and manage orders in a real database
- 🗄️ MongoDB persistence with LangGraph checkpointers for memory
- ✅ Zod schema validation to ensure reliable, structured AI outputs
- 🔄 Order confirmation and progress tracking
- 😀 Human-like, friendly responses with emojis and contextual suggestions
- 🔐 Authentication & User Sessions
- Secure user identification for conversations
- Conversation memory scoped per authenticated user
- Prevents cross-user data leakage in multi-session environments
- Stateful AI Agent Design using LangGraph annotations and reducers
- Schema-driven AI workflows to prevent hallucinated or malformed outputs
- Tool-based execution model where the LLM triggers real backend actions
- Checkpointed memory allowing conversations to resume seamlessly
- Separation of concerns between AI logic, validation, persistence, and APIs
This mirrors how modern AI systems are built in production environments.
- User sends a message (e.g., "I want a latte with oat milk")
- The AI agent checks which order details are missing
- The agent asks follow-up questions contextually
- Once all fields are complete, the agent asks for confirmation
- On confirmation, the create_order tool is called
- Order is validated and saved to MongoDB
- The response always includes structured JSON for frontend use
git clone https://github.com/yourusername/langgraph-starbucks-agent.git
cd langgraph-starbucks-agent2️⃣ Install Dependencies
yarn install
# or (Windows)
npm install3️⃣ Configure Environment Variables
Create a .env file in the root directory:
GOOGLE_API_KEY=your_google_api_key
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/starbucks_db4️⃣ Run the Server
yarn start:dev
# or (Windows)
npm run devUser: I want a caramel macchiato
AI: What size would you like? ☕
User: Grande
AI: Would you like any toppings? 🍫
User: Yes, whipped cream
AI: Please confirm your order: Grande Caramel Macchiato with Whipped Cream ✅
User: Yes
AI: Order created successfully 🎉
- Database:
drinks_db - Collections:
orders– saved drink orderslanggraph_checkpoints– conversation memory
All orders are validated using Zod schemas before insertion.
- 🏦 Banking Assistant (accounts, cards, loans)
- 🏥 Hospital Appointment Agent
- 💼 SaaS Customer Support Agent
- Knowledge-base powered responses using vector search
MIT License