How wassengerhq/whatsapp-chatgpt-bot works
This repository runs a WhatsApp customer-support chatbot: a user message arrives through Wassenger, the server hands the webhook event to the bot, and the bot filters and prepares the message, uses conversation context and OpenAI to produce a response, then replies through Wassenger. Separate paths support human-agent handoff, configurable business tools, audio transcription and voice replies, and outbound sample or on-demand messages. The README documents multimodal and webhook/tunnel capabilities; sampled source shows their main integration points, but not every bot-processing detail.
Main entry points: actions.js Messaging actions · bot.js AI response and tools · server.js Webhook and HTTP routes · main.js Startup and setup
Components 15
Service runtime
- Startup and setup
main.js - Webhook and HTTP routes
server.js - Temporary audio files
server.js
Conversation handling
- Message filtering
bot.js - Input preparation
bot.js - AI response and tools
bot.js - Reply and handoff
bot.js - Business tool functions
functions.js
External integrations
- Wassenger API
- OpenAI services
- Ngrok tunnel
- Messaging actions
actions.js
State and configuration
- Chat state and cache
store.js - Bot configuration
config.js
Other components
- WhatsApp user
Connections 28
- WhatsApp user → Wassenger API: sends messages
- Wassenger API → Webhook and HTTP routes: delivers webhook
- Startup and setup → Messaging actions: loads device and setup
- Startup and setup → Webhook and HTTP routes: starts server
- Startup and setup → Ngrok tunnel: creates tunnel
- Startup and setup → Messaging actions: registers webhook
- Webhook and HTTP routes → Messaging actions: serves outbound requests
- Webhook and HTTP routes → Message filtering: dispatches message
- Message filtering → Input preparation: accepts eligible messages
- Input preparation → Messaging actions: transcribes audio
- Input preparation → AI response and tools: provides prepared input
- AI response and tools → Chat state and cache: reads and updates context
- AI response and tools → OpenAI services: requests completions
- AI response and tools → Business tool functions: runs selected tools
- AI response and tools → Reply and handoff: passes generated response
- Reply and handoff → OpenAI services: generates voice audio
- Reply and handoff → Messaging actions: sends reply and updates chat
- Reply and handoff → Temporary audio files: writes generated audio
- Messaging actions → Wassenger API: calls messaging API
- Messaging actions → OpenAI services: transcribes audio
- Webhook and HTTP routes → Temporary audio files: serves and removes audio
- Wassenger API → WhatsApp user: delivers replies
- Startup and setup → Bot configuration: reads settings
- Webhook and HTTP routes → Bot configuration: reads settings
- AI response and tools → Bot configuration: reads behavior and limits
- Messaging actions → Bot configuration: reads credentials
- Bot configuration → Business tool functions: provides tool definitions
- Messaging actions → Chat state and cache: loads chat history