Course WhatsApp Chatbot¶
An AI-powered WhatsApp chatbot that delivers interactive course content through conversational learning. Students can engage with structured lessons via text or voice messages, with the AI acting as a personal instructor that explains concepts, asks questions, and tracks progress through course materials.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow creates an intelligent course delivery system accessible through WhatsApp, making educational content available to students wherever they are. The chatbot supports both text and voice interactions, maintains conversation context across sessions, and provides personalized learning experiences by adapting explanations to individual student responses.
How It Works¶
- Message Reception: The workflow receives WhatsApp messages through a Twilio webhook endpoint
- Message Type Detection: A switch node determines if the incoming message is text or audio
- Audio Processing (if applicable): Audio messages are downloaded from Twilio and transcribed using OpenAI Whisper
- Message Normalization: Both text and transcribed audio are standardized into a common message format
- Reset Check: The system checks if the user sent "reset" to clear conversation history
- AI Processing: The main AI agent processes the message using:
- OpenAI's language model for natural conversation
- Conversation memory to maintain context across sessions
- A course content tool that fetches structured lesson materials
- Response Generation: The AI generates educational responses, explanations, and follow-up questions
- Message Delivery: The response is sent back to the user via Twilio WhatsApp
The system also includes maintenance capabilities through a scheduled trigger that processes course content from Google Drive.
Workflow Diagram¶
graph TD
A[Webhook - WhatsApp Message] --> B[Switch - Message Type]
B -->|Audio| C[HTTP Request - Download Audio]
B -->|Text| D[Edit Fields1 - Extract Text]
C --> E[Transcribe Recording - OpenAI Whisper]
E --> F[Edit Fields - Format Audio Text]
D --> G[Edit Fields2 - Normalize Message]
F --> G
G --> H[If - Check Reset Command]
G --> I[Main Agent - AI Processing]
H -->|Reset| J[Delete Messages1 - Clear Memory]
I --> K[Send WhatsApp Message - Twilio]
L[OpenAI Chat Model] -.->|Language Model| I
M[Simple Memory] -.->|Conversation Context| I
N[Leadership Course Agent] -.->|Course Content Tool| I
O[Schedule Trigger] --> P[HTTP Request1 - Download Course PDF]
P --> Q[Extract from File - Parse PDF]
Q --> R[Code - Structure Course Data]
S[Manual Trigger] --> T[Delete Messages - Clear Test Memory]
T --> U[Insert Messages1 - Add Test Conversation]
Trigger¶
Primary Trigger: Webhook endpoint at /webhook/course-chatbot that receives POST requests from Twilio when WhatsApp messages are sent to the configured number.
Additional Triggers: - Manual trigger for testing and memory management - Schedule trigger for course content maintenance
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives WhatsApp messages from Twilio |
| Switch | Routes messages based on type (audio/text) |
| HTTP Request | Downloads audio files from Twilio |
| OpenAI (Transcribe) | Converts audio messages to text |
| Edit Fields | Normalizes and formats message data |
| If | Checks for reset commands |
| AI Agent | Main conversational AI with course knowledge |
| OpenAI Chat Model | Provides language model for AI responses |
| Memory Buffer Window | Maintains conversation context |
| Tool Workflow | Accesses structured course content |
| Twilio | Sends responses back via WhatsApp |
| Memory Manager | Manages conversation history |
| Extract from File | Processes course PDF content |
| Code | Structures course data into lessons |
| Schedule Trigger | Automated course content updates |
External Services & Credentials Required¶
Twilio:
- Account for WhatsApp Business API
- Credentials: twilioApi and httpBasicAuth for media downloads
OpenAI:
- API access for GPT models and Whisper transcription
- Credentials: openAiApi
Google Drive: - Access to course content PDFs (public download links)
Environment Variables¶
No specific environment variables are required. All configuration is handled through n8n credentials and node parameters.
Data Flow¶
Input: - WhatsApp messages (text or audio) via Twilio webhook - Message metadata (sender ID, message type, media URLs)
Processing: - Audio transcription to text - Message normalization - AI agent processing with course context - Memory management for conversation continuity
Output: - Educational responses sent via WhatsApp - Updated conversation memory - Course progress tracking
Error Handling¶
The workflow includes basic error handling through: - Switch node routing for different message types - Conditional checks for reset commands - Memory management for conversation state recovery
No explicit error nodes are present, so errors would be handled by n8n's default error handling mechanisms.
Known Limitations¶
Based on the workflow structure: - Depends on external services (Twilio, OpenAI) for core functionality - Audio processing requires additional API calls and processing time - Course content is currently limited to PDF-based materials - Memory is session-based and may not persist across long periods
Related Workflows¶
- CourseContentAgent (ID: I32PCLSspW3b6umC): Provides structured course content and lesson management
Setup Instructions¶
-
Import the workflow into your n8n instance
-
Configure Twilio credentials:
- Set up WhatsApp Business API account
- Create
twilioApicredential with Account SID and Auth Token - Create
httpBasicAuthcredential for media downloads
-
Configure OpenAI credentials:
- Create
openAiApicredential with your OpenAI API key - Ensure access to both GPT models and Whisper API
- Create
-
Set up the webhook:
- Activate the workflow to generate the webhook URL
- Configure Twilio to send WhatsApp messages to the webhook endpoint
-
Configure course content:
- Ensure the CourseContentAgent workflow is properly set up
- Update Google Drive links for course materials if needed
-
Test the setup:
- Send a test message to your WhatsApp number
- Verify audio transcription works with voice messages
- Check that course content is accessible through the AI agent
-
Customize the AI behavior:
- Modify the system message in the Main Agent node
- Adjust memory settings for conversation length
- Configure course-specific responses as needed