AI Email Assistant with Feedback Logging to Google Sheets

This workflow creates an intelligent email assistant that uses OpenAI's GPT to automatically reply to incoming emails and logs all interactions in a Google Sheet for future fine-tuning. It's a powerful tool for anyone who wants to automate email responses while maintaining a database of AI-generated replies and user feedback.

Workflow Steps

Main Flow: Email Processing

  1. On email received (Gmail Trigger - OAuth2) — Polls Gmail every minute for new emails. Uses OAuth2 authentication to access the user's Gmail inbox.
  2. Identify trigger #1 (Set - No auth) — Tags the data with triggeredFrom: gmail to identify which trigger started the workflow.
  3. Configure (Set - No auth) — Stores configuration variables including:
    • maxTokenSize: Maximum tokens for the AI model (default: 4000)
    • replyTokenSize: Maximum tokens for the AI reply (default: 300)
    • spreadsheetId/worksheetId: Optional Google Sheet IDs
    • spreadsheetName/worksheetName: Sheet names (default: "ChatGPT responses" / "Database")
    • recipients: Comma-separated list of email addresses to process (use * for all)
  4. Determine which trigger ran (Switch - No auth) — Routes the workflow based on which trigger started it (gmail or webhook).
  5. Only continue for specific emails (IF - No auth) — Checks if the sender's email address is in the configured recipients list. If not, the email is ignored.
  6. Generate UUID (Crypto - No auth) — Creates a unique identifier for each email interaction.
  7. Extract message content (advanced) (Code - No auth) — Uses a custom JavaScript email parser to extract the reply content from the email body, removing quoted text and signatures.
  8. Is text within token limit? (IF - No auth) — Checks if the email content fits within the configured token limit. If too large, the workflow stops.
  9. Generate reply (OpenAI - API Key auth) — Sends the email content to OpenAI's GPT model with the prompt: "From: {{from}} To: {{to}} Subject: {{subject}} Body: {{reply}} Reply:". Uses the configured replyTokenSize for the response.
  10. If reply is complete (IF - No auth) — Checks if the AI response finished naturally (finish_reason = "stop"). If not, the workflow stops to avoid sending incomplete replies.
  11. Send email reply (NoOp - No auth) — Placeholder node for routing.
  12. Email template (HTML - No auth) — Creates a beautifully formatted HTML email template containing the AI response and feedback links (Yes/No) for the recipient.
  13. Send reply to recipient (Gmail - OAuth2) — Sends the HTML email as a reply to the original message using Gmail's reply operation.
  14. Send reply to database (NoOp - No auth) — Placeholder node for routing.
  15. Format data (Set - No auth) — Structures the data for Google Sheets with columns: ID, Initial message, Generated reply, Good response?.
  16. If no spreadsheet in configuration #1 (IF - No auth) — Checks if spreadsheet IDs are configured. If not, uses static data storage.
  17. Get sheet IDs #1 / Store specific sheet IDs #1 (Code - No auth) — Retrieves or stores spreadsheet IDs in workflow static data.
  18. If no sheet IDs (IF - No auth) — Checks if sheet IDs exist in static data. If not, creates a new spreadsheet.
  19. Create spreadsheet (Google Sheets - OAuth2) — Creates a new Google Sheet with the configured name and worksheet.
  20. Store spreadsheet ID (Code - No auth) — Saves the new spreadsheet ID to workflow static data.
  21. Get data from Format data node (Code - No auth) — Retrieves the formatted data for appending.
  22. Paste data (Google Sheets - OAuth2) — Appends the initial email and AI response to the spreadsheet.
  23. Get data from Format data (Code - No auth) — Retrieves data for updating existing rows.
  24. Create or update rows (Google Sheets - OAuth2) — Appends or updates rows in the spreadsheet, matching on the ID column.
  25. If spreadsheet doesn't exist (IF - No auth) — Error handling: if the sheet doesn't exist, creates a new one.

Feedback Flow

  1. On feedback given (Webhook - No auth) — Listens for HTTP GET requests when users click Yes/No links in the email.
  2. Identify trigger #2 (Set - No auth) — Tags the data with triggeredFrom: webhook.
  3. Configure (Set - No auth) — Same configuration node as above.
  4. Determine which trigger ran (Switch - No auth) — Routes to the feedback path.
  5. Record feedback (NoOp - No auth) — Placeholder for routing.
  6. Thanks for your response! (HTML - No auth) — Displays a thank you page to the user.
  7. Show HTML page (Respond to Webhook - No auth) — Returns the HTML response to the webhook caller.
  8. If no spreadsheet in configuration #2 (IF - No auth) — Checks for spreadsheet configuration.
  9. Get sheet IDs #2 / Store specific sheet IDs #2 (Code - No auth) — Retrieves or stores spreadsheet IDs.
  10. Send feedback for fine-tuned data (Google Sheets - OAuth2) — Updates the "Good response?" column in the spreadsheet with the user's feedback (Yes/No).

Setup Instructions

Required Accounts & Services

  1. Google Account — For Gmail and Google Sheets access. You'll need to create OAuth2 credentials in the Google Cloud Console.
  2. OpenAI Account — For GPT API access. You'll need an API key from platform.openai.com.

Configuration Steps

  1. Gmail Trigger: Connect your Gmail account using OAuth2. The trigger polls every minute for new emails.
  2. OpenAI Node: Add your OpenAI API key in the credentials section. The node uses the default GPT model.
  3. Google Sheets Nodes: Connect your Google account using OAuth2. The workflow can auto-create spreadsheets.
  4. Configure Node: Update the recipients field with comma-separated email addresses or * for all senders.
  5. Webhook URL: The workflow uses an environment variable WEBHOOK_URL. Set this to your n8n instance's public URL (e.g., https://your-n8n-instance.com/).

Important Notes

  • The workflow stores spreadsheet IDs in workflow static data. To reset, copy the workflow to a new one.
  • If you delete the spreadsheet, also remove it from Google Drive's trash to avoid conflicts.
  • The email parser handles multiple languages for detecting quoted replies.

Use Cases & Variations

Primary Use Cases

  • Customer Support Automation: Automatically reply to common customer inquiries with AI-generated responses.
  • Personal Email Assistant: Have AI draft replies to your emails while you review and approve them.
  • Feedback Collection: Gather user feedback on AI responses to improve the model over time.

Adaptation Ideas

  • Add Human Approval: Insert a manual approval step before sending the email reply.
  • Multiple AI Models: Experiment with different OpenAI models or switch to other AI providers.
  • Enhanced Filtering: Add more sophisticated email filtering based on subject, attachments, or priority.
  • Analytics Dashboard: Connect the Google Sheet to a BI tool for analyzing response quality.
  • Slack Integration: Send notifications to Slack when feedback is received.
  • Batch Processing: Modify to process emails in batches rather than individually.
49 nodesmanual triggerProductivity
Open AIIFSetSticky NoteGmailCryptoHtmlCode

Workflow JSON

{
  "meta": {
    "instanceId": "a2434c94d549548a685cca39cc4614698e94f527bcea84eefa363f1037ae14cd"
  },
  "nodes": [
    {
      "id": "88c0f64c-a7cd-4f35-96dd-9eee4b1d6a1a",
      "name": "Generate reply",
      "type": "n8n-nodes-base.openAi",
      "position": [
        -480,
        2260
      ],
      "parameters": {
        "prompt": "=From: {{ $json.from.value }}\nTo: {{ $json.to.value }}\nSubject: {{ $json.subject }}\nBody: {{ $json.reply }}\n\n\nReply: ",
        "options": {
          "maxTokens": "={{ $('Configure').first().json.replyTokenSize }}"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "27",
          "name": "[UPDATE ME]"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7105b689-9f9c-4354-aad9-8f1abb6c0a06",
      "name": "On email received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -2460,
        2680
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "26",
// ... truncated (copy to see full JSON)

How to Import This Workflow

  1. 1Copy the workflow JSON above using the Copy Workflow JSON button.
  2. 2Open your n8n instance and go to Workflows.
  3. 3Click Import from JSON and paste the copied workflow.

Don't have an n8n instance? Start your free trial at n8nautomation.cloud

Related Templates

Telegram Bot TikTok Video Downloader (No Watermark)

Overview This workflow transforms your Telegram bot into a powerful TikTok video downloader without watermarks. When a user sends a TikTok link to the bot, it automatically validates the URL, fetches the video page, extracts the clean video URL, downloads the file, and sends it back to the user with statistics (views, likes, author). The entire process is handled seamlessly with real-time status updates and robust error handling. This is perfect for content curators, social media managers, or anyone who wants to save TikTok videos without watermarks directly from Telegram. The bot provides a smooth user experience with progress messages and clear error feedback. Workflow Steps Telegram Trigger (No auth) — Listens for incoming messages from Telegram users. Configured to receive only updates. This node requires a Telegram Bot Token set up in n8n credentials. Validate TikTok URL (No auth) — An IF node that checks if the received message contains in the text. Uses string contains operator with loose type validation. Routes valid URLs to the processing path and invalid ones to an error message. Send Invalid URL Message (Telegram API Key auth) — Sends a friendly error message to the user explaining they need to provide a valid TikTok link with examples. Uses the chat ID from the original trigger message. Send Chat Action (Telegram API Key auth) — Sends a "uploading video" chat action to show the user that the bot is processing their request. This provides visual feedback in the Telegram chat. Send Processing Message (Telegram API Key auth) — Sends a status message "⏳ Downloading video... Please wait!" to keep the user informed about the progress. Configure Variables (No auth) — A Set node that stores the video URL (trimmed) and chat ID as named variables for use in subsequent nodes. This ensures data persistence through the workflow. Get TikTok Page HTML (No auth) — An HTTP Request node that fetches the TikTok video page HTML. Uses browser-like headers (User-Agent, Accept, Accept-Language) to mimic a real browser request. Configured with a 30-second timeout and full response capture. On error, it continues to the error handling path. Extract Video URL (No auth) — A Code node running JavaScript that parses the HTML to find the script tag containing video metadata. Extracts the video URL (playAddr or downloadAddr), cookies, description, author, and statistics (plays, likes, comments). On error, it routes to the error handler. Download Video File (No auth) — An HTTP Request node that downloads the actual video file using the extracted URL. Includes cookies from the previous step, proper referrer header, and a 60-second timeout. Configured to return binary file data. On error, it routes to the error handler. Delete Process Notif (Telegram API Key auth) — Deletes the "Processing..." status message to clean up the chat after the video is ready. Uses the message ID from the earlier status message. Send Video to User (Telegram API Key auth) — Sends the downloaded video file to the user with a formatted caption showing the author, view count, and like count. Uses binary data mode for file upload. Format Error (No auth) — A Code node that captures error messages from failed nodes and formats them into a user-friendly error object with the chat ID for response. Send Error Message (Telegram API Key auth) — Sends a detailed error message to the user explaining possible reasons for failure (deleted video, invalid link, maintenance, restrictions) with HTML formatting. Setup Instructions Prerequisites Telegram Bot Token: Create a bot via @BotFather on Telegram and get your API token n8n Instance: Self-hosted or cloud n8n (n8n.io) Configuration Steps Telegram Credentials: In n8n, go to Credentials → New → Telegram API. Enter your bot token from BotFather Webhook Setup: The Telegram Trigger node automatically sets up a webhook URL. Make sure your n8n instance is publicly accessible or use a tunnel (ngrok) Test the Bot: Send any TikTok video link to your bot (e.g., ) Use Cases & Variations Primary Use Case Personal Video Archiving: Save your favorite TikTok videos without watermarks for offline viewing Content Curation: Collect videos for repurposing on other platforms Social Media Management: Download client videos for scheduling tools Possible Adaptations Add Multiple Platforms: Extend the workflow to support Instagram Reels, YouTube Shorts, or Twitter videos by adding additional validation and extraction logic Database Storage: Add a Google Sheets or Airtable node to log downloaded videos with metadata Admin Notifications: Add a second Telegram channel to notify you when someone downloads a video Rate Limiting: Implement user rate limiting using n8n's Wait node or a database Video Processing: Add FFmpeg or other processing nodes to convert formats or add watermarks Multi-language Support: Modify error messages and captions based on user language preferences

23 nodes

YouTube Video Summarizer with Telegram Notification

High-Level Summary This workflow automatically processes YouTube videos by fetching their transcripts, generating a structured AI-powered summary using OpenAI's GPT-4o-mini, and sending the summary along with video metadata to a Telegram chat. It is triggered via a webhook, making it easy to integrate with other tools or services (e.g., a browser extension, a form, or another automation). The workflow is ideal for content curators, researchers, or teams who want to quickly digest video content without watching the full video. Workflow Steps Webhook — Receives an incoming HTTP POST request containing a YouTube URL in the request body. This is the entry point of the workflow. (No auth) Get YouTube URL (Set node) — Extracts the field from the incoming webhook payload and stores it as a string variable for downstream use. (No auth) YouTube Video ID (Code node) — Runs a JavaScript function that parses the YouTube URL using a regex pattern to extract the 11-character video ID (supports both and formats). (No auth) Get YouTube Video (YouTube node) — Uses the extracted video ID to fetch video metadata (title, description, etc.) from the YouTube Data API v3. (OAuth2 — requires a Google Cloud project with YouTube Data API enabled) YouTube Transcript (Community node: ) — Fetches the transcript/captions for the video. This node requires the video ID (passed from the previous step). (No auth — uses public YouTube captions) Split Out (SplitOut node) — Splits the transcript array into individual items so each text segment can be processed separately. (No auth) Concatenate (Summarize node) — Concatenates all transcript text segments into a single string, separated by spaces, to prepare the full transcript for analysis. (No auth) gpt-4o-mini (OpenAI Chat Model node) — Configures the OpenAI language model (GPT-4o-mini) that will be used for summarization. (API Key auth — requires an OpenAI API key) Summarize & Analyze Transcript (LLM Chain node) — Sends the concatenated transcript to the GPT-4o-mini model with a detailed prompt asking for a structured summary with headers, bullet points, bold terms, and tables. The output is a markdown-formatted analysis. (No auth — uses the model configured in the previous node) Response Object (Set node) — Assembles the final output object containing: - : The AI-generated summary text - : An empty array (placeholder for future use) - : The video title from YouTube metadata - : The video description from YouTube metadata - : The YouTube video ID - : The original YouTube URL from the webhook (No auth) Respond to Webhook — Sends the assembled response object back to the original webhook caller (e.g., a browser extension or app). (No auth) Telegram — Sends a message to a specified Telegram chat containing the video title and the YouTube URL. (API Key auth — requires a Telegram Bot Token and chat ID) Setup Instructions To use this workflow, you will need the following accounts and credentials: OpenAI Account: Create an account at platform.openai.com and generate an API key. Add this as a credential in n8n under "OpenAI". Google Cloud Project: Enable the YouTube Data API v3 in your Google Cloud Console, create OAuth 2.0 credentials (Desktop app type), and add them in n8n under "YouTube OAuth2 API". Telegram Bot: Create a bot via @BotFather on Telegram to get a Bot Token. Find your chat ID (e.g., by messaging your bot and visiting ). Add the token as a credential in n8n under "Telegram API". Webhook URL: After activating the workflow, copy the production webhook URL (e.g., ). You will send POST requests to this URL with a JSON body like . Use Cases and Variations Content Curation: Automatically summarize long conference talks, tutorials, or webinars and share them with your team on Telegram. Research Assistant: Collect video transcripts and AI summaries for later reference or database storage. Browser Extension Integration: Pair this workflow with a browser extension that sends the current YouTube URL to the webhook when clicked. Variations: - Replace Telegram with Slack, Discord, or email notifications. - Store summaries in a Google Sheet or Airtable for a searchable archive. - Add a filter to skip videos shorter than a certain duration. - Use a different LLM (e.g., Claude, Gemini) by swapping the OpenAI node. - Add error handling to notify you if a video has no captions.

12 nodes

Telegram to Email Newsletter Automation using Dumpling AI

High-Level Summary This workflow transforms a simple keyword sent via Telegram into a polished, HTML-formatted email newsletter. It leverages Dumpling AI's APIs for search and scraping, OpenAI's language models for content generation, and Gmail for delivery. The automation is ideal for content creators, marketers, or anyone who wants to quickly curate and distribute news on a specific topic without manual research and formatting. Step-by-Step Node Breakdown Start: Receive Keyword from Telegram (Telegram Trigger) — No auth (uses Telegram bot token configured in n8n credentials). Listens for incoming Telegram messages. When a message is received, it passes the message text (the keyword) to the next node. AI Agent: Expand Keyword & Orchestrate Tools (LangChain Agent) — Uses the connected LLM and tools. The system prompt instructs the agent to first call to expand the keyword into popular search terms, then pass those terms to to fetch recent articles. The agent outputs a structured JSON array of articles. LLM: Language Model (OpenAI Chat Model) — API Key auth (OpenAI API key stored in n8n). Provides the language model (GPT-4o-mini) that powers the AI Agent's reasoning and tool selection. Simple Memory (Memory Buffer Window) — Stores conversation context for the AI Agent using the Telegram user's ID as the session key. Google_autocomplete (HTTP Request Tool) — Header Auth (Dumpling AI API key in header). Calls with a POST request containing the keyword. Returns autocomplete suggestions from Google. Search_news (HTTP Request Tool) — Header Auth (Dumpling AI API key in header). Calls with a POST request containing the autocomplete suggestion. Returns recent news articles. Parser: Format News JSON (Output Parser) — Defines a JSON schema that the AI Agent must follow when outputting the final list of articles (with fields: category, title, url, source, summary, published). Split Articles (Split Out) — Splits the array from the agent into individual items, one per article. Loop: Process Each Article (Split In Batches) — Iterates over each article one at a time. For each article, it triggers the Wait node and then the Scraper. Wait (Wait) — No auth. Adds a small delay (configurable) between scraping requests to avoid rate limiting. Scraper: Clean Article Content (HTTP Request) — Header Auth (Dumpling AI API key in header). Calls with the article URL and to get the article's main content in markdown format. Aggregate: Combine Article Content (Aggregate) — Collects the field from all scraped articles into a single array. Generate Newsletter (OpenAI) — API Key auth (OpenAI API key). Sends the aggregated content to GPT-4.1-mini with a system prompt that instructs it to generate a professional HTML newsletter and a subject line. Outputs JSON with (HTML) and fields. Send Newsletter via Email (Gmail) — OAuth2 (Google account connected via n8n Gmail node). Sends the generated HTML newsletter to a specified email address with the generated subject line. Setup Instructions To use this workflow, you will need accounts and API keys for the following services: Telegram: Create a bot via @BotFather and get the bot token. Configure the Telegram Trigger node with this token. Dumpling AI: Sign up at app.dumplingai.com and generate an API key. This key is used as a header () in the three HTTP Request nodes (Googleautocomplete, Searchnews, Scraper). OpenAI: Sign up at platform.openai.com and create an API key. Use this in the LLM node and the Generate Newsletter node. Gmail: Connect your Google account via OAuth2 in n8n's Gmail node. Ensure the email address you want to send to is authorized (or use your own address for testing). After configuring all credentials, activate the workflow and send a keyword (e.g., "AI in retail") to your Telegram bot. The workflow will run and deliver a newsletter to your inbox. Use Cases and Variations Content Curation for Newsletters: Replace the Telegram trigger with a Schedule trigger to run daily or weekly on predefined keywords (e.g., "tech news", "climate change"). Brand Monitoring: Use the workflow to monitor news about your brand or competitors and send alerts to your team via email or Slack. Personalized Digests: Modify the AI prompt to generate summaries in different languages or tones (e.g., executive brief, casual digest). Multi-Channel Delivery: Instead of Gmail, send the newsletter to Slack, Discord, or a Notion database by swapping the final node. Add Human Review: Insert a manual approval step (e.g., n8n's "Wait" node with webhook) before sending, so you can review and edit the newsletter.

16 nodes

Ready to automate with n8n?

Get affordable managed n8n hosting with 24/7 support.