Course WhatsApp Copy¶
An AI-powered WhatsApp chatbot that delivers structured educational content through conversational interactions. The system processes both text and audio messages, transcribes voice notes, and guides students through course lessons with an intelligent agent that maintains conversation context and provides personalized learning experiences.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Message Reception: The workflow receives WhatsApp messages via Twilio webhook, handling both text and audio formats
- Message Processing: Text messages are passed through directly, while audio messages are downloaded and transcribed using OpenAI's Whisper API
- Reset Detection: The system checks if the user sent "reset" to clear conversation memory
- AI Agent Processing: An OpenAI-powered conversational agent processes the message using:
- A detailed system prompt that defines the instructor chatbot behavior
- Access to course content through a specialized tool
- Conversation memory to maintain context across interactions
- Course Content Integration: The agent can access structured course lessons through a connected workflow tool
- Response Generation: The AI generates educational responses and sends them back via WhatsApp
- Memory Management: Conversation history is maintained per user (identified by WhatsApp ID) with a 15-message window
Mermaid 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 Transcription]
F --> G[Edit Fields2 - Normalize Message]
D --> G
G --> H[If - Check for Reset]
G --> I[Main Agent - AI Instructor]
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 Memory]
T --> U[Insert Messages1 - Add Sample Conversation]
Trigger¶
- Primary: Webhook endpoint that receives WhatsApp messages from Twilio
- Secondary: Schedule trigger for course content updates
- Testing: Manual trigger for memory management operations
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming WhatsApp messages from Twilio |
| Switch | Routes messages based on type (audio vs text) |
| HTTP Request | Downloads audio files and course PDFs |
| OpenAI (Transcribe) | Converts audio messages to text using Whisper |
| Edit Fields | Normalizes and formats message data |
| If | Checks for reset commands |
| AI Agent | Main conversational AI instructor |
| OpenAI Chat Model | Provides language model capabilities |
| Memory (Buffer Window) | Maintains conversation context |
| Tool Workflow | Accesses course content from external workflow |
| Twilio | Sends WhatsApp responses |
| Extract from File | Parses PDF course content |
| Code | Structures course data into lessons and sections |
| Memory Manager | Manages conversation history |
| Schedule Trigger | Automated course content updates |
| Manual Trigger | Testing and maintenance operations |
External Services & Credentials Required¶
- Twilio API: For WhatsApp messaging
- Account SID and Auth Token
- WhatsApp-enabled phone number
- OpenAI API: For transcription and chat completion
- API key with access to Whisper and GPT models
- HTTP Basic Auth: For Twilio media downloads
- Username and password for authenticated requests
Environment Variables¶
No specific environment variables are configured in this workflow. All credentials are managed through n8n's credential system.
Data Flow¶
Input: - WhatsApp messages (text or audio) via Twilio webhook - Course PDF content via scheduled downloads
Processing: - Audio transcription to text - Message normalization and formatting - AI agent processing with course content integration - Conversation memory management
Output: - Educational WhatsApp responses - Structured course data (lessons and sections) - Conversation state persistence
Error Handling¶
The workflow includes basic error handling through: - Message type switching to handle different input formats - Conditional logic for reset commands - Memory management operations for conversation state
No explicit error nodes or try-catch mechanisms are implemented.
Known Limitations¶
- Workflow is currently inactive (active: false)
- Limited to WhatsApp messaging platform
- Depends on external course content workflow availability
- No explicit error handling for API failures
- Audio processing limited to formats supported by OpenAI Whisper
Related Workflows¶
- CourseContentAgent (ID: I32PCLSspW3b6umC): Provides structured course lessons and explanations
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up Twilio API credentials with WhatsApp capabilities
- Configure OpenAI API credentials
- Set up HTTP Basic Auth for Twilio media downloads
-
Webhook Configuration:
- Note the webhook URL from the Webhook node
- Configure your Twilio WhatsApp number to send messages to this endpoint
-
Course Content Setup:
- Ensure the referenced CourseContentAgent workflow is available
- Update the Google Drive PDF URL if needed
- Configure the schedule trigger for content updates
-
Memory Configuration:
- Verify the session key uses WhatsApp ID for user identification
- Adjust context window length if needed (currently 15 messages)
-
Testing:
- Use the manual trigger to test memory operations
- Send test messages to verify the complete flow
- Test both text and audio message handling
-
Activation: Set the workflow to active once configuration is complete