Skip to content

Course WhatsApp Copy

An AI-powered WhatsApp chatbot that delivers interactive educational courses through conversational learning. This workflow processes both text and voice messages, transcribes audio content, and guides students through structured lessons using an intelligent agent with conversation memory.

Purpose

No business context provided yet — add a context.md to enrich this documentation.

This workflow appears to be a duplicate of another "course whatsapp" workflow and serves as an educational chatbot that delivers structured course content through WhatsApp. Students can interact with the bot using text or voice messages, receive personalized instruction, and progress through lessons with built-in quizzes and assessments.

How It Works

  1. Message Reception: WhatsApp messages arrive via Twilio webhook
  2. Content Processing: The system determines if the message is text or audio
  3. Audio Transcription: Voice messages are downloaded and transcribed using OpenAI
  4. Message Routing: Both text and transcribed audio are normalized into a common format
  5. Reset Detection: Special "reset" commands clear conversation memory
  6. AI Processing: The main agent processes the message using OpenAI's language model with conversation memory
  7. Course Content: The agent can call a specialized course content tool to retrieve lesson materials
  8. Response Generation: The AI generates contextual responses based on course content and conversation history
  9. Message Delivery: Responses are sent back to the user via WhatsApp through Twilio

Additionally, there's a scheduled process that downloads and parses course content from Google Drive to keep the curriculum updated.

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 a recording]
    E --> F[Edit Fields - Format Audio Text]
    F --> G[Edit Fields2 - Normalize Message]
    D --> 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]

    L[Schedule Trigger] --> M[HTTP Request1 - Download Course PDF]
    M --> N[Extract from File - Parse PDF]
    N --> O[Code - Structure Course Data]

    P[OpenAI Chat Model] -.-> I
    Q[Simple Memory] -.-> I
    R[Leadership_course_agent] -.-> I

    S[Manual Trigger] --> T[Delete Messages - Clear Memory]
    T --> U[Insert Messages1 - Add Test Data]

Trigger

  • Primary: WhatsApp webhook at /webhook/871a76d4-05ff-4ce4-af6b-1390f9a1e9e3
  • Secondary: Schedule trigger for course content updates
  • Testing: Manual trigger for memory management operations

Nodes Used

Node Type Purpose
Webhook Receives WhatsApp messages from Twilio
Switch Routes messages based on type (audio/text)
HTTP Request Downloads audio files and course content
OpenAI (Transcribe) Converts voice messages to text
Edit Fields Normalizes and formats message data
If Checks for special reset commands
AI Agent Main conversational AI with course instruction logic
OpenAI Chat Model Language model for generating responses
Memory Buffer Window Maintains conversation context per user
Tool Workflow Integrates with course content management system
Twilio Sends WhatsApp responses
Extract from File Parses PDF course materials
Code Structures course data into lessons and sections
Memory Manager Manages conversation history for testing

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
  • Google Drive: For course content storage
    • Public access to course PDF files
  • HTTP Basic Auth: For Twilio media downloads
    • Credentials for accessing WhatsApp media URLs

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) via Twilio webhook - Course content PDFs from Google Drive

Processing: - Audio transcription to text - Message normalization - AI agent processing with course context - Memory management for conversation continuity

Output: - WhatsApp responses with course instruction - Structured course data for agent consumption

Error Handling

The workflow includes basic error handling through: - Message type switching to handle different input formats - Conditional logic for reset commands - Memory management for conversation state recovery

No explicit error nodes or try-catch mechanisms are implemented.

Known Limitations

Based on the workflow structure: - This appears to be a duplicate workflow that should be consolidated - Limited to single course content (Leadership course) - No explicit error handling for API failures - Memory is session-based but may not persist across system restarts - Course content updates require manual scheduling

  • CourseContentAgent (ID: I32PCLSspW3b6umC): Provides structured course content and lesson management
  • Original "course whatsapp": The primary version of this workflow that should be consolidated

Setup Instructions

  1. Import Workflow: Import the JSON into your n8n instance

  2. Configure Credentials:

    • Set up Twilio API credentials with WhatsApp access
    • Configure OpenAI API credentials
    • Set up HTTP Basic Auth for Twilio media downloads
  3. Webhook Configuration:

    • Copy the webhook URL from the Webhook node
    • Configure Twilio WhatsApp webhook to point to this URL
  4. Course Content Setup:

    • Ensure the Google Drive PDF is accessible
    • Update the Google Drive URL if needed
    • Configure the schedule trigger for content updates
  5. Test the Workflow:

    • Use the manual trigger to test memory management
    • Send test messages to the WhatsApp number
    • Verify audio transcription and course content delivery
  6. Production Deployment:

    • Activate the workflow
    • Monitor webhook responses
    • Consider consolidating with the original workflow to avoid duplication

Note: This workflow appears to be a duplicate. Consider reviewing both versions and maintaining only one canonical implementation to reduce maintenance overhead and prevent confusion.