Skip to content

LangGraph-powered customer support agent for e-commerce. Multi-tenant, RAG-backed, with Shopify integration.

License

Notifications You must be signed in to change notification settings

teamauresta/merchant-mind

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CI License: MIT Python LangGraph Version

E-Commerce Support Agent

AI-powered customer support agent for e-commerce stores. Automates 80%+ of common support inquiries using LangGraph.

Features

  • πŸ›’ Order Status (WISMO) - Real-time order tracking with Shopify integration
  • πŸ“¦ Returns Processing - Automated return eligibility checks and label generation
  • πŸ’° Refunds - Policy-based auto-approval with escalation for edge cases
  • 😊 Sentiment Analysis - Tone adaptation based on customer mood
  • πŸ”„ Smart Escalation - Seamless handoff to human agents when needed
  • πŸ“Š Analytics - Track automation rates, response times, and more

Quick Start

# Clone and setup
git clone https://github.com/yourcompany/ecommerce-support-agent.git
cd ecommerce-support-agent
python -m venv venv && source venv/bin/activate
make dev

# Configure
cp .env.example .env
# Edit .env with your API keys

# Start services
make docker-up
make migrate
make run

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Chat Widget │────▢│   FastAPI    │────▢│   LangGraph     β”‚
β”‚  (React)    β”‚     β”‚   API        β”‚     β”‚   Agent         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                   β”‚
         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
         β”‚                                         β”‚             β”‚
    β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ Postgres β”‚   β”‚   Redis    β”‚   β”‚     Integrations          β”‚
    β”‚ + Vector β”‚   β”‚   Cache    β”‚   β”‚ Shopify Β· Gorgias Β· EasyPostβ”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Agent Flow

Message β†’ Classify Intent β†’ Analyze Sentiment β†’ Fetch Context
                                                      β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚              β”‚                  β”‚                 β”‚
               β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”        β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”
               β”‚  WISMO  β”‚   β”‚ Returns β”‚        β”‚ Refunds β”‚       β”‚ General β”‚
               β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
                    β”‚              β”‚                  β”‚                 β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                      β”‚
                                            Build Response β†’ Check Escalation β†’ End

Project Structure

ecommerce-support-agent/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ agents/           # LangGraph agents
β”‚   β”‚   β”œβ”€β”€ graph.py      # Main workflow
β”‚   β”‚   β”œβ”€β”€ state.py      # State definitions
β”‚   β”‚   β”œβ”€β”€ prompts.py    # LLM prompts
β”‚   β”‚   └── nodes/        # Individual agent nodes
β”‚   β”œβ”€β”€ integrations/     # External service clients
β”‚   β”‚   β”œβ”€β”€ shopify.py    # Shopify API
β”‚   β”‚   β”œβ”€β”€ gorgias.py    # Gorgias helpdesk
β”‚   β”‚   └── shipping.py   # EasyPost/carriers
β”‚   β”œβ”€β”€ api/              # FastAPI application
β”‚   β”‚   β”œβ”€β”€ main.py       # App entry point
β”‚   β”‚   β”œβ”€β”€ routes/       # API endpoints
β”‚   β”‚   └── middleware/   # Auth, rate limiting
β”‚   β”œβ”€β”€ models/           # SQLAlchemy models
β”‚   └── config.py         # Settings
β”œβ”€β”€ widget/               # React chat widget
β”œβ”€β”€ tests/                # Test suite
β”œβ”€β”€ docs/                 # Documentation
β”œβ”€β”€ alembic/              # Database migrations
└── scripts/              # Utility scripts

Configuration

Environment Variables

Variable Description Required
DATABASE_URL PostgreSQL connection string Yes
REDIS_URL Redis connection string Yes
OPENAI_API_KEY OpenAI API key Yes
LANGCHAIN_API_KEY LangSmith API key No
SENTRY_DSN Sentry error tracking No

See .env.example for full list.

Store Configuration

Stores are configured with:

  • Shopify credentials - API access for orders
  • Policies - Returns window, refund limits, etc.
  • Brand voice - Customized agent personality
  • Knowledge base - FAQ and product info

API Endpoints

Conversations

Method Endpoint Description
POST /api/v1/conversations Start new conversation
POST /api/v1/conversations/{id}/messages Send message
GET /api/v1/conversations/{id} Get conversation

Webhooks

Endpoint Source Purpose
/api/v1/webhooks/shopify/orders Shopify Order updates
/api/v1/webhooks/gorgias Gorgias Ticket sync

Health

Endpoint Purpose
/health Basic liveness
/health/ready Full readiness

Development

# Run tests
make test

# Run with coverage
make test-cov

# Lint code
make lint

# Format code
make format

# Create migration
make migrate-new

Deployment

Railway (Recommended)

# Install Railway CLI
npm install -g @railway/cli

# Login and deploy
railway login
railway up

Docker

# Build image
make build

# Run
docker run -p 8000:8000 --env-file .env ecommerce-support-agent

Monitoring

  • LangSmith - Trace all agent runs
  • Sentry - Error tracking
  • Grafana - Metrics dashboard

See docs/08-METRICS-AND-MONITORING.md for details.

Documentation

Doc Purpose
Architecture System design
Week-by-Week Development plan
Technical Spec Implementation details
API Spec API documentation
Integrations External services
Testing Test approach
Deployment Production setup
Monitoring Observability
Runbook Operations guide
Onboarding Customer setup

License

Private - All rights reserved.

About

LangGraph-powered customer support agent for e-commerce. Multi-tenant, RAG-backed, with Shopify integration.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •