Workflow n8n para detecção e processamento de anexos em emails via…
INEMA
How This Solution Works:
Gmail Trigger: We start with a Gmail trigger that's configured to download all messages, including their binary attachments. Analyze Attachments: This code node performs a thorough analysis to:
Detect if the email has attachments by checking both the attachments array and binary data Identify the types of attachments (image, PDF, document) Create useful flags like hasImageAttachment, hasPdfAttachment, and hasDocumentAttachment Generate a list of attachment names and a user-friendly summary
Conditional Logic: We use a series of "If" nodes to: First check if the email has any attachments Then check for specific attachment types (images, PDFs, documents)
Type-Specific Processing: Based on attachment type, different nodes process the specific attachment types: Image processor identifies and lists all image attachments PDF processor handles PDF files Document processor handles various document formats (Word, Excel, PowerPoint, etc.)
No Attachments Path: Handles the case where no attachments are detected Merge: All paths converge at the end, allowing you to take further actions with the processed data
Customization Tips: You can extend the code in the "Process" nodes to perform additional operations on attachments Add more specific attachment type detection by examining file extensions or MIME types Connect additional nodes after the "Merge" to handle the attachments (download, analyze, etc.) If you need to process specific attachment formats, add more conditional branches
This workflow provides a comprehensive solution to detect attachments and identify their types, giving you a solid foundation to build upon for your specific needs.
1