Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Conversational LangGraph Patterns

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

📚 Available Patterns

1. Booking Pattern

A conversational agent that guides users through the process of booking an appointment. The agent asks for missing information, validates availability, and confirms bookings.

Booking Pattern Diagram

Key Concepts:

  • Incremental information gathering
  • Conditional routing based on state
  • Availability validation
  • Confirmation handling

2. Modify Appointment Pattern

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.

Modify Appointment Pattern Diagram

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

3. Detect Correction Pattern

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.

Detect Correction Pattern Diagram
  • 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:

  1. Detect Correction - Identifies if user is correcting previous statement
  2. Detect Intent - Determines user intention (order, modify, cancel, FAQ, finish)
  3. Process Intent - Executes business logic based on intent and corrections
  4. 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)

🚀 Getting Started

Prerequisites

  • Python 3.10+
  • pip

Installation

  1. Clone the repository:
git clone https://github.com/juanludataanalyst/langgraph-conversational-patterns.git
cd langgraph-conversational-patterns
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up your environment (optional):
cp .env.example .env  # if you have an .env.example file

Running the Patterns

Option 1: LangGraph Studio (Recommended)

View and test all patterns in an interactive web interface:

uv run langgraph dev

Then open http://localhost:8000 in your browser. You'll see all three patterns available to test.

Option 2: Test Locally

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.py

🤝 Contributing

We 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.

📖 Learning Path

  1. Video: Watch the tutorial to understand the pattern
  2. Code: Explore the implementation in patterns/<pattern-name>/
  3. Article: Read the detailed explanation on Medium
  4. Experiment: Modify and extend the pattern

📁 Repository Structure

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

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙋 Questions?

If you have questions or suggestions, please open an issue on GitHub.


Happy learning! 🚀

About

No description, website, or topics provided.

Resources

Contributing

Stars

20 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages