Run a 24/7 website chatbot with OpenAI, Google Sheets, and Gmail

Go to Workflow
0 views
Built by Tanjimul Islam Tanjimul Islam
Created on October 21, 2026

Description

Quick Overview
This workflow powers an @n8n/chat website widget that answers visitor questions using an n8n Data Table knowledge base via OpenAI, keeps per-session memory, captures leads to Google Sheets only with consent, emails you via Gmail, and logs unanswered questions for follow-up.

How it works
Receives a new message from the @n8n/chat widget trigger.
Cleans and validates the visitor input, returning a prompt if the message is empty.
Uses an OpenAI-powered agent with session memory to search the n8n Data Table knowledge_base and generate a structured, grounded reply.
If the visitor has explicitly consented and provided a name and valid email, appends the lead details to a Google Sheets “Leads” tab and sends a Gmail notification.
If the answer is supported, returns the agent’s reply to the chat widget.
If the answer is not supported, logs the question and missing information to the n8n Data Table unanswered_questions and returns a fallback response offering human follow-up.

Setup
Add OpenAI credentials (or n8n AI Gateway) for the chat model used by the agent.
Create n8n Data Tables named knowledge_base and unanswered_questions and ensure they contain the expected string columns (topic/details/last_verified_date and session_id/question/missing_info/asked_at).
Connect Google Sheets OAuth credentials, set the target spreadsheet in the Google Sheets node, and create a “Leads” sheet with the mapped columns.
Connect Gmail OAuth credentials and replace the placeholder recipient email address in the Gmail node.
Configure the Chat Widget Trigger allowed origins and publish the workflow, then embed the @n8n/chat widget on your site using the production chat URL.

This workflow was created by Tanjimul Islam and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.

Nodes Used (6)

AI Agent
@n8n/n8n-nodes-langchain.agent
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow
Structured Output Parser
@n8n/n8n-nodes-langchain.outputParserStructured