How daveebbelaar/python-whatsapp-bot works
Project Type and Purpose
• This is a backend service built with Flask (“run.py” entry point, “app/” package) that acts as a WhatsApp chatbot.
• It integrates with Meta’s WhatsApp Cloud API for sending and receiving messages and with OpenAI’s Assistants API to generate AI responses.
File Structure
• Top-level:
• run.py – starts the Flask server
• requirements.txt, example.env – dependency and env setup
• start/ – standalone Python scripts showing quickstart examples (whatsapp_quickstart.py and assistants_quickstart.py)
• data/, docs/, img/ – reference assets, not part of the runtime
• app/: contains core MVC-style layers
• config.py – environment/configuration loader
• views.py – Flask route definitions (webhook endpoint, health checks, etc.)
• decorators/security.py – request verification (webhook signature, token check)
• services/openai_service.py – encapsulates OpenAI API calls
• utils/whatsapp_utils.py – message parsing, response‐generation glue code
README for Additional Insights
• Describes the end-to-end flow:
1. Configure environment (APP_ID, SECRET, VERIFY_TOKEN, ACCESS_TOKEN)
2. Use ngrok to publish /webhook endpoint
3. Receive incoming messages via GET/POST at /webhook
4. Verify requests, parse payloads, call OpenAI, then POST reply back to WhatsApp API
• Mentions security patterns (SHA-256 payload signing)