Draft and approve Gmail replies with OpenAI, Cognee, Slack, and Google Sheets

Go to Workflow
0 views
Built by Rahul Joshi Rahul Joshi
Created on September 24, 2026

Description

Quick overview
This workflow monitors a Gmail inbox for new messages, uses OpenAI to decide whether a reply is needed, drafts grounded replies with a Cognee knowledge base, saves them as Gmail drafts, and requests human approval in Slack while logging approvals to Google Sheets.

How it works
Triggers every minute when a new email arrives in the Gmail INBOX.
Filters out automated senders (for example no-reply and mailer-daemon addresses) to skip unnecessary processing.
Uses OpenAI (gpt-4o-mini) to classify the email as needing a human reply or not.
For emails that need a reply, uses an OpenAI agent (gpt-4o-mini) with Cognee search to retrieve relevant company context and draft a response.
Creates a Gmail draft reply in the same thread and posts a preview to Slack for approve/reject decision.
Logs the approval status, timestamp, sender, subject, and draft text to Google Sheets.
If any step fails, formats the error details and sends an alert to Slack.

Setup
Connect Gmail OAuth2 credentials and choose the mailbox/label to monitor, then ensure draft creation has access to the same Gmail account.
Add an OpenAI API credential for the classifier and drafting agent, and ensure the gpt-4o-mini model is available to your account.
Add a Cognee API credential and set the Cognee dataset used for search (for example cognee_3rd_workflow_dataset).
Connect Slack credentials and set the target Slack channel ID for approval requests and the channel for error alerts.
Connect Google Sheets OAuth2 credentials, then set the spreadsheet/document ID and sheet name and ensure the sheet has columns for Timestamp, From, Subject, Draft, and Approval Status.

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Slack
n8n-nodes-base.slack
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured