Deploy a powerful LINE chatbot using this robust n8n workflow. It integrates Google Gemini for advanced conversational intelligence and utilizes Google Sheets for persistent conversation memory management.
Download this n8n workflow template and start using it instantly.
AI Developers: Individuals building custom, stateful chatbots requiring persistent memory across sessions.
E-commerce/Support Teams: Businesses needing an intelligent, custom LINE response system.
n8n Users: Those looking for advanced n8n templates demonstrating complex control flow, API interaction, and Google Sheets manipulation.
Automation Specialists: Experts seeking to deploy reliable, high-volume chatbot solutions using n8n.
Building a truly useful chatbot requires memory, especially on platforms like LINE where context is key. This sophisticated n8n workflow solves the problem of stateless API interactions by using Google Sheets as a low-cost, high-capacity external memory store.
When a message is received via the LINE platform, the n8n trigger instantly pulls the user's past conversation history from Google Sheets. This history is then injected into the prompt provided to the Google Gemini AI Model, allowing the chatbot, named 'ลลิตา', to respond accurately and contextually, even across long periods. After the response is generated, a critical custom JavaScript n8n node manages the history size, archiving older conversation chunks to prevent Google Sheets cell overflow before saving the updated record. This comprehensive approach makes this n8n template exceptionally powerful for conversational AI deployment.
This powerful n8n workflow executes the following steps:
userId, the user's message text, and the essential replyToken needed for the response.userId to look up and retrieve all existing conversation history and archives stored in the spreadsheet.HistoryArchive1 to 4) in Google Sheets to maintain optimal performance and prevent data loss.replyToken, completing the lifecycle of this sophisticated n8n workflow.To import and run this n8n workflow template, follow these steps:
/guitarpa) and configure your LINE Official Account settings to send message events to the full resulting Webhook URL.UserID, History, LastUpdated, and four archive columns (HistoryArchive1, etc.). Establish the Google Sheets OAuth2Api credential in n8n.Authorization header parameter with your LINE Messaging API Access Token (Bearer [YOUR_TOKEN]). Webhook (n8n trigger): The entry point of the n8n workflow. It is configured to listen for POST requests from the LINE service on a specific path (/guitarpa).
Google Sheets (Get History): Functions as the memory retrieval mechanism. It uses the incoming userId as the lookup value to fetch the entire conversation context (History and Archives) for that specific user. Key Configuration: Uses lookupColumn: 'UserID '.
Prepare Prompt (Set n8n node): Essential data manipulation node that compiles the system instructions, all archived history items, and the latest user message into a single, comprehensive string input for the AI.
Google Gemini Chat Model: This powerful n8n node connects to the Gemini API (models/gemini-2.0-flash-001), providing the generative intelligence for the chatbot.
AI Agent: Manages the LLM interaction. It takes the prepared prompt and the configured Gemini model to generate a response. Key Configuration: Uses a defined system message, setting the bot's name ('ลลิตา') and context.
Split History (Code n8n node): This custom JavaScript n8n node manages memory persistence. It checks if the updated history exceeds 35,000 characters and handles the archival process, moving older segments into History_Archive fields before the data is saved.
Google Sheets (Save History): Used for persistence. It updates the user's row in Google Sheets with the newly segmented history and archives, ensuring continuity for the next run of this n8n workflow.
HTTP Request: Sends the final AI response back to the LINE API (https://api.line.me/v2/bot/message/reply) using the crucial replyToken extracted earlier. This is the final action of the n8n workflow.
Create a smart LINE chatbot assistant using n8n workflow templates. Integrate OpenAI tools for scheduling events in Google Calendar and reading Gmail directly via an intelligent n8n agent.

Automate Kubernetes Root Cause Analysis using this advanced n8n workflow. It monitors Prometheus and Loki logs, runs analysis with Gemini AI, and alerts teams via Slack. Get started with this powerful n8n template today.

Use this powerful n8n workflow to translate natural language into secure, read-only kubectl commands for managing Kubernetes clusters, powered by GPT-4o.

Automate Line messages with this robust n8n workflow. Classify images, extract namecard data using GPT-4o (via OpenRouter), save tasks to Microsoft To Do, and notes to Teams.

Use this advanced n8n workflow template to automatically scrape any landing page, analyze it using four specialized Claude AI agents (Design, Copy, SEO, Growth), and instantly deliver a comprehensive, actionable report via Gmail.

Working as a marketer in a bilingual school in Phuket with no coding background. I am a lazy person so I constantly looking for a way to make me work less. Been learning about AI stuff for around 2 years now.







































