Skip to content

Audio Reports

This workflow processes WhatsApp messages (both text and voice) to generate AI-powered reports through a conversational interface. It handles user onboarding, role assignment, voice transcription, and generates structured reports that are stored in Google Sheets and sent back via WhatsApp.

Purpose

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

How It Works

  1. Message Reception: The workflow receives WhatsApp messages through a webhook endpoint
  2. Message Type Detection: Determines if the incoming message is audio or text
  3. Audio Processing: For voice messages, downloads the audio file, converts it if over 25MB using CloudConvert, and transcribes it using OpenAI Whisper
  4. User Validation: Checks if the user exists in the Google Sheets database
  5. User Onboarding: For new users, runs an AI agent to collect user information and assign appropriate roles (0-5) based on their program participation
  6. Role Assignment: Stores user data including name, role ID, and user ID in Google Sheets
  7. Report Generation: For existing users, retrieves role-specific prompts and generates AI-powered reports using OpenAI
  8. Data Storage: Saves generated reports to Google Sheets with timestamps
  9. Response Delivery: Sends the AI response and formatted report back to the user via WhatsApp

Workflow Diagram

graph TD
    A[WhatsApp Webhook] --> B{If Voicenote}
    B -->|Yes| C[Download Voice File]
    B -->|No| D[Text In1]
    C --> E{If > 25mb}
    E -->|Yes| F[Create Job] --> G[Wait] --> H[GET Job] --> I[Switch]
    E -->|No| J[Transcribe a recording]
    I -->|finished| K[Download Audio File] --> J
    I -->|processing| G
    J --> L[Voice Out1]
    D --> M[User Message1]
    L --> M
    M --> N{User Exists?1}
    N --> O[Check User Exists1]
    O --> P{User in DB?1}
    P -->|Yes| Q[Get Current Prompt1] --> R[AI Agent]
    P -->|No| S[Onboarding Agent1] --> T[Assign Role1]
    T --> U[Send Response2]
    T --> Q
    R --> V[Append Report1] --> W[Send Response3]

Trigger

WhatsApp Webhook - HTTP POST endpoint at path coaching-start that receives WhatsApp messages from Twilio.

Nodes Used

Node Type Purpose
Webhook Receives incoming WhatsApp messages
If Conditional logic for message type and file size checks
HTTP Request Downloads audio files and manages CloudConvert API
OpenAI Transcribes audio and powers AI agents
Google Sheets Manages user data, prompts, and report storage
Twilio Sends responses back via WhatsApp
Set Data transformation and message formatting
Switch Routes based on conversion job status
Wait Pauses execution during file conversion
LangChain Agent AI conversation management with memory
Structured Output Parser Ensures consistent AI response format

External Services & Credentials Required

Required Credentials

  • OpenAI API: For audio transcription and AI chat models
  • Google Service Account: For Google Sheets access
  • Twilio API: For WhatsApp messaging
  • CloudConvert API: For audio file compression (when files exceed 25MB)

External Services

  • OpenAI Whisper: Audio transcription service
  • Google Sheets: User database and report storage
  • Twilio WhatsApp: Message delivery platform
  • CloudConvert: File conversion service

Environment Variables

No specific environment variables are configured in this workflow. All external service connections use n8n credential management.

Data Flow

Input

  • WhatsApp messages (text or audio) via webhook
  • User phone numbers (WaId) for identification
  • Audio files up to 25MB (larger files are compressed)

Processing

  • Audio transcription to text
  • User role identification and assignment
  • AI-generated reports based on role-specific prompts
  • Conversation memory management per user

Output

  • User data stored in Google Sheets (Users sheet)
  • Generated reports stored in Google Sheets (Reports sheet)
  • AI responses sent via WhatsApp
  • Formatted markdown reports delivered to users

Error Handling

The workflow includes several error handling mechanisms:

  • File Size Management: Automatically compresses audio files over 25MB using CloudConvert
  • Conversion Status Monitoring: Uses Switch node to handle processing, finished, and error states
  • Graceful Role Assignment: Continues execution even if role assignment fails
  • User Validation: Checks for existing users before onboarding
  • Always Output Data: Ensures user lookup always returns data for downstream processing

Known Limitations

Based on the workflow structure, potential limitations include:

  • Audio files must be accessible via public URLs for transcription
  • Dependency on multiple external services (OpenAI, Google Sheets, Twilio, CloudConvert)
  • Role assignment is limited to predefined roles (0-5)
  • Memory is session-based per user phone number
  • CloudConvert processing time may cause delays for large files

No related workflows identified from the current configuration.

Setup Instructions

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

  2. Configure Credentials:

    • Set up OpenAI API credentials for transcription and chat models
    • Configure Google Service Account for Sheets access
    • Add Twilio API credentials for WhatsApp messaging
    • Set up CloudConvert API credentials for file conversion
  3. Google Sheets Setup:

    • Create or configure the "E Lab Report" spreadsheet
    • Ensure sheets exist: "Users", "VoiceNotePrompts", "Reports"
    • Set up appropriate column headers matching the workflow schema
  4. Webhook Configuration:

    • Note the webhook URL for the "WhatsApp Webhook" node
    • Configure Twilio WhatsApp webhook to point to this endpoint
  5. Test the Workflow:

    • Send a test message to your WhatsApp number
    • Verify user onboarding flow works correctly
    • Test both text and voice message processing
  6. Activate: Enable the workflow to start processing live WhatsApp messages