Skip to main content

Route chatbot requests to humans with OpenAI and Google Sheets

Workflow preview

Workflow preview
100%
Route chatbot requests to humans with OpenAI and Google Sheets preview
Open on n8n.io

1. Workflow Overview

Quick Overview This workflow processes incoming chat messages, uses Google Sheets to deduplicate and track escalation status by session, and calls OpenAI to decide whether to answer or escalate to ...

Best for

  • Support Chatbot automation workflows
  • AI Chatbot automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, n8n-nodes-base.set, n8n-nodes-base.stickynote, n8n-nodes-base.googlesheets, n8n-nodes-base.if, n8n-nodes-base.noop, @n8n/n8n-nodes-langchain.agent, @n8n/n8n-nodes-langchain.lmchatopenai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Luis R..

Original n8n.io source

1.1 Workflow description

Title
Route chatbot requests to humans with OpenAI and Google Sheets
Workflow name
Route chatbot requests to humans with OpenAI and Google Sheets

Quick Overview

This workflow processes incoming chat messages, uses Google Sheets to deduplicate and track escalation status by session, and calls OpenAI to decide whether to answer or escalate to a human, muting the bot during active handoffs and re-enabling it after a timeout.

How it works

  1. Runs manually (replace with your chat webhook in production) and maps the incoming message fields like sessionId, messageId, channel, and userMessage.
  2. Checks a Google Sheets “processed_messages” sheet to detect whether the messageId was already handled and stops if it is a duplicate.
  3. Logs the messageId to Google Sheets for idempotency and looks up the session’s escalation status in an “escalations” sheet.
  4. If the escalation status is PENDING and the configured timeout has not expired, the workflow stays silent so a human can continue the conversation.
  5. Otherwise, it sends the user message to an OpenAI-powered agent to either generate a normal reply or return the signal ESCALATE_TO_HUMAN.
  6. If escalation is needed, it upserts a PENDING escalation record in Google Sheets, sets a holding message for the user, and prepares a notification payload for a human agent.
  7. If escalation is not needed, it outputs the AI’s response for you to send back via your messaging provider.

Setup

  1. Add an OpenAI API credential and select the chat model in the OpenAI Chat Model node.
  2. Add a Google Sheets OAuth credential and create a spreadsheet with two sheets named “processed_messages” (messageId, processedAt) and “escalations” (sessionId, userMessage, channel, status, escalatedAt, resolvedAt).
  3. Update the Google Sheets document URL/ID and sheet references to point to your spreadsheet.
  4. Replace the manual trigger and sample input mapping with your real inbound webhook payload (for example from Evolution API, Twilio, or WhatsApp Cloud).
  5. Replace the “Notify Human” placeholder with a real notification action (for example Slack or email) and connect the normal and escalation responses to your messaging provider to reply to the user.
  6. Adjust the workflow config values (escalationTimeoutMinutes and holdingMessage) to match your handoff process.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Execute workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Set — Input Mapping

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 4 - Sheets — Lookup Processed Message

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 5 - If — Already Processed?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 6 - NoOp — Duplicate Ignored

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 7 - Set — Normalize Lookup Result

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 8 - Sheets — Lookup Escalation Status

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 9 - Set — Normalize Escalation Status

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 10 - If — Is Bot Muted?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 11 - NoOp — Human is Handling

Type / Role
n8n-nodes-base.noOp - noOp
Config choices
Version 1

Block 12 - Set — Workflow Config

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 3.1

Block 16 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.3

Block 17 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Simple Memory

Type / Role
@n8n/n8n-nodes-langchain.memoryBufferWindow - memoryBufferWindow
Config choices
Version 1.3

Block 19 - Set — Extract AI Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 20 - If — Needs Escalation?

Type / Role
n8n-nodes-base.if - if
Config choices
Version 2.3

Block 21 - Set — Normal Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 22 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sheets — Upsert Escalation

Type / Role
n8n-nodes-base.googleSheets - googleSheets
Config choices
Version 4.7

Block 24 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Showing the first 24 of 29 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Route chatbot requests to humans with OpenAI and Google Sheets
Complexity advanced
Nodes 29
Categories Support Chatbot, AI Chatbot
Author Luis R.
Published 12 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16315/16315.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Route chatbot requests to humans with OpenAI and Google Sheets do?

Quick Overview This workflow processes incoming chat messages, uses Google Sheets to deduplicate and track escalation status by session, and calls OpenAI to decide whether to answer or escalate to ...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Support Chatbot, AI Chatbot use case.