Log clinic chatbot inquiries from a website widget with OpenAI and Google Sheets

Go to Workflow
0 views
Built by Vonn Vonn
Created on August 04, 2026

Description

Quick overview
This workflow receives website chatbot messages via a webhook, uses OpenAI to generate an AI receptionist reply with session-based context, extracts structured inquiry details, and appends or updates a single visitor row in Google Sheets before returning a clean JSON reply to the widget.

How it works
Receives a POST request from the website chat widget containing the visitor message, sessionId, and timestamp.
Uses an OpenAI-powered receptionist agent with per-session memory to generate a contextual reply and a hidden JSON block of extracted inquiry details.
Strips the hidden data block from the reply, parses the JSON into fields (name, contact, intent, appointment details, summary, status), and flags whether any meaningful data was captured.
If collectible data exists, appends or updates a Google Sheets row matched on Session ID with the latest extracted details and a Last Updated timestamp.
Returns the cleaned reply to the chat widget as a JSON response with CORS headers.

Setup
Add an OpenAI API credential for the OpenAI chat model used by the receptionist agent.
Add a Google Sheets OAuth2 credential and set the target spreadsheet document ID and sheet/tab name used for logging.
Create the Google Sheet with column headers that match the mapped fields (for example: Session ID, Last Updated, Name, Contact, Intent, Service Interested, Appointment Date/Time, Doctor Preference, Reason for Visit, Conversation Summary, Status).
Activate the workflow, copy the webhook URL for the chat endpoint, and configure your website widget to POST messages to it (including message and sessionId).

Nodes Used (5)

AI Agent
@n8n/n8n-nodes-langchain.agent
Code
n8n-nodes-base.code
Google Sheets
n8n-nodes-base.googleSheets
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow