AudioReports3¶
A WhatsApp-based AI assistant workflow that processes text and voice messages to provide intelligent responses about mentor activities and coaching programs. The system integrates with OpenAI's Assistant API to deliver contextual responses while supporting voice note transcription and mentor database lookups.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
How It Works¶
- Message Reception: The workflow receives WhatsApp messages via webhook, extracting sender information, message content, and any attached voice notes
- Voice Processing: If a voice note is present, it gets transcribed using OpenAI's Whisper API
- Mentor Detection: The system scans messages for 6-digit mentor IDs and loads relevant mentor data from Google Sheets when found
- Thread Management: Creates or uses existing OpenAI conversation threads for each user to maintain context
- AI Processing: Sends the processed message (text + transcription + mentor context) to OpenAI Assistant for intelligent response generation
- Function Handling: If the assistant needs to look up mentor information, it executes function calls to query the mentor database
- Response Delivery: Formats and sends the AI-generated response back to the user via WhatsApp
The workflow includes two parallel processing paths - one appears to be the main flow and another (with "1" suffixed nodes) that may be for testing or alternative processing.
Workflow Diagram¶
graph TD
A[WhatsApp Webhook1] --> B[Extract Message Info]
B --> C[Set Configuration]
C --> D[Has Voice Note?]
C --> E[Has Mentor ID?]
C --> F[Create Conversation Thread]
D -->|Yes| G[Prepare Voice Note]
D -->|No| H[Prepare Message for Assistant]
E -->|Yes| I[Load Specific Mentor Data]
E -->|No| H
I --> J[Filter Mentor Data]
J --> H
F --> H
G --> K[Transcribe Voice Note]
K --> L[Prepare Message for Assistant1]
H --> M[Add Message to Thread]
M --> N[Run Assistant]
N --> O[Wait for Processing]
O --> P[Check Run Status]
P --> Q[Is Completed?]
P --> R[Needs Function Call?]
Q -->|Yes| S[Get Assistant Response]
Q -->|No| T[Send Processing Message]
R -->|Yes| U[Handle Function Calls]
U --> V[Submit Function Results]
V --> W[Wait After Functions]
W --> S
S --> X[Extract Assistant Response]
X --> Y[Send WhatsApp Response]
L --> Z[Add Message to Thread1]
Z --> AA[Run Assistant1]
AA --> BB[Wait for Processing1]
BB --> CC[Check Run Status1]
CC --> DD[Is Completed?1]
CC --> EE[Needs Function Call?1]
DD --> FF[Get Assistant Response1]
EE --> GG[Handle Function Calls1]
GG --> HH[Submit Function Results1]
HH --> II[Wait After Functions1]
II --> FF
FF --> JJ[Extract Assistant Response1]
JJ --> KK[Send WhatsApp Response1]
Trigger¶
WhatsApp Webhook: HTTP POST endpoint that receives incoming WhatsApp messages from Twilio. The webhook listens on the path /coaching-start for the main flow.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming WhatsApp messages from Twilio |
| Code | Processes message data, extracts mentor IDs, prepares payloads, and handles function responses |
| Set | Configures workflow variables like Assistant ID |
| If | Conditional logic for voice notes, mentor IDs, and processing status |
| HTTP Request | Communicates with OpenAI API and Google Sheets API |
| OpenAI | Transcribes voice notes using Whisper |
| Twilio | Sends WhatsApp responses back to users |
| Wait | Adds delays for processing completion |
External Services & Credentials Required¶
- OpenAI API: For Assistant conversations and voice transcription
- Credential:
openAiApi - Used for: Assistant API calls, Whisper transcription
- Credential:
- Twilio API: For WhatsApp messaging
- Credential:
twilioApi - Used for: Sending WhatsApp responses
- Credential:
- Google Sheets API: For mentor data storage
- Credential:
googleSheetsOAuth2ApiorgoogleApi - Used for: Loading mentor activity data
- Credential:
Environment Variables¶
The workflow uses hardcoded configuration values:
- Assistant ID: asst_3f6EDOYjPdAeKRTT7q6tKmiy
- Google Sheet ID: Referenced from configuration but not visible in the workflow
- Twilio WhatsApp Number: +14155238886
Data Flow¶
Input: - WhatsApp message with text content - Optional voice note attachment - Sender phone number and profile information
Processing: - Message text and voice transcription - Mentor ID extraction (6-digit numbers) - Mentor database lookup when applicable - OpenAI Assistant conversation with function calling
Output: - Intelligent WhatsApp response based on message content and context - Mentor information when requested - Error messages for processing issues
Error Handling¶
The workflow includes several error handling mechanisms: - Try-catch blocks in JavaScript code nodes for graceful error handling - Fallback responses when AI processing fails - Processing timeout messages when assistant takes too long - Validation for missing mentor data or invalid requests
Known Limitations¶
Based on the workflow structure: - Responses are limited to 1500 characters for WhatsApp compatibility - Voice note processing may add significant latency - Mentor database queries are limited to Google Sheets format - The workflow appears to have duplicate processing paths which may cause confusion
Related Workflows¶
No related workflows identified from the current configuration.
Setup Instructions¶
-
Import Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up OpenAI API credentials with access to Assistant API and Whisper
- Configure Twilio credentials for WhatsApp messaging
- Set up Google Sheets API access for mentor data
-
Update Configuration:
- Replace the Assistant ID in "Set Configuration" node with your OpenAI Assistant
- Update Google Sheet ID reference
- Verify Twilio WhatsApp number
-
Set Up Webhook:
- Activate the workflow to generate webhook URL
- Configure Twilio WhatsApp webhook to point to the generated URL
-
Prepare Data Sources:
- Set up Google Sheet with mentor data including mentor_id column
- Configure OpenAI Assistant with appropriate instructions and function definitions
-
Test:
- Send test messages to your WhatsApp number
- Verify voice note transcription works
- Test mentor ID lookup functionality