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.
This workflow appears to serve educational programs (EBA and EXP) by: - Onboarding new users and assigning them appropriate roles - Processing voice messages and text inputs via WhatsApp - Generating AI-powered responses and reports based on user context - Maintaining user data and conversation history in Google Sheets
How It Works¶
- Message Reception: The workflow receives WhatsApp messages (text or voice) through a webhook
- Voice Processing: If the message is a voice note, it downloads and transcribes the audio using OpenAI
- User Validation: Checks if the sender exists in the user database and has complete profile information
- User Onboarding: For new or incomplete users, runs an onboarding process to collect name and assign role (EBA/EXP program participant, trainer, or mentor)
- Role Assignment: Updates the user database with collected information and assigned role ID
- AI Processing: For existing users, retrieves role-specific prompts and processes the message through an AI agent
- Report Generation: Creates structured reports in markdown format based on the user's input and role
- Response Delivery: Sends AI-generated responses back to the user via WhatsApp
- Data Storage: Saves generated reports and timestamps to the Google Sheets database
Workflow Diagram¶
graph TD
A[WhatsApp Webhook] --> B{Voice Note?}
B -->|Yes| C[Download Voice File]
B -->|No| D[Text Input]
C --> E[Transcribe Audio]
E --> F[Voice Output]
D --> F
F --> G[User Message]
G --> H{User Exists?}
H -->|Yes| I[Check User in DB]
I --> J{Complete Profile?}
J -->|Yes| K[Get Current Prompt]
J -->|No| L[Onboarding Agent]
L --> M[Assign Role]
M --> N[Send Response]
K --> O[AI Agent]
O --> P[Upsert Report]
P --> Q[Send Response]
Trigger¶
Webhook: POST endpoint at path 23d0efd9-c4dc-4cdd-82a8-f389082afdf2 that receives WhatsApp messages from Twilio.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming WhatsApp messages from Twilio |
| HTTP Request | Downloads voice message files from WhatsApp |
| OpenAI (Transcription) | Converts voice messages to text |
| Google Sheets | Reads/writes user data, prompts, and reports |
| If (Conditional) | Routes workflow based on message type and user status |
| Set | Formats and structures data between nodes |
| AI Agent (LangChain) | Processes messages with role-specific AI 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 per user |
| Twilio | Sends responses back to users via WhatsApp |
External Services & Credentials Required¶
Google Sheets API¶
- Service Account: For reading/writing user data, prompts, and reports
- Document ID:
1Vv_gTpvI8RHPPrn0iwzypG3qKRYeLDb1HZFPDzYe5ng(E Lab Report spreadsheet) - Sheets: Users, VoiceNotePrompts
OpenAI API¶
- API Key: For audio transcription and chat completions
- Models Used: GPT-4.1, GPT-4.1-mini
Twilio API¶
- Account SID & Auth Token: For WhatsApp messaging
- WhatsApp Number: +14155238886
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 voice) containing:
- User phone number (WaId)
- Message content or audio file URL
- Message metadata
Processing¶
- User profile lookup and validation
- Voice-to-text transcription (if applicable)
- Role-based AI prompt selection
- Conversation memory management
- Structured response generation
Output¶
- WhatsApp responses to users
- Updated user records in Google Sheets
- Generated reports stored with timestamps
- Conversation history maintained in memory
Error Handling¶
The workflow includes several conditional paths for error handling:
- Unknown Users: Redirects to onboarding flow for profile completion
- Incomplete Profiles: Triggers role assignment process
- Message Type Detection: Handles both voice and text inputs appropriately
- Always Output Data: User existence check node configured to continue workflow even if no matches found
Known Limitations¶
- Workflow is currently archived and inactive
- Response sending nodes are disabled
- No explicit error handling for API failures or malformed data
- Memory buffer is session-based but may not persist across workflow restarts
Related Workflows¶
No related workflows mentioned in the provided context.
Setup Instructions¶
-
Import Workflow: Import the JSON configuration into your n8n instance
-
Configure Credentials:
- Set up Google Service Account with access to the target spreadsheet
- Configure OpenAI API credentials
- Set up Twilio account with WhatsApp sandbox or approved number
-
Update Webhook URL:
- Activate the webhook node to get the production URL
- Configure Twilio to send WhatsApp messages to this endpoint
-
Prepare Google Sheets:
- Ensure the spreadsheet contains "Users" and "VoiceNotePrompts" sheets
- Set up appropriate column headers matching the node configurations
-
Test Configuration:
- Send a test message to verify webhook reception
- Check user onboarding flow with a new phone number
- Verify AI responses and report generation
-
Activate Workflow:
- Enable the workflow in n8n
- Re-enable the Twilio response nodes if needed
- Monitor execution logs for any issues