workflows.fit
Back to n8n workflows
n8n templateFreeBy Jakkrapat Ampring

Line chatbot with Google Sheets memory and Gemini AI

Main Use Case This workflow enables automated, AI-assisted replies to users messaging a LINE Official Account, while storing and referencing chat history from Google Sheets to maintain context. Ideal for businesses or...

Data & StorageProductivityDevelopmentCore NodesAILangchainWebhookAgent
Loading interactive preview...

Template notes

Main Use Case This workflow enables automated, AI-assisted replies to users messaging a LINE Official Account, while storing and referencing chat history from Google Sheets to maintain context. Ideal for businesses or support teams that want to provide smart, personalized customer interactions using AI with memory.

How It Works (Step-by-Step) 1. Connect to LINE Official Account's API A Webhook listens for incoming messages from users on LINE. When a message is received, it triggers the workflow.

2. Prepare the Data An Edit Fields module structures incoming data (e.g. extracts user ID, message content). This ensures data is clean and usable downstream.

3. Retrieve Chat History The user’s previous conversations are fetched from a Google Sheet. This ensures the AI has memory and can continue conversations contextually.

4. Prepare Prompt The retrieved chat history is combined with the new message to form a complete prompt for the AI. Example format: “User previously said X. Now they said Y. How should we respond?”

5. AI Agent: Google Gemini The formatted prompt is passed to an AI Agent (Google Gemini Chat Model). The AI generates a response based on the message + history. Tools used: Chat ModeMemory, ToolOutputParser for accurate replies.

6. Split & Clean History The conversation history is split into smaller chunks for cleaning and storage. This ensures the Google Sheet remains readable and manageable over time.

7. Save Chat History The cleaned new message and AI reply are saved to Google Sheets. This updates the chat history for future context.