Skip to content

Audio Reports V3

An intelligent WhatsApp-based reporting system that processes voice messages and text inputs from users in educational programs, automatically transcribes audio content, manages user onboarding with role assignment, and generates structured reports using AI agents tailored to specific user roles.

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 by: - Enabling users to submit reports via WhatsApp (voice or text) - Automatically onboarding new users and assigning them appropriate roles - Processing submissions through role-specific AI agents - Storing reports and user data in Google Sheets - Sending automated reminders to users who haven't submitted reports

How It Works

  1. Message Reception: The workflow receives WhatsApp messages through a webhook
  2. Audio Processing: If the message contains audio, it downloads and transcribes the voice file using OpenAI's transcription service
  3. User Validation: Checks if the user exists in the system by looking up their WhatsApp ID in Google Sheets
  4. User Onboarding: For new users, runs an onboarding process to collect their name, determine their program (EBA or EXP), and assign an appropriate role (0-5)
  5. Role Assignment: Updates the user database with their assigned role and information
  6. Report Processing: For existing users, retrieves role-specific prompts and processes their message through an AI agent
  7. Report Generation: The AI agent generates structured responses and markdown reports based on the user's role and input
  8. Data Storage: Saves the generated report to Google Sheets with timestamp and user information
  9. Response Delivery: Sends the AI-generated response back to the user via WhatsApp
  10. Reminder System: A scheduled trigger runs twice daily to identify users who haven't submitted reports and sends reminder messages

Workflow Diagram

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

    T[Schedule Trigger] --> U[Get Reports Data]
    U --> V[Aggregate Data]
    V --> W[Group by User ID]
    W --> X[Find Missing Reports]
    X --> Y[Send Reminders]

Trigger

  • Primary: WhatsApp Webhook - Receives incoming messages from WhatsApp users
  • Secondary: Schedule Trigger - Runs daily at 9 AM and 3 PM to send reminder messages to users who haven't submitted reports in the last 24 hours

Nodes Used

Node Type Purpose
Webhook Receives WhatsApp messages via Twilio webhook
HTTP Request Downloads voice message files from WhatsApp
OpenAI Transcribe Converts audio messages to text
Google Sheets Manages user data, prompts, and report storage
If (Conditional) Routes workflow based on message type and user status
Set Formats and structures data between nodes
AI Agent (LangChain) Processes user inputs with role-specific prompts
Structured Output Parser Ensures AI responses follow defined JSON schemas
OpenAI Chat Model Provides language model capabilities for AI agents
Memory Buffer Maintains conversation context for users
Twilio Sends WhatsApp responses back to users
Schedule Trigger Automates daily reminder system
Code Custom JavaScript for data processing and filtering
Aggregate Combines multiple data items for processing

External Services & Credentials Required

Required Credentials

  • Google Service Account: For accessing Google Sheets containing user data, prompts, and reports
  • OpenAI API: For audio transcription and AI chat model functionality
  • Twilio API: For WhatsApp webhook integration and message sending

External Services

  • Google Sheets: Stores user information, role-specific prompts, and generated reports
  • OpenAI: Provides transcription and language model services
  • Twilio/WhatsApp: Handles message reception and delivery
  • WhatsApp Media URLs: For downloading voice message files

Environment Variables

No explicit environment variables are defined in this workflow. All configuration is handled through: - Webhook URLs (embedded in webhook nodes) - Google Sheets document IDs (configured in Google Sheets nodes) - Credential references (stored in n8n credential system)

Data Flow

Input

  • WhatsApp messages (text or audio) from users
  • User WhatsApp IDs for identification
  • Voice message files (when applicable)

Processing

  • Audio transcription to text
  • User role identification and assignment
  • AI-powered response generation based on role-specific prompts
  • Report formatting in markdown

Output

  • Structured AI responses sent via WhatsApp
  • User data stored in Google Sheets (Users tab)
  • Generated reports stored in Google Sheets (Reports tab)
  • Reminder messages for inactive users

Error Handling

The workflow includes several error handling mechanisms: - Always Output Data: User existence checks continue workflow even if no user is found - Continue on Error: Role assignment continues even if errors occur - Conditional Routing: Multiple IF nodes ensure proper flow control based on data availability - Disabled Nodes: Some Twilio response nodes are disabled, likely for testing purposes

Known Limitations

Based on the workflow structure: - The workflow is currently marked as inactive - Some response nodes are disabled, which may affect user communication - Role assignment is limited to predefined roles (0-5) with no custom role creation - Audio processing depends on WhatsApp media URL accessibility - Reminder system only checks for reports from the previous day

No related workflows are explicitly referenced in this implementation.

Setup Instructions

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

  2. Configure Credentials:

    • Set up Google Service Account with access to the specified Google Sheets
    • Configure OpenAI API credentials
    • Set up Twilio account with WhatsApp integration
  3. Prepare Google Sheets:

    • Create or access the spreadsheet with ID: 1-rSu9reEnlEIR80dXusX0GxfmpAUMli-2MXNEVVndgI
    • Ensure sheets exist: Users, VoiceNotePrompts, Reports
    • Set up appropriate column headers for user data and reports
  4. Configure Webhook:

    • Set up Twilio webhook to point to your n8n webhook URL
    • Update webhook path if needed: afac3d91-a4a3-4dba-b1e8-54d509257815
  5. Test Setup:

    • Send a test WhatsApp message to verify webhook reception
    • Test audio transcription with a voice message
    • Verify user onboarding flow for new users
  6. Activate Workflow:

    • Enable any disabled nodes as needed
    • Set workflow to active status
    • Monitor initial executions for proper functionality
  7. Schedule Configuration:

    • Verify reminder schedule (9 AM and 3 PM) matches your timezone requirements
    • Test reminder system with sample data