AI Email Responder & Feedback Collector with OpenAI, Gmail & Google Sheets
Integrates with:
Overview
Unlock Automated, Intelligent Email Responses & Build a Fine-Tuning Dataset
This AI Agent streamlines your email communication by automatically replying to incoming Gmail messages from specified senders using OpenAI's powerful language models. It doesn't just send replies; it also meticulously logs the entire interaction—original email, AI-generated response, and a unique ID—into a Google Sheet.
Crucially, this agent incorporates a feedback loop. Each AI-generated email includes simple 'Yes' or 'No' links, allowing recipients to rate the usefulness of the response. This feedback is captured via a webhook and recorded directly into the Google Sheet, creating a valuable, structured dataset perfect for fine-tuning your AI models for even better performance over time. If a Google Sheet isn't specified in the 'Configure' node, the agent will create one for you.
Key Features & Benefits
- AI-Powered Replies: Leverages OpenAI (GPT models) to understand email context and generate relevant, human-like responses.
- Intelligent Email Parsing: Utilizes an advanced parser to extract the core message from email threads, improving reply accuracy.
- Selective Processing: Filters incoming Gmail messages based on a configurable list of senders, ensuring the AI only handles designated communications.
- Automated Conversation Logging: Automatically creates or updates a Google Sheet to store initial messages, AI-generated replies, unique interaction IDs, and feedback.
- Integrated Feedback Loop: Embeds 'Yes/No' feedback links in replies. Recipient responses are captured via webhook and logged to the Google Sheet.
- Data for Fine-Tuning: Systematically builds a dataset of interactions and feedback, invaluable for improving your custom AI models.
- Dynamic Spreadsheet Management: If you don't provide spreadsheet/worksheet IDs in the 'Configure' node, it creates them. Otherwise, it appends/updates rows in your specified sheet.
- Configurable Parameters: Easily adjust OpenAI token limits, specify target email recipients, and provide Google Sheet details through a central 'Configure' node.
- Token Limit Handling: Includes a check to assess if an incoming email is too long for the OpenAI model's token limit before processing.
Use Cases
- Automating responses to common customer inquiries or FAQs.
- Providing instant AI-assisted first-line support via email.
- Gathering feedback on AI-generated content to monitor and improve quality.
- Building a structured dataset for fine-tuning custom LLMs for specific email response tasks.
- Streamlining communication for solopreneurs by auto-replying to select incoming emails.
- Logging important email exchanges and AI interactions for record-keeping and analysis.
Prerequisites
- An n8n instance (Cloud or self-hosted).
- OpenAI API Key with access to a suitable model (e.g., gpt-3.5-turbo or gpt-4).
- Gmail account credentials (OAuth2) for receiving and sending emails.
- Google Sheets API credentials (OAuth2) for logging data.
- Your n8n instance's base URL (defined by
WEBHOOK_URL
environment variable) must be publicly accessible for the feedback links in emails to work.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure the 'Configure' Node:
recipients
(Required): Comma-separated list of email addresses that will trigger AI replies (e.g.,user1@example.com,user2@example.com
). Use*
to reply to all incoming emails (use with extreme caution).spreadsheetId
(Optional): ID of an existing Google Sheet to use. If empty, a new sheet will be created.worksheetId
(Optional): ID of an existing worksheet within thespreadsheetId
. If empty, the first sheet or a new one named 'Database' will be used/created.spreadsheetName
(Default: 'ChatGPT responses'): Name for the Google Sheet if a new one is created.worksheetName
(Default: 'Database'): Name for the worksheet if a new one is created.maxTokenSize
(Default: 4000): Max tokens for the incoming email content processing by OpenAI.replyTokenSize
(Default: 300): Max tokens for the AI-generated reply.
- Update Credentials:
- 'On email received' (Gmail Trigger node): Connect your Gmail account for incoming emails.
- 'Generate reply' (OpenAI node): Enter your OpenAI API Key.
- 'Send reply to recipient' (Gmail node): Connect your Gmail account for sending replies (can be the same as the trigger).
- Google Sheets Nodes ('Create spreadsheet', 'Paste data', 'Create or update rows', 'Send feedback for fine-tuned data'): Connect your Google Sheets account.
- Webhook Accessibility: Ensure your n8n instance's
WEBHOOK_URL
environment variable is correctly set and your instance is publicly accessible. This is crucial for the feedback links in the emails to function. - Review Email Template: Customize the 'Email template' (HTML node) for the AI reply format and feedback link appearance if desired.
- Activate the Workflow. The first relevant email will initiate the process, including creating the Google Sheet if IDs aren't provided in the 'Configure' node.
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Request a Consultation