AI-Powered Email Responder & Feedback Collector with OpenAI and Google Sheets
Integrates with:
Overview
Unlock Automated Email Management & Response Refinement with this AI Agent
This powerful n8n AI Agent streamlines your email communication by automatically handling incoming messages. When an email is received via Gmail (from specified senders), the agent extracts its content, employs OpenAI to generate a relevant and contextual reply, and sends it back to the recipient.
Beyond just replying, this agent is designed for continuous improvement. It embeds feedback links (Yes/No) in the outgoing email. When a recipient clicks a link, their feedback is captured via a webhook and recorded alongside the original email and the AI-generated reply in a Google Sheet. If a designated spreadsheet doesn't exist, the agent will create one automatically. This system not only saves you time but also builds a valuable dataset for analyzing AI response effectiveness and potentially fine-tuning your language models.
Key Features & Benefits
- Intelligent Email Reception: Triggers on new Gmail messages from configured recipients.
- AI-Powered Reply Generation: Leverages OpenAI's capabilities to craft context-aware email responses.
- Automated Email Sending: Dispatches replies directly through Gmail.
- Integrated Feedback Loop: Captures user satisfaction (Helpful: Yes/No) via webhook-linked responses in the email body.
- Comprehensive Data Logging: Stores the initial email, the AI's reply, a unique ID, and user feedback in Google Sheets.
- Dynamic Spreadsheet Management: Automatically creates a new Google Sheet with appropriate headers if one isn't specified or found.
- Configurable AI Behavior: Allows customization of token limits for OpenAI to manage response length and cost.
- Selective Processing: Filters emails based on sender and checks if the email content length is within processing limits to avoid errors and unnecessary costs.
Use Cases
- Automating initial responses for B2C e-commerce customer inquiries and gathering feedback on response quality.
- Streamlining B2B SaaS support by providing quick AI-generated answers and logging interactions for agent review and dataset creation.
- Building a dataset of email interactions and AI performance for fine-tuning LLMs for specific business communication styles.
- Managing high-volume email communications by pre-drafting replies for solopreneurs and small teams, with a mechanism for quality assessment.
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).
- Google (Gmail and Google Sheets) OAuth2 credentials configured in n8n.
- Your n8n instance must have a publicly accessible base URL for the feedback webhook to function (e.g.,
https://your-n8n-instance.com
). This URL is used via the$env.WEBHOOK_URL
variable.
Setup Instructions
- Download the n8n workflow JSON file.
- Import the workflow into your n8n instance.
- Configure Credentials:
- Update the 'OpenAI' node ('Generate reply') with your OpenAI API credential.
- Update the 'Gmail Trigger' node ('On email received') with your Gmail OAuth2 credential.
- Update the 'Gmail' node ('Send reply to recipient') with your Gmail OAuth2 credential.
- Update all 'Google Sheets' nodes with your Google Sheets OAuth2 credential. (Ensure nodes named 'Create spreadsheet', 'Paste data', 'Create or update rows', 'Send feedback for fine-tuned data' are correctly configured).
- Configure Settings in the 'Configure' node:
recipients
: Set a comma-separated list of email addresses that should trigger AI replies. Use*
to respond to all incoming emails (use with caution).spreadsheetName
&worksheetName
: Define names for the Google Sheet and worksheet.spreadsheetId
&worksheetId
: Leave blank if you want the workflow to create a new spreadsheet. If you have an existing sheet, provide its ID and the worksheet ID.maxTokenSize
: The maximum token size for the OpenAI model (input + output).replyTokenSize
: The desired maximum token size for the AI's reply part.
- Review Webhook URL: The 'Email template' node uses
$env.WEBHOOK_URL
to construct feedback links. Ensure this environment variable is set correctly in your n8n environment (pointing to your n8n instance's public URL), or modify the 'Email template' node to hardcode the URL if preferred (e.g.,https://<your-n8n-domain>/webhook/...
). - Test and Activate:
- It's highly recommended to run a test by sending an email to the monitored account from an address you've whitelisted in
recipients
. - Once configured and tested, activate both the 'On email received' trigger and ensure the 'On feedback given' webhook is active (it activates with the workflow).
- It's highly recommended to run a test by sending an email to the monitored account from an address you've whitelisted in
Want your own unique AI agent?
Talk to us - we know how to build custom AI agents for your specific needs.
Schedule a Consultation