Course WhatsApp Copy¶
An AI-powered WhatsApp chatbot that delivers structured educational content through conversational interactions. This workflow processes incoming WhatsApp messages (text and audio), transcribes voice messages, and provides personalized course instruction using OpenAI's language models with memory persistence.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Message Reception: Receives WhatsApp messages via Twilio webhook, supporting both text and audio formats
- Message Processing: Routes messages based on type - audio messages are downloaded and transcribed using OpenAI's Whisper, while text messages are processed directly
- Content Preparation: Normalizes all messages into a standard text format for the AI agent
- Reset Detection: Checks if the user sent "reset" to clear conversation memory
- AI Instruction: Uses an OpenAI-powered agent with conversation memory to provide educational guidance, accessing course content through a specialized tool
- Response Delivery: Sends the AI's response back to the user via WhatsApp
The workflow also includes a separate process that periodically downloads and processes course content from Google Drive, parsing PDF files into structured lesson formats.
Mermaid Diagram¶
graph TD
A[Webhook] --> B[Switch]
B -->|audio| C[HTTP Request]
B -->|text| D[Edit Fields1]
C --> E[Transcribe a recording]
E --> F[Edit Fields]
F --> G[Edit Fields2]
D --> G
G --> H[If]
G --> I[Main agent]
H -->|reset| J[Delete Messages1]
I --> K[Send an SMS/MMS/WhatsApp message]
L[OpenAI Chat Model] -.->|language model| I
M[Simple Memory] -.->|memory| I
N[Leadership_course_agent] -.->|tool| I
O[Schedule Trigger] --> P[HTTP Request1]
P --> Q[Extract from File]
Q --> R[Code]
S[When clicking 'Execute workflow'] --> T[Delete Messages]
T --> U[insert Messages1]
M -.->|memory| T
M -.->|memory| U
M -.->|memory| J
Trigger¶
- Primary: Webhook endpoint that receives POST requests from Twilio when WhatsApp messages are sent to the configured number
- Secondary: Schedule trigger for periodic course content updates
- Manual: Manual trigger for testing memory management functions
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 content |
| OpenAI (Transcribe) | Converts audio messages to text using Whisper |
| Edit Fields | Normalizes message data into consistent format |
| If | Checks for reset command to clear memory |
| AI Agent | Main conversational AI powered by OpenAI |
| OpenAI Chat Model | Language model for generating responses |
| Memory (Buffer Window) | Maintains conversation context per user |
| Tool Workflow | Accesses course content through external workflow |
| Twilio | Sends WhatsApp responses back to users |
| Extract from File | Parses PDF course content |
| Code | Processes and structures lesson data |
| Memory Manager | Manages conversation memory (delete/insert) |
External Services & Credentials Required¶
Twilio¶
- Purpose: WhatsApp message handling (receive and send)
- Credentials:
- Account SID
- Auth Token
- WhatsApp-enabled phone number
- Used in: Webhook reception and message sending
OpenAI¶
- Purpose: Audio transcription and conversational AI
- Credentials:
- API Key with access to Whisper and GPT models
- Used in: Audio transcription and chat responses
Google Drive¶
- Purpose: Course content storage and retrieval
- Requirements: Public access to course PDF files
- Used in: Periodic content updates
Environment Variables¶
No explicit environment variables are defined in this workflow. All configuration is handled through n8n credentials and node parameters.
Data Flow¶
Input¶
- WhatsApp Messages: Text or audio messages from users
- Message Metadata: Sender ID, message type, timestamps
- Audio Files: Voice messages in supported formats
Processing¶
- Text Extraction: Audio transcription or direct text processing
- Context Management: User-specific conversation memory
- Course Content: Structured lesson data from PDF files
Output¶
- WhatsApp Responses: Educational content and interactive guidance
- Memory Updates: Persistent conversation context
- Structured Lessons: Parsed course content for agent use
Error Handling¶
The workflow includes basic error handling through: - Message Type Routing: Graceful handling of different message formats - Conditional Processing: Reset command detection and memory management - Tool Integration: Fallback behavior when course content is unavailable
No explicit error nodes are present, so errors would follow n8n's default error handling behavior.
Known Limitations¶
- Audio transcription depends on OpenAI service availability
- Course content updates require manual PDF uploads to Google Drive
- Memory is limited to 15 message window per user
- No explicit error recovery for failed API calls
- Workflow is currently inactive (active: false)
Related Workflows¶
- CourseContentAgent (ID: I32PCLSspW3b6umC): Provides structured course content and lesson management
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 with GPT and Whisper access
- Ensure HTTP Basic Auth for Twilio media downloads
-
Set Up Webhook:
- Note the webhook URL from the Webhook node
- Configure Twilio WhatsApp webhook to point to this URL
-
Configure Course Content:
- Upload course PDF to Google Drive with public access
- Update the Google Drive URL in the HTTP Request1 node
- Ensure the CourseContentAgent workflow is available
-
Test Setup:
- Use the manual trigger to test memory management
- Send test messages to your WhatsApp number
- Verify audio transcription and text responses
-
Activate Workflow: Set the workflow to active to begin processing messages
-
Monitor Performance: Check execution logs for any credential or API issues