How ahmedsheikh27/auto-whatsapp works
This is a WhatsApp sales assistant paired with a product-browsing website and a shared FastAPI backend. The main messaging workflow verifies and receives WhatsApp webhooks, identifies the customer, saves the incoming message, delegates to the conversational agent, saves the reply, and sends it back. The backend also serves product and collection browsing. The graph includes the SDK and persistence layer; unsampled agent and service internals are represented only where the tree or source index supports them.
Main entry points: main_agent.py Conversation orchestrator · webhook.py WhatsApp webhook · client.py Ecommerce SDK · main.py FastAPI app
Components 27
Web storefront
- Storefront pages
wa-front/app - Product browsing UI
wa-front/app/products/ProductsClient.tsx - Collection browsing UI
wa-front/app/collection/page.tsx - Backend fetch client
wa-front/app/service/api.ts
Backend API
- FastAPI app
backend/app/main.py - WhatsApp webhook
backend/app/api/webhook.py - Product routes
backend/app/api/products.py - Collection routes
backend/app/api/collection.py - Message routes
backend/app/api/messages.py - WhatsApp sender
backend/app/services/whatsapp_service.py
Conversation agents
- Conversation orchestrator
backend/app/agents/main_agent.py - FAQ agent
backend/app/agents/faq_agent.py - Product agent
backend/app/agents/product_agent.py - Order agent
backend/app/agents/order_agent.py - Order tool
backend/app/tools/order_tool.py - FAQ tool
backend/app/tools/faq_tool.py - Product tool
backend/app/tools/product_tool.py - LLM configuration
backend/app/core/config.py
Commerce SDK
- Ecommerce SDK
backend/app/sdk/client.py - Postgres adapter
backend/app/sdk/adapters/postgres.py
State and storage
- Commerce models
backend/app/models/tables.py - PostgreSQL
- Conversation sessions
backend/app/services/session_service.py - Redis
Other components
- Shopper
- WhatsApp customer
- WhatsApp Cloud API
Connections 30
- Shopper → Storefront pages: browses
- Storefront pages → Product browsing UI: shows products
wa-front/app/products/page.tsx - Storefront pages → Collection browsing UI: shows collections
wa-front/app/collection/page.tsx - Product browsing UI → Backend fetch client: uses fetch client
wa-front/app/products/page.tsx - Collection browsing UI → Backend fetch client: fetches collections
wa-front/app/collection/page.tsx - Backend fetch client → Product routes: requests products
wa-front/app/service/api.ts - Backend fetch client → Collection routes: requests collections
wa-front/app/service/api.ts - WhatsApp customer → WhatsApp Cloud API: messages
- WhatsApp Cloud API → WhatsApp webhook: posts events
- FastAPI app → WhatsApp webhook: registers route
backend/app/main.py - FastAPI app → Product routes: registers route
backend/app/main.py - FastAPI app → Collection routes: registers route
backend/app/main.py - FastAPI app → Message routes: registers route
backend/app/main.py - WhatsApp webhook → Ecommerce SDK: creates SDK
backend/app/api/webhook.py - Product routes → Ecommerce SDK: creates SDK
backend/app/api/products.py - Collection routes → Ecommerce SDK: creates SDK
backend/app/api/collection.py - WhatsApp webhook → Conversation orchestrator: runs agent
backend/app/api/webhook.py - WhatsApp webhook → WhatsApp sender: sends reply
backend/app/api/webhook.py - Conversation orchestrator → FAQ agent: dispatches to
backend/app/agents/main_agent.py - Conversation orchestrator → Product agent: dispatches to
backend/app/agents/main_agent.py - Conversation orchestrator → Order agent: dispatches to
backend/app/agents/main_agent.py - Conversation orchestrator → Conversation sessions: uses session
backend/app/agents/main_agent.py - Order agent → Order tool: uses tool
backend/app/agents/order_agent.py - Order tool → Ecommerce SDK: creates orders
backend/app/tools/order_tool.py - Conversation orchestrator → LLM configuration: uses settings
backend/app/agents/main_agent.py - Ecommerce SDK → Postgres adapter: constructs adapter
backend/app/sdk/client.py - Postgres adapter → Commerce models: queries models
backend/app/sdk/adapters/postgres.py - Postgres adapter → PostgreSQL: reads and writes
backend/app/sdk/adapters/postgres.py - Conversation sessions → Redis: stores sessions
backend/app/services/session_service.py - WhatsApp sender → WhatsApp Cloud API: sends messages