AutomationFlowsAI & RAG › Update Sales CRM and Tasks From Gmail with Google Gemini and Google Sheets

Update Sales CRM and Tasks From Gmail with Google Gemini and Google Sheets

ByOka Hironobu @okp29 on n8n.io

This workflow monitors unread Gmail messages labeled “sales”, uses Google Gemini to extract structured deal updates and a suggested reply, writes the deal and next action to Google Sheets, drafts a follow-up email in the original thread, and posts Slack alerts for high-risk or…

Event trigger★★★★☆ complexityAI-powered16 nodesGmail TriggerChain LlmGoogle Gemini ChatOutput Parser StructuredGoogle SheetsGmailSlack
AI & RAG Trigger: Event Nodes: 16 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #18065 — we link there as the canonical source.

This workflow follows the Chainllm → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "M6fAvs6tknDULQm9",
  "meta": {
    "builderVariant": "mcp",
    "aiBuilderAssisted": true
  },
  "name": "Turn client emails into CRM updates and next actions with Gemini",
  "tags": [],
  "nodes": [
    {
      "id": "91fac9e7-3361-44f5-bd7b-4c5ccb707e3d",
      "name": "Watch Sales Inbox",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        48,
        48
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "q": "label:sales",
          "readStatus": "unread"
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.4
    },
    {
      "id": "c28b81f4-853c-4546-b531-4f87dcc48107",
      "name": "Extract Deal Update with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "onError": "continueRegularOutput",
      "position": [
        304,
        48
      ],
      "parameters": {
        "text": "=You are a sales operations analyst. Read this client email and extract a CRM update as JSON. Infer the company and contact from the sender. stage must be one of: qualification, proposal, negotiation, closed_won, closed_lost. sentiment: positive, neutral or negative. risk: low, medium or high - high when the client mentions competitors, budget cuts, delays or dissatisfaction. next_action must be a concrete task, owner is \"us\" or \"client\", and due_date in YYYY-MM-DD if a deadline is mentioned (resolve relative dates like Friday). Also draft a short reply. Never invent commitments that are not in the email.\n\nFrom: {{ $json.from }}\nSubject: {{ $json.subject }}\nEmail:\n{{ $json.text }}",
        "batching": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "d3774a33-87b1-4e35-b7d1-651f71f759ac",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        272,
        208
      ],
      "parameters": {
        "options": {
          "temperature": 0.1
        },
        "modelName": "models/gemini-3.1-flash-lite"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "e75a111b-fb10-4a7b-bb85-6f028cbeca1e",
      "name": "Deal Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        496,
        208
      ],
      "parameters": {
        "jsonSchemaExample": "{\"company\":\"Acme Ltd\",\"contact_name\":\"Jane\",\"stage\":\"negotiation\",\"sentiment\":\"neutral\",\"summary\":\"Client likes the proposal but pushes back on price\",\"objections\":[\"Price is too high\"],\"next_action\":\"Send a revised quote\",\"owner\":\"us\",\"due_date\":\"2026-07-24\",\"risk\":\"medium\",\"suggested_reply\":\"Hi Jane, thanks for the quick feedback...\"}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "fe7fc5ee-06a6-4897-85ac-a39184533845",
      "name": "Shape Deal Update",
      "type": "n8n-nodes-base.code",
      "position": [
        688,
        48
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const e = $('Watch Sales Inbox').item.json;\nconst d = $json.output || {};\nconst join = function (x) { return Array.isArray(x) ? x.join('; ') : (x || ''); };\nreturn {\n  clientEmail: e.from || '',\n  threadId: e.threadId || '',\n  subject: e.subject || '',\n  company: d.company || e.from || '',\n  contactName: d.contact_name || '',\n  stage: String(d.stage || 'qualification').toLowerCase(),\n  sentiment: String(d.sentiment || 'neutral').toLowerCase(),\n  risk: String(d.risk || 'low').toLowerCase(),\n  summary: d.summary || '',\n  objections: join(d.objections),\n  nextAction: d.next_action || 'Review the email',\n  owner: d.owner || 'us',\n  dueDate: d.due_date || '',\n  suggestedReply: d.suggested_reply || ''\n};"
      },
      "typeVersion": 2
    },
    {
      "id": "4ce8e7d0-2647-4d2d-8fa1-934dee972da4",
      "name": "Update CRM Row",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        896,
        48
      ],
      "parameters": {
        "operation": "appendOrUpdate",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Deals"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Select your spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "62da0a83-a070-4cbf-a52c-c2b859694107",
      "name": "Log Next Action",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1104,
        48
      ],
      "parameters": {
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Tasks"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "Select your spreadsheet"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "81f7f105-e6b3-41e8-b3a3-f9f361560905",
      "name": "Draft Follow-up Reply",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1296,
        48
      ],
      "parameters": {
        "message": "={{ $(\"Shape Deal Update\").item.json.suggestedReply }}",
        "options": {
          "sendTo": "={{ $(\"Shape Deal Update\").item.json.clientEmail }}",
          "threadId": "={{ $(\"Shape Deal Update\").item.json.threadId }}"
        },
        "subject": "={{ \"Re: \" + $(\"Shape Deal Update\").item.json.subject }}",
        "resource": "draft"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "93ac088d-22f1-4c4c-8c99-660866006bf6",
      "name": "Route by Deal Risk",
      "type": "n8n-nodes-base.switch",
      "position": [
        1552,
        32
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $(\"Shape Deal Update\").item.json.risk }}",
                    "rightValue": "high"
                  }
                ]
              }
            },
            {
              "conditions": {
                "options": {
                  "version": 1,
                  "leftValue": "",
                  "caseSensitive": false,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $(\"Shape Deal Update\").item.json.stage }}",
                    "rightValue": "closed_won"
                  }
                ]
              }
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "Normal"
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "5b284e3e-cbc5-4ba5-8297-5a7b684b11c9",
      "name": "Alert Deal at Risk",
      "type": "n8n-nodes-base.slack",
      "position": [
        1824,
        16
      ],
      "parameters": {
        "text": "=*:warning: Deal at risk: {{ $(\"Shape Deal Update\").item.json.company }}*\n*Stage:* {{ $(\"Shape Deal Update\").item.json.stage }} | *Sentiment:* {{ $(\"Shape Deal Update\").item.json.sentiment }}\n*Objections:* {{ $(\"Shape Deal Update\").item.json.objections }}\n*Next action:* {{ $(\"Shape Deal Update\").item.json.nextAction }} (owner: {{ $(\"Shape Deal Update\").item.json.owner }})\nA draft reply is ready in Gmail.",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "#sales"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "b997c8d4-a6ca-4e80-8e6a-a6f97d886263",
      "name": "Announce Closed Won",
      "type": "n8n-nodes-base.slack",
      "position": [
        1824,
        208
      ],
      "parameters": {
        "text": "=*:tada: Deal won: {{ $(\"Shape Deal Update\").item.json.company }}*\n{{ $(\"Shape Deal Update\").item.json.summary }}",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "list",
          "value": "",
          "cachedResultName": "#sales"
        },
        "otherOptions": {},
        "authentication": "oAuth2"
      },
      "credentials": {
        "slackOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.5
    },
    {
      "id": "d4a674f3-eb13-45ff-b9dd-2e2896088744",
      "name": "Mark Email Processed",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1824,
        384
      ],
      "parameters": {
        "messageId": "={{ $(\"Watch Sales Inbox\").item.json.id }}",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "19668b9e-8b7e-4f95-a929-ac60a4314826",
      "name": "Overview Sticky",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -464,
        -112
      ],
      "parameters": {
        "width": 440,
        "height": 820,
        "content": "## Turn client emails into CRM updates and next actions with Gemini\n\n### How it works\nSales reps update the CRM last, if at all, so pipeline data is always stale. This template does it from the emails themselves. Every new message in your sales inbox is read by a Basic LLM Chain with Google Gemini, which extracts the company, contact, deal stage, sentiment, the objections raised, a concrete next action with an owner and due date, a risk rating, and a suggested reply - without inventing commitments the client never made. The CRM row is upserted by client email so each company keeps one live record, the next action is logged as a task, and a draft reply is prepared in the original Gmail thread. A Switch then alerts the sales channel when a deal is flagged at risk and celebrates closed-won deals, and every processed email is marked read.\n\n### Setup\n1. Connect Gmail, Google Gemini (PaLM) API, Google Sheets and Slack.\n2. Label your sales emails and point the sheets at your Deals and Tasks tabs.\n3. Pick the Slack channel for alerts.\n\n### Customization tips\nSwap Sheets for HubSpot or Pipedrive, or auto-send low-risk replies."
      },
      "typeVersion": 1
    },
    {
      "id": "eff3b280-fd2c-4a25-933c-e45d80b88c3a",
      "name": "S1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 620,
        "height": 652,
        "content": "## 1. Read the email (Basic LLM Chain)\nGemini extracts stage, sentiment, objections, next action, owner, due date, risk and a draft reply."
      },
      "typeVersion": 1
    },
    {
      "id": "0d92b4e0-f49e-4372-9905-a28c3224a628",
      "name": "S2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 800,
        "height": 652,
        "content": "## 2. Update the CRM & prepare the follow-up\nUpsert the deal row by client email, log the next action as a task, and draft the reply in the original thread."
      },
      "typeVersion": 1
    },
    {
      "id": "20809d64-8b8f-41d3-b3fa-ee17c0293625",
      "name": "S3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        -112
      ],
      "parameters": {
        "color": 7,
        "width": 660,
        "height": 652,
        "content": "## 3. Escalate & close the loop\nAt-risk deals alert sales, closed-won deals are celebrated, and every email is marked processed."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "availableInMCP": true,
    "executionOrder": "v1"
  },
  "versionId": "8012883c-635a-4c79-a36a-68a99603b10a",
  "nodeGroups": [],
  "connections": {
    "Deal Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Extract Deal Update with Gemini",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Update CRM Row": {
      "main": [
        [
          {
            "node": "Log Next Action",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log Next Action": {
      "main": [
        [
          {
            "node": "Draft Follow-up Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Shape Deal Update": {
      "main": [
        [
          {
            "node": "Update CRM Row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Watch Sales Inbox": {
      "main": [
        [
          {
            "node": "Extract Deal Update with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Deal Risk": {
      "main": [
        [
          {
            "node": "Alert Deal at Risk",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Announce Closed Won",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Mark Email Processed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft Follow-up Reply": {
      "main": [
        [
          {
            "node": "Route by Deal Risk",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Extract Deal Update with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Extract Deal Update with Gemini": {
      "main": [
        [
          {
            "node": "Shape Deal Update",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow monitors unread Gmail messages labeled “sales”, uses Google Gemini to extract structured deal updates and a suggested reply, writes the deal and next action to Google Sheets, drafts a follow-up email in the original thread, and posts Slack alerts for high-risk or…

Source: https://n8n.io/workflows/18065/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This workflow runs daily to send Gemini-generated cold emails from leads stored in Google Sheets via Gmail, schedules two follow-ups based on time since sending, and continuously monitors Gmail for re

Gmail Trigger, Google Sheets, Slack +3
AI & RAG

Automate your lead intake, scoring, and outreach pipeline. This workflow collects leads from forms, enriches and scores them using Relevance AI, routes them by quality, and triggers the right follow-u

Form Trigger, HTTP Request, Chain Llm +6
AI & RAG

This workflow creates a sophisticated, self-improving customer support system that automatically handles incoming emails. It's designed to answer common questions using an AI-powered knowledge base an

Text Classifier, Chain Llm, Gmail Trigger +4
AI & RAG

Perfect for use cases such as: 💼 Finance teams managing vendor invoices 📊 Bookkeeping workflows 🔄 Automating monthly reconciliation

Output Parser Structured, HTTP Request, Gmail Trigger +4
AI & RAG

This workflow monitors Gmail for unread invoice emails with PDF attachments, extracts invoice details with Google Gemini, verifies Japanese qualified invoice registration numbers against the National

Gmail Trigger, Chain Llm, Google Gemini Chat +5