01 Email - AI-Powered Email Response System¶
An automated email processing workflow that monitors Gmail for unread messages, generates AI-powered draft responses using OpenAI's GPT-4, and stores all email data and generated responses in Airtable for review and management.
Purpose¶
No business context provided yet — add a context.md to enrich this documentation.
This workflow appears to be designed for automated email management, helping users handle incoming emails by generating contextual AI responses while maintaining a centralized database of all communications.
How It Works¶
- Scheduled Monitoring: Every 2 hours, the workflow automatically checks for new unread emails in Gmail
- Email Retrieval: Fetches all unread emails and extracts detailed information including sender, subject, and body content
- AI Response Generation: Uses an AI agent powered by GPT-4 to analyze each email and generate appropriate draft responses based on predefined user context and examples
- Data Storage: Creates records in Airtable containing the original email details alongside the AI-generated response drafts
- Email Management: Marks processed emails as read to prevent reprocessing
Workflow Diagram¶
graph TD
A[Schedule Trigger<br/>Every 2 hours] --> B[Gets ALL Emails<br/>Gmail - Unread only]
B --> C[Pulls GRANULAR Details<br/>Gmail - Get message details]
C --> D[AI Agent<br/>Generate response draft]
D --> E[Creates Record in Airtable<br/>Store email + draft]
E --> F[Marks Emails Unread<br/>Gmail - Mark as read]
G[OpenAI Chat Model<br/>GPT-4] -.-> D
Trigger¶
Schedule Trigger: Runs automatically every 2 hours to check for new unread emails.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Schedule Trigger | Initiates workflow execution every 2 hours |
| Gmail (Gets ALL Emails) | Retrieves list of unread emails from Gmail |
| Gmail (Pulls GRANULAR Details) | Fetches detailed email content including attachments |
| AI Agent | Processes email content and generates contextual responses |
| OpenAI Chat Model | Provides GPT-4 language model for AI agent |
| Airtable | Creates records storing email data and generated responses |
| Gmail (Marks Emails Unread) | Marks processed emails as read |
| Structured Output Parser | Formats AI responses into structured JSON (connected but unused) |
External Services & Credentials Required¶
Gmail¶
- Required: Gmail OAuth2 credentials
- Permissions: Read emails, modify email labels
- Purpose: Email monitoring and management
OpenAI¶
- Required: OpenAI API key
- Model: GPT-4 (gpt-4o)
- Purpose: AI response generation
Airtable¶
- Required: Airtable API key or OAuth
- Base: "Email Collection System" (app4qQr7DGv3at14a)
- Table: "Email Aggregation" (tblmUrFXNdzDCve4a)
- Purpose: Data storage and management
Environment Variables¶
No specific environment variables are configured in this workflow. All credentials are managed through n8n's credential system.
Data Flow¶
Input¶
- Source: Gmail unread emails
- Data: Email metadata (sender, subject, thread ID) and content (body text, attachments)
Processing¶
- AI Context: User profile for "Drake Surach" from "AiF" company
- Response Style: Professional, community-focused, declining external opportunities
- Examples: Predefined response patterns for different email types
Output¶
- Airtable Record: Contains sender name, email address, subject, original body, AI-generated draft response, and thread ID
- Gmail: Emails marked as read after processing
Error Handling¶
No explicit error handling nodes are present in this workflow. The workflow relies on n8n's default error handling: - Failed nodes will stop execution - Gmail API rate limits may cause temporary failures - OpenAI API failures will prevent response generation
Known Limitations¶
- No error recovery mechanisms for API failures
- Processes all unread emails without filtering or prioritization
- AI responses are generated but not automatically sent
- No handling for email threads or conversation context
- Limited to text-based emails (attachment content not processed for AI analysis)
Related Workflows¶
No related workflows mentioned in the provided context.
Setup Instructions¶
1. Import Workflow¶
- Import the workflow JSON into your n8n instance
- The workflow will be imported as inactive
2. Configure Credentials¶
Gmail: 1. Create Gmail OAuth2 credentials in n8n 2. Authorize access to your Gmail account 3. Assign credentials to all Gmail nodes
OpenAI: 1. Create OpenAI credentials in n8n 2. Add your OpenAI API key 3. Assign to the OpenAI Chat Model node
Airtable: 1. Create Airtable credentials in n8n 2. Add your Airtable API key or configure OAuth 3. Verify base and table IDs match your Airtable setup 4. Assign credentials to the Airtable node
3. Customize AI Agent¶
- Review the AI agent's system message and user context
- Update user details (name, company, aspirations) to match your profile
- Modify response examples to match your communication style
4. Test Workflow¶
- Run the workflow manually to test email processing
- Verify Airtable records are created correctly
- Check that emails are marked as read after processing
5. Activate Workflow¶
- Enable the workflow to start automatic execution
- Monitor the first few runs to ensure proper operation
6. Airtable Setup¶
Ensure your Airtable base has a table with these fields: - Sender Name (Text) - From Email (Text) - Subject (Text) - Email Body (Long text) - Body Draft Reply (Long text) - Thread ID (Text)