AI-powered customer support chatbot for Swiss Airlines with a modern web interface.
customersupport/
├── backend/ # FastAPI + WebSocket Server
│ ├── main.py # WebSocket endpoint
│ ├── chatbot.py # LangGraph agent logic
│ ├── db.py # Database utilities
│ └── tool/ # Agent tools (flights, hotels, etc.)
│
└── frontend/ # Next.js + TypeScript + TailwindCSS
└── src/
├── app/ # Pages
├── components/ # UI components
├── hooks/ # WebSocket hook
└── types/ # TypeScript types
- Python 3.12+
- Node.js 20+
- pnpm
cd backend
# Install dependencies
pip install -r requirements.txt
# Set up environment variables
cp ../.env.example ../.env
# Edit .env with your API keys (OpenAI, Tavily, etc.)
# Run the server
python main.pyThe backend will start on http://localhost:8000
cd frontend
# Install dependencies
pnpm install
# Run the development server
pnpm devThe frontend will start on http://localhost:3000
Create a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key
ANTHROPIC_API_KEY=your_anthropic_api_key
TAVILY_API_KEY=your_tavily_api_key-
Backend (FastAPI + WebSocket)
- Real-time bidirectional communication
- Session management
- Sensitive tool approval flow
- Error handling and reconnection
-
Frontend (Next.js + React)
- ChatGPT-like UI
- Real-time messaging
- Approval dialog for sensitive operations
- Connection status indicator
- Auto-scroll and typing indicator
- Responsive design
The AI agent can help with:
✈️ Flight search and booking- 🏨 Hotel reservations
- 🚗 Car rental bookings
- 🎫 Excursion recommendations
- 📋 Company policy lookups
- 🔄 Modify/cancel existing reservations
Sensitive Operations (require user approval):
- Updating flight tickets
- Canceling bookings
- Making new reservations
- FastAPI: Modern async web framework
- WebSocket: Real-time communication
- LangGraph: Agent orchestration
- LangChain: LLM integration
- OpenAI GPT-4: Language model
- SQLite: Database
- Next.js 14: React framework (App Router)
- TypeScript: Type safety
- TailwindCSS: Styling
- WebSocket API: Real-time communication
- Minimal Code: Reuse existing
chatbot.pylogic - No Redundancy: Single source of truth for agent logic
- Simple Architecture: Direct WebSocket communication
- Clean Separation: Backend/Frontend clearly separated
- Backend: All agent logic, tools, and database operations
- Frontend: Pure UI layer, no business logic
- Communication: WebSocket with JSON messages
See Todo.md for the testing plan.
MIT
This is a tutorial project. Feel free to fork and modify!
Note: This project is based on LangGraph tutorials and adapted for a web interface.