Build a Thai Line Chatbot with Google Sheets Memory using n8n

Frustrated with managing chat histories manually in Line chatbot? This n8n workflow automates conversation memory using Google Sheets, keeping your Thai chatbot responsive and context-aware effortlessly.
webhook
agent
googleSheets
+6
Workflow Identifier: 1992
NODES in Use: Webhook, AI Agent, Google Gemini Chat Model, Edit Fields, HTTP Request, Google Sheets, Set, Code, Sticky Note

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow helps a Thai language Line chatbot remember past conversations using Google Sheets. It solves the problem of the chatbot forgetting earlier chats and giving repeated replies. The chatbot fetches, updates, and stores chat history to create better, polite replies with AI assistance.

The result is a smoother, more personal chat experience that saves hours of manual work for chat managers.


Who should use this workflow

This is for chat managers and small businesses who use Line Official Accounts to talk with customers in Thai. It works well for shops with many daily inquiries needing quick and polite replies.

Users who want to keep dialogue history simple in Google Sheets without complex databases will benefit most.


Tools and services used

  • Line Official API: Receives and sends chat messages.
  • Google Sheets: Stores and retrieves chat history per user.
  • Google Gemini AI (Google Palm API): Generates chatbot replies based on conversation context.
  • n8n Automation Platform: Runs the workflow connecting Line, Sheets, and AI.

How this workflow works (Inputs → Process → Output)

Inputs

  • Incoming Line chat messages including user ID, user message text, and reply token.

Processing Steps

  • Webhook node catches messages from Line.
  • Edit Fields node extracts user ID, reply token, and message text for clean use.
  • Get History Google Sheets node fetches past chat history for that user ID.
  • Prepare Prompt node builds a new text prompt; it joins previous chat history with the new message and instructs the AI to answer politely as a chatbot named “ลลิตา” in Thai language.
  • AI Agent node sends this prompt to Google Gemini AI and gets the AI reply.
  • Split History node uses JavaScript to add latest user and bot messages to history and splits old chat logs into archive parts if too large.
  • Save History Google Sheets node updates the sheet with the new chat history per user.
  • HTTP Request node replies to the Line user through the Line Messaging API with the AI-generated answer.

Outputs

  • Personalized, polite AI replies sent back to the user on Line.
  • Updated chat history stored safely in Google Sheets for next conversations.

Beginner step-by-step: How to use this workflow in n8n

Step 1: Import the workflow

  1. Click the Download button on this page to get the workflow file.
  2. Open the n8n editor where you want to use it.
  3. Choose Import from File option and upload the downloaded file.

Step 2: Configure credentials and variables

  1. Set up your Line channel access token and set it in the HTTP Request node headers.
  2. Connect your Google account with OAuth credentials in the Google Sheets nodes.
  3. Add your Google Palm API key to the AI Agent node credentials.
  4. Check and update your Google Sheets columns names (UserID, History, History_Archive_1-4) match the sheet you use.
  5. Adjust the webhook path in the Webhook node to match your public endpoint URL.

Step 3: Test the workflow

  1. Send a test message from your Line Official Account to the chatbot.
  2. Watch the Webhook node trigger in n8n.
  3. Confirm the AI replies appear properly in Line chat.

Step 4: Activate the workflow

  1. Turn the workflow ON inside n8n to run continuously.
  2. Make sure your n8n webhook URL is public and reachable by Line servers.
  3. If using self-host n8n, confirm server uptime for steady operation.

Customization ideas

  • Edit the system message inside the AI Agent node to change chatbot style or tone.
  • Add more archive columns in Google Sheets and extend the Split History node JavaScript to store longer chats.
  • Change webhook path for using the workflow with other Line accounts.
  • Replace Google Gemini AI model with another AI if needed, by changing the AI Agent node settings.
  • Adapt prompt to support multi-language chats based on user data.

Handling errors and common problems

  • Webhook not triggered: Check webhook URL matches Line developer settings and is public.
  • Empty AI reply or API errors: Confirm Google Palm API keys and prompt format are correct.
  • Google Sheets update fails: Verify UserID values match and appendOrUpdate operation is correct.
  • 401 error from Line API: Renew and use correct Line channel access token in HTTP headers.

Summary of benefits and outcomes

✓ Saves hours by automating chat memory management.
✓ Gives polite, context-aware AI replies in Thai.
✓ Stores conversation history cleanly in Google Sheets.
✓ Works directly with Line Official Accounts and Google AI.
✓ Easy to configure and extend inside n8n.


Frequently Asked Questions

The Webhook node receives incoming chat messages from the Line Official Account and triggers the workflow.
Chat history is stored in Google Sheets and updated per user by the Save History node after adding new exchanges.
The AI Agent node uses the Google Gemini AI (Google Palm API) model to create replies based on the chat context.
Customize the chatbot style by editing the system message parameter in the AI Agent node to change tone or language.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free