WhatsApp Multi Model Content Processor¶
This workflow creates an intelligent WhatsApp bot that can process and analyze multiple types of content including images, PDFs, spreadsheets, Word documents, and voice messages. It uses AI to understand and respond to various file formats sent via WhatsApp, providing users with summaries, analysis, and answers to questions about their uploaded content.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow serves users who need to quickly analyze and extract insights from various document types through WhatsApp. It eliminates the need to manually process files by automatically detecting content types, converting them to analyzable formats, and providing AI-powered summaries and responses.
How It Works¶
- Message Reception: The workflow receives WhatsApp messages through a webhook endpoint
- Content Type Detection: Analyzes incoming messages to determine if they contain files (PDF, images, spreadsheets, Word docs, audio) or text questions
- File Processing: Downloads and converts files to text format using appropriate extraction methods:
- Spreadsheets are converted to JSON then text
- PDFs are extracted directly to text
- Images are analyzed using GPT-4 Vision
- Word documents are converted via CloudConvert API
- Audio files are transcribed using OpenAI Whisper
- AI Analysis: Processes the extracted content using GPT-4 with memory to provide summaries and answer questions
- Response Delivery: Sends the AI-generated analysis back to the user via WhatsApp
Workflow Diagram¶
graph TD
A[WhatsApp Webhook] --> B[Analyze Input Type]
B --> C{Content Type Switch}
C -->|Spreadsheet| D[Download Sheet]
D --> E[Convert to JSON]
E --> F[JSON to Text]
F --> G[Content Analyze]
C -->|PDF| H[Download File]
H --> I{File Type Path}
I -->|PDF| J[PDF to Text]
J --> G
C -->|Image| H
I -->|Image| K[Analyze Image with GPT-4V]
K --> L[Content to Text]
L --> G
C -->|Word Doc| H
I -->|Word| M[Create CloudConvert Job]
M --> N[Wait]
N --> O[Convert Docs to Text]
O --> P{Conversion Status}
P -->|Finished| Q[Download Text]
P -->|Processing| N
Q --> G
C -->|Voice| R[Get Audio from Twilio]
R --> S{File Size Check}
S -->|Large| T[Download Voice File]
T --> U[Import to CloudConvert]
U --> V[Wait]
V --> W[Convert Audio]
W --> X{Audio Status}
X -->|Finished| Y[Download Audio]
X -->|Processing| V
Y --> Z[Transcribe with OpenAI]
S -->|Small| Z
Z --> AA[Edit Fields]
AA --> G
C -->|Text Question| G
G --> BB[OpenAI Chat Model + Memory]
BB --> CC[Send to WhatsApp]
Trigger¶
Webhook: POST endpoint at /whatsapp-multimedia that receives WhatsApp messages from Twilio's messaging service.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Webhook | Receives incoming WhatsApp messages |
| Code | Analyzes message content and determines file types |
| Switch | Routes content based on type (spreadsheet, PDF, image, voice, text, Word) |
| HTTP Request | Downloads files from Twilio and external services |
| Extract From File | Converts PDFs and spreadsheets to text |
| OpenAI (Vision) | Analyzes images and transcribes audio |
| LangChain Agent | Processes content with GPT-4 and provides analysis |
| OpenAI Chat Model | Powers the AI analysis with GPT-4 |
| Buffer Window Memory | Maintains conversation context |
| Twilio | Sends responses back to WhatsApp |
| Wait | Handles asynchronous file conversion processes |
| If | Checks file sizes for processing decisions |
External Services & Credentials Required¶
- Twilio API: For WhatsApp messaging (sending/receiving)
- OpenAI API: For GPT-4 chat, image analysis, and audio transcription
- CloudConvert API: For converting Word documents and large audio files
- HTTP Basic Auth: For accessing Twilio media files
Environment Variables¶
No specific environment variables are configured in this workflow. All authentication is handled through n8n credential management.
Data Flow¶
Input: WhatsApp messages containing: - Text questions - Image files (JPG, PNG, etc.) - PDF documents - Spreadsheet links (Google Sheets, CSV, XLSX) - Word documents (DOC, DOCX) - Audio messages (various formats)
Output: WhatsApp text responses containing: - Content summaries and analysis - Answers to specific questions about uploaded content - Key insights, trends, and important details extracted from files
Error Handling¶
The workflow includes several error handling mechanisms: - File Size Checks: Large audio files are processed through CloudConvert for format conversion - Conversion Status Monitoring: Wait loops check CloudConvert job status before proceeding - Multiple Processing Paths: Different extraction methods for various file types - Fallback Responses: AI responds with "I couldn't find that information" when data is unavailable
Known Limitations¶
- Audio files larger than 25MB require additional processing time through CloudConvert
- File processing depends on external service availability (CloudConvert, OpenAI)
- Memory is maintained per workflow session, not per individual user
- Some file formats may not be supported by the extraction services
Related Workflows¶
No related workflows specified in the current context.
Setup Instructions¶
-
Import the Workflow: Import the JSON into your n8n instance
-
Configure Credentials:
- Set up Twilio API credentials for WhatsApp messaging
- Add OpenAI API key for GPT-4 and vision capabilities
- Configure CloudConvert API token for document conversion
- Set up HTTP Basic Auth for Twilio media access
-
Webhook Configuration:
- Note the webhook URL generated for the "WhatsApp message" node
- Configure this URL in your Twilio WhatsApp sandbox or production setup
-
Test the Setup:
- Send a text message to verify basic functionality
- Test with different file types (PDF, image, spreadsheet, audio)
- Verify responses are sent back through WhatsApp
-
Production Deployment:
- Activate the workflow
- Monitor execution logs for any processing issues
- Adjust memory settings or processing timeouts as needed