How bibinprathap/whatsapp-chatbot works
This is a WhatsApp sales and ordering bot. A customer message enters through the WhatsApp connection, is checked for a natural-language order, and either becomes a validated cart or falls through to the numbered stage flow; both paths persist customer state and send replies. The product also supports attendant handoff and scheduled abandoned-cart recovery. The sampled code shows the message handler, NLP path, selected stages, storage helpers, and recovery job; connections among unsampled stage implementations are therefore shown only where documented by the README or registry.
Main entry points: stages.js Stage router · server.js Message server · index.js Natural-language processor · storage.js State access
Components 20
Conversation handling
- Message server
src/server.js - Stage router
src/stages.js
Order flows
- Welcome stage
src/stages/0.js - Menu stage
src/stages/1.js - Cart stage
src/stages/2.js - Address and bill
src/stages/3.js - Order stage
src/stages/4.js - Attendant handoff
src/stages/5.js - Recovery stage
src/stages/99.js - Natural-language processor
src/nlp/index.js - Order pre-filter
src/nlp/parser.js - Cart and summary builder
src/nlp/parser.js - Product catalog
src/menu.js
State and recovery
- State access
src/storage.js - SQLite state store
src/db.js - Abandoned-cart job
src/cron_jobs.js
External integrations
- OpenAI order parser
src/nlp/openai.js - WhatsApp service
- OpenAI service
Other components
- Customer
Connections 29
- Customer → WhatsApp service: sends message
- WhatsApp service → Message server: delivers message
- Message server → WhatsApp service: sends replies
- Message server → State access: loads state
- Message server → Natural-language processor: checks order
- Natural-language processor → Order pre-filter: filters message
- Natural-language processor → OpenAI order parser: parses order
- OpenAI order parser → OpenAI service: calls model
- OpenAI order parser → Product catalog: reads menu
- Natural-language processor → Cart and summary builder: builds cart
- Cart and summary builder → Product catalog: validates items
- Natural-language processor → State access: saves order state
- Natural-language processor → WhatsApp service: sends summary
- Message server → Stage router: falls back to
- Stage router → Welcome stage: dispatches stage
- Stage router → Menu stage: dispatches stage
- Stage router → Cart stage: dispatches stage
- Stage router → Address and bill: dispatches stage
- Stage router → Order stage: dispatches stage
- Stage router → Attendant handoff: dispatches stage
- Stage router → Recovery stage: dispatches stage
- Menu stage → Product catalog: reads menu
- Menu stage → State access: saves stage
- Address and bill → State access: saves address
- Message server → Abandoned-cart job: starts job
- Abandoned-cart job → SQLite state store: queries stale carts
- Abandoned-cart job → State access: loads and updates state
- Abandoned-cart job → WhatsApp service: sends nudges
- State access → SQLite state store: reads and writes