Educational repository showcasing conversational patterns built with LangGraph. Each pattern demonstrates core concepts for building agentic conversational systems with practical, real-world examples.
Currently featuring three patterns:
- Booking Pattern: Guide users through booking appointments
- Modify Appointment Pattern: Help users modify or cancel existing appointments
- Detect Correction Pattern: Handle user corrections and intent changes in conversations
A conversational agent that guides users through the process of booking an appointment. The agent asks for missing information, validates availability, and confirms bookings.
- Video Tutorial: Watch on YouTube
- Detailed Article: Read on Medium
- Code:
patterns/booking/
Key Concepts:
- Incremental information gathering
- Conditional routing based on state
- Availability validation
- Confirmation handling
A conversational agent that helps users modify or cancel existing appointments. The agent identifies the customer, looks up their appointments, processes modifications or cancellations, and validates availability for changes.
- Video Tutorial: Watch on YouTube
- Detailed Article: Read on Medium
- Code:
patterns/modify_appointment/
Key Concepts:
- Customer identification and lookup
- Appointment selection from multiple results
- Modification request parsing (time, date, service)
- Availability validation for changes
- Confirmation handling for modifications
- Cancellation processing
A conversational agent that detects and handles user corrections in real-time. The agent identifies when users are correcting previous statements (changing dishes, sizes, rejecting offers) and adjusts the conversation flow accordingly. Uses regex-based detection for fast, reliable correction identification.
- Video Tutorial: Watch on YouTube
- Code:
patterns/detect_correction/ - Domain: Food ordering system
Key Concepts:
- Correction-first pattern detection
- Regex-based intent classification (no LLM required)
- Dynamic state management for multi-turn conversations
- Context preservation during corrections
- Early exit optimization for rejections
- Fallback handling for incomplete information
Pattern Flow:
- Detect Correction - Identifies if user is correcting previous statement
- Detect Intent - Determines user intention (order, modify, cancel, FAQ, finish)
- Process Intent - Executes business logic based on intent and corrections
- Respond User - Sends response and maintains conversation state
Example Conversations:
User: "I want a large pizza"
Bot: "Perfect, large pizza. Anything else?"
User: "Actually, make it small"
Bot: "Perfect, changed to small size. Your order: small pizza. Anything else?"
User: "How much does it cost?"
Bot: "Pizza: $15-25. You were ordering a pizza - what size?"
User: "I want tacos"
Bot: "What size would you like?"
User: "No thanks, never mind"
Bot: "No problem. Have a great day!" ← Early exit (fast path)
- Python 3.10+
- pip
- Clone the repository:
git clone https://github.com/juanludataanalyst/langgraph-conversational-patterns.git
cd langgraph-conversational-patterns- Install dependencies:
pip install -r requirements.txt- Set up your environment (optional):
cp .env.example .env # if you have an .env.example fileView and test all patterns in an interactive web interface:
uv run langgraph devThen open http://localhost:8000 in your browser. You'll see all three patterns available to test.
Run a specific pattern directly:
# Booking pattern
python patterns/booking/graph.py
# Modify Appointment pattern
python patterns/modify_appointment/graph.py
# Detect Correction pattern
python patterns/detect_correction/graph.pyWe welcome contributions! Whether you want to:
- Add new conversational patterns
- Improve existing patterns
- Fix bugs
- Enhance documentation
Please read CONTRIBUTING.md for details on how to contribute.
- Video: Watch the tutorial to understand the pattern
- Code: Explore the implementation in
patterns/<pattern-name>/ - Article: Read the detailed explanation on Medium
- Experiment: Modify and extend the pattern
langgraph-conversational-patterns/
├── README.md # This file
├── CONTRIBUTING.md # How to contribute
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── langgraph.json # LangGraph Studio configuration
├── img/ # Visual assets
│ ├── BookingDiagram.PNG # Booking pattern architecture
│ ├── Modify_appointment_diagram.PNG # Modify appointment pattern architecture
│ └── Correction_diagram.PNG # Detect correction pattern architecture
└── patterns/
├── booking/ # Booking pattern
│ ├── __init__.py
│ ├── state.py # State schema
│ ├── nodes.py # Graph nodes
│ └── graph.py # Graph definition
├── modify_appointment/ # Modify/Cancel appointments pattern
│ ├── __init__.py
│ ├── state.py # State schema
│ ├── nodes.py # Graph nodes
│ └── graph.py # Graph definition
└── detect_correction/ # Detect correction pattern
├── __init__.py
├── state.py # State schema
├── nodes.py # Graph nodes
└── graph.py # Graph definition
This project is licensed under the MIT License - see the LICENSE file for details.
If you have questions or suggestions, please open an issue on GitHub.
Happy learning! 🚀