Skip to content

Audio Reports V2

An intelligent WhatsApp-based reporting system that processes voice messages and text inputs from users in educational programs, providing AI-powered responses and generating structured reports based on user roles and program participation.

Purpose

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

Based on the workflow implementation, this system appears to serve educational programs (EBA and EXP) by: - Onboarding new users and assigning them appropriate roles - Processing voice messages and text inputs from trainers, mentors, and participants - Generating AI-powered responses and reports tailored to each user's role - Maintaining user data and conversation history in Google Sheets

How It Works

  1. Message Reception: The workflow receives WhatsApp messages via webhook, supporting both text and voice messages
  2. Voice Processing: Voice messages are automatically downloaded and transcribed using OpenAI's speech-to-text
  3. User Validation: The system checks if the sender exists in the user database and has a valid role assignment
  4. User Onboarding: New users go through an AI-powered onboarding process to determine their role in either the EBA or EXP program
  5. Role Assignment: Users are assigned specific roles (0-5) based on their program participation and responsibilities
  6. Prompt Selection: The system retrieves role-specific prompts from a Google Sheets database
  7. AI Processing: User messages are processed by specialized AI agents that generate appropriate responses and reports
  8. Response Delivery: AI-generated responses are sent back to users via WhatsApp
  9. Data Storage: All interactions, reports, and user data are stored in Google Sheets for tracking and analysis

Workflow Diagram

graph TD
    A[WhatsApp Webhook] --> B{Voice or Text?}
    B -->|Voice| C[Download Voice File]
    B -->|Text| D[Text Input]
    C --> E[Transcribe Audio]
    E --> F[Voice Output]
    D --> G[User Message]
    F --> G
    G --> H{User Exists?}
    H -->|Yes| I[Check User in DB]
    I --> J{User Has Role?}
    J -->|Yes| K[Get Current Prompt]
    J -->|No| L[Onboarding Agent]
    L --> M[Assign Role]
    M --> N[Send Onboarding Response]
    K --> O[AI Agent]
    O --> P[Upsert Report]
    P --> Q[Send AI Response]

Trigger

Webhook: WhatsApp messages received via Twilio webhook at endpoint 23d0efd9-c4dc-4cdd-82a8-f389082afdf2

The workflow activates when users send messages to the configured WhatsApp number.

Nodes Used

Node Type Purpose
Webhook Receives incoming WhatsApp messages from Twilio
HTTP Request Downloads voice message files from WhatsApp
OpenAI (Transcribe) Converts voice messages to text
Google Sheets Manages user data, prompts, and reports storage
If (Conditional) Routes workflow based on message type and user status
Set Transforms and prepares data for processing
AI Agent (LangChain) Processes messages with role-specific AI prompts
OpenAI Chat Model Provides AI language processing capabilities
Structured Output Parser Ensures consistent AI response formatting
Memory Buffer Maintains conversation context for users
Twilio Sends responses back to WhatsApp users

External Services & Credentials Required

Required Services

  • OpenAI API: For voice transcription and AI chat processing
  • Google Sheets API: For user data and prompt management
  • Twilio: For WhatsApp messaging integration

Credentials Needed

  • openAiApi: OpenAI API key for transcription and chat models
  • googleApi: Google Service Account for Sheets access
  • twilioApi: Twilio account credentials for WhatsApp messaging

Environment Variables

No specific environment variables are configured in this workflow. All configuration is handled through n8n credentials and node parameters.

Data Flow

Input

  • WhatsApp messages (text or voice) from users
  • User identification via WhatsApp phone number (WaId)
  • Voice files (when applicable) downloaded from WhatsApp media URLs

Processing

  • Voice-to-text transcription
  • User role validation and assignment
  • AI-powered response generation based on user role
  • Report creation and storage

Output

  • AI-generated responses sent via WhatsApp
  • Structured reports stored in Google Sheets
  • Updated user profiles with latest interaction data

Error Handling

The workflow includes several error handling mechanisms:

  • User Validation: Checks for user existence before processing
  • Role Verification: Validates user roles before applying specific prompts
  • Conditional Routing: Different paths for new vs. existing users
  • Always Output Data: Ensures workflow continues even with empty results from user lookups

Known Limitations

  • The workflow is currently archived and inactive
  • Twilio response nodes are disabled, preventing actual message sending
  • Limited to predefined roles (0-5) in the educational programs
  • Requires manual Google Sheets setup for user and prompt management

No related workflows are specified in the current context.

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 credentials for WhatsApp integration
  3. Prepare Google Sheets:

    • Create or access the "E Lab Report" spreadsheet
    • Ensure "Users" sheet exists with columns: UserID, UserName, RoleID, LastReport, LastReportCreatedAt
    • Set up "VoiceNotePrompts" sheet with role-specific prompts
  4. Configure Webhook:

    • Set up Twilio WhatsApp webhook to point to the n8n webhook URL
    • Ensure webhook path matches the configured endpoint
  5. Enable Workflow:

    • Activate the workflow in n8n
    • Enable the disabled Twilio response nodes if message sending is required
  6. Test Integration:

    • Send test messages to the WhatsApp number
    • Verify user onboarding and role assignment processes
    • Check that reports are properly stored in Google Sheets