01 Email - AI-Powered Email Response System¶
An automated workflow that monitors Gmail for unread emails, generates personalized AI responses using OpenAI's GPT-4, and stores the results 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, specifically for someone who receives many inquiries and needs AI assistance to draft appropriate responses while maintaining a personal touch and consistent messaging aligned with their brand and values.
How It Works¶
- Scheduled Monitoring: Every 2 hours, the workflow checks Gmail for unread emails
- Email Retrieval: Fetches all unread emails and their detailed content including attachments
- AI Response Generation: For each email, an AI agent analyzes the content and generates a personalized response based on predefined user context (Drake Surach from AiF company)
- Data Storage: Stores the original email details and AI-generated response in an Airtable database
- Email Management: Marks the processed emails as read to prevent reprocessing
The AI agent is specifically trained to respond as Drake Surach, a 21-year-old focused on teaching AI to his community, with clear guidelines about declining external opportunities while being helpful and professional.
Workflow Diagram¶
graph TD
A[Schedule Trigger<br/>Every 2 Hours] --> B[Gets ALL Emails<br/>Unread Only]
B --> C[Pulls GRANULAR Details<br/>Get Message Content]
C --> D[AI Agent<br/>Generate Response]
E[OpenAI Chat Model<br/>GPT-4] --> D
D --> F[Creates Record in Airtable<br/>Store Email & Response]
F --> G[Marks Emails Unread<br/>Mark as Read]
Trigger¶
Schedule Trigger: Runs automatically every 2 hours to check for new unread emails.
Nodes Used¶
| Node Type | Purpose |
|---|---|
| Schedule Trigger | Initiates workflow every 2 hours |
| Gmail (Gets ALL Emails) | Retrieves unread emails from Gmail |
| Gmail (Pulls GRANULAR Details) | Fetches detailed email content and attachments |
| AI Agent | Generates personalized email responses using predefined context |
| OpenAI Chat Model | Provides GPT-4 language model for AI agent |
| Airtable (Creates Record) | Stores email data and AI responses |
| Gmail (Marks Emails Unread) | Marks processed emails as read |
| Structured Output Parser | Formats AI responses (connected but not actively used) |
External Services & Credentials Required¶
Gmail¶
- OAuth2 credentials for Gmail API access
- Scopes needed: Read emails, modify email labels/status
- Account: Must be the Gmail account to monitor
OpenAI¶
- API Key for GPT-4 access
- Model: gpt-4o configured in the Chat Model node
Airtable¶
- API Key or Personal Access Token
- Base ID: app4qQr7DGv3at14a (Email Collection System)
- Table ID: tblmUrFXNdzDCve4a (Email Aggregation)
Environment Variables¶
No environment variables are explicitly used in this workflow. All configuration is done through node parameters and credential connections.
Data Flow¶
Input¶
- Unread Gmail messages with subject, body, sender information, and attachments
Processing¶
- Email content is analyzed by AI agent with context about Drake Surach's persona and business focus
- AI generates appropriate responses based on email type (inquiries, opportunities, community interest)
Output¶
- Airtable Record containing:
- Sender Name
- From Email
- Subject
- Email Body
- AI-Generated Draft Reply
- Thread ID
Error Handling¶
The workflow does not include explicit error handling nodes. Potential failure points: - Gmail API rate limits or authentication issues - OpenAI API failures or quota exceeded - Airtable API connection problems - Email parsing errors for malformed messages
Consider adding error handling nodes and notification systems for production use.
Known Limitations¶
- No explicit error handling or retry mechanisms
- Processes all unread emails without filtering (could include spam or irrelevant emails)
- AI responses are stored but not automatically sent (requires manual review and sending)
- No duplicate detection if workflow runs multiple times on same emails
- Limited to Gmail only (no other email providers)
Related Workflows¶
No related workflows mentioned in the provided context.
Setup Instructions¶
-
Import Workflow
- Import the JSON into your n8n instance
- The workflow will be inactive by default
-
Configure Gmail Credentials
- Set up Gmail OAuth2 credentials in n8n
- Test connection with your Gmail account
- Ensure proper scopes for reading and modifying emails
-
Configure OpenAI Credentials
- Add your OpenAI API key to n8n credentials
- Verify GPT-4 access in your OpenAI account
-
Configure Airtable
- Set up Airtable credentials (API key or PAT)
- Verify access to the specified base and table
- Ensure table schema matches the expected fields
-
Customize AI Agent
- Review the system message in the AI Agent node
- Update user information (name, company, age, aspirations) as needed
- Modify examples to match your communication style
-
Test the Workflow
- Run manually first to verify all connections work
- Check that emails are properly retrieved and processed
- Verify Airtable records are created correctly
-
Activate
- Enable the workflow to start automatic processing
- Monitor initial runs to ensure proper operation
-
Optional Enhancements
- Add error handling nodes
- Implement email filtering logic
- Set up notifications for failures
- Add automatic email sending (with appropriate safeguards)