AutomationFlowsAI & RAG › LINE AI Advice Chatbot with Gemini

LINE AI Advice Chatbot with Gemini

Original n8n title: Send Advice From Three AI Personas via Line, Gemini, and Google Sheets

ByRyo Sayama @sayama on n8n.io

Anyone who wants a fun and practical AI chatbot on LINE. Great for people who enjoy getting advice from multiple angles — whether they face work stress, personal dilemmas, or everyday decisions.

Webhook trigger★★★★☆ complexityAI-powered17 nodesChain LlmGoogle Gemini ChatGoogle SheetsHTTP Request
AI & RAG Trigger: Webhook Nodes: 17 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #14308 — we link there as the canonical source.

This workflow follows the Chainllm → Google Sheets recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "o5tdn6I0A2mz6lbZ",
  "name": "Send advice from three AI personas via LINE, Gemini, and Google Sheets",
  "tags": [],
  "nodes": [
    {
      "id": "c4365520-63df-4041-93be-00bea975f4ec",
      "name": "Sticky Note \u2014 Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        16
      ],
      "parameters": {
        "width": 712,
        "height": 600,
        "content": "## Overview\nThis workflow lets users send any worry or question to a LINE bot and instantly receive advice from three distinct AI personas \u2014 a Fortune Teller \ud83d\udd2e, a Business Coach \ud83d\udcbc, and a Best Friend \ud83d\ude0a \u2014 all powered by Google Gemini.\n\nEach conversation is automatically logged to Google Sheets for review and analysis.\n\n### How it works\n1. A user sends a text message to your LINE bot\n2. The message is parsed and passed to Gemini via Basic LLM Chain\n3. Gemini responds as three different personas in a single JSON reply\n4. The advice is saved to Google Sheets\n5. A LINE Flex Message carousel is sent back with each persona in a color-coded card\n\n### Setup steps\n1. Create a LINE Messaging API channel at https://developers.line.biz and copy your Channel Access Token\n2. Get a free Gemini API key at https://aistudio.google.com\n3. Create a Google Sheets spreadsheet with a sheet named `advice_history` \u2014 add these headers in row 1: `Timestamp`, `User ID`, `Message`, `Fortune Teller`, `Business Coach`, `Best Friend`\n4. In the **Set config** node, paste your LINE token, Gemini API key, and Sheet ID\n5. Set your LINE webhook URL to the n8n webhook path\n6. Activate the workflow and test by messaging your LINE bot"
      },
      "typeVersion": 1
    },
    {
      "id": "bcb42662-52bf-46e1-9fa6-6d97409ba4b3",
      "name": "Sticky Note \u2014 Section 1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -240,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 304,
        "height": 220,
        "content": "## 1. Receive & configure\nWebhook receives the LINE event.\nPaste your credentials in **Set config**."
      },
      "typeVersion": 1
    },
    {
      "id": "b9e15dcc-ba9a-4d86-9693-66edd4b57d33",
      "name": "Sticky Note \u2014 Section 2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 220,
        "content": "## 2. Parse & route\nExtracts userId, replyToken, and message text.\nNon-message events (follows, etc.) are skipped immediately."
      },
      "typeVersion": 1
    },
    {
      "id": "107baccf-bce7-4a35-8e6a-f74556388b22",
      "name": "Sticky Note \u2014 Section 3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 220,
        "content": "## 3. Generate advice with Gemini\nBuilds a structured prompt and calls Gemini.\nThe response is parsed into three persona fields."
      },
      "typeVersion": 1
    },
    {
      "id": "50fc75cc-310a-4971-893b-da3d8fadf73e",
      "name": "Sticky Note \u2014 Section 4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1456,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 560,
        "height": 220,
        "content": "## 4. Log & reply\nSaves the conversation to Google Sheets,\nthen sends a Flex Message carousel back to the user."
      },
      "typeVersion": 1
    },
    {
      "id": "f2d60e0b-2288-42f7-9c40-0230d58fca46",
      "name": "Receive LINE message",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -240,
        592
      ],
      "parameters": {
        "path": "line-three-advisors",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "cd98f303-bdba-4513-838f-442853931dfe",
      "name": "Set config",
      "type": "n8n-nodes-base.set",
      "position": [
        -16,
        592
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "field-line-token",
              "name": "LINE_CHANNEL_ACCESS_TOKEN",
              "type": "string",
              "value": "Paste your LINE Channel Access Token here"
            },
            {
              "id": "field-sheet-id",
              "name": "SHEET_ID",
              "type": "string",
              "value": "Paste your Google Sheets ID here"
            },
            {
              "id": "field-history-sheet",
              "name": "HISTORY_SHEET_NAME",
              "type": "string",
              "value": "advice_history"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8a2f923f-bd00-43f6-9f2f-4fb53eb013da",
      "name": "Parse LINE event",
      "type": "n8n-nodes-base.code",
      "position": [
        208,
        592
      ],
      "parameters": {
        "jsCode": "const input = $input.first().json;\n\nlet events = null;\n\nif (input.events && Array.isArray(input.events)) {\n  events = input.events;\n} else if (input.body && input.body.events && Array.isArray(input.body.events)) {\n  events = input.body.events;\n}\n\nif (!events || events.length === 0) {\n  return [{ json: { skip: true, userId: '', replyToken: '', messageText: '', eventType: '' } }];\n}\n\nconst event = events[0];\nconst userId = event.source?.userId || '';\nconst replyToken = event.replyToken || '';\nconst messageText = event.message?.text || '';\nconst eventType = event.type || '';\n\nif (eventType !== 'message' || event.message?.type !== 'text') {\n  return [{ json: { skip: true, userId, replyToken, messageText: '', eventType } }];\n}\n\nreturn [{\n  json: {\n    skip: false,\n    userId,\n    replyToken,\n    messageText,\n    eventType\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "52c9a62d-b608-4b2c-b2d2-408e758304ba",
      "name": "Skip if no text event",
      "type": "n8n-nodes-base.if",
      "position": [
        432,
        592
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "cond-skip",
              "operator": {
                "type": "boolean",
                "operation": "true"
              },
              "leftValue": "={{ $json.skip }}",
              "rightValue": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ea83a492-fd1b-4ab3-bfa4-c338ff3e5751",
      "name": "Respond OK (skip)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        640,
        448
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "OK"
      },
      "typeVersion": 1
    },
    {
      "id": "7b773bfd-eb46-4e81-b639-275e8dae6f98",
      "name": "Build context",
      "type": "n8n-nodes-base.code",
      "position": [
        640,
        704
      ],
      "parameters": {
        "jsCode": "const lineEvent = $('Parse LINE event').first().json;\nconst config = $('Set config').first().json;\n\nreturn [{\n  json: {\n    userId: lineEvent.userId,\n    replyToken: lineEvent.replyToken,\n    messageText: lineEvent.messageText,\n    SHEET_ID: config.SHEET_ID,\n    HISTORY_SHEET_NAME: config.HISTORY_SHEET_NAME,\n    LINE_CHANNEL_ACCESS_TOKEN: config.LINE_CHANNEL_ACCESS_TOKEN\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "c511cf07-85fd-494a-a300-6369c1c5b4f4",
      "name": "Generate advice with Gemini",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        864,
        704
      ],
      "parameters": {
        "text": "=You are three distinct advisors. Reply to the user's concern below as all three personas.\n\nUser's message: {{ $json.messageText }}\n\nRespond ONLY in this exact JSON format with no other text:\n{\n  \"fortune_teller\": \"advice from the Fortune Teller here\",\n  \"business_coach\": \"advice from the Business Coach here\",\n  \"best_friend\": \"advice from the Best Friend here\"\n}\n\nPersona guidelines:\n[Fortune Teller \ud83d\udd2e] Mystical and warm. Reference stars, fate, and intuition. Slightly formal, old-fashioned tone. 3-4 sentences.\n[Business Coach \ud83d\udcbc] Logical and action-oriented. Give specific next steps. Direct and motivating tone. 3-4 sentences.\n[Best Friend \ud83d\ude0a] Casual and empathetic. Use phrases like \"I totally get it!\". Encouraging with a touch of humor. 3-4 sentences.",
        "batching": {},
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "94c799f4-6d24-4a13-ae37-af0959283e51",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        800,
        912
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "04099137-d571-4624-ba19-0102b7b5e65f",
      "name": "Parse Gemini response",
      "type": "n8n-nodes-base.code",
      "position": [
        1456,
        704
      ],
      "parameters": {
        "jsCode": "const rawText = $input.first().json.text || '';\nconst prevData = $('Build context').first().json;\n\nconst jsonMatch = rawText.match(/\\{[\\s\\S]*\\}/);\nlet advice = {\n  fortune_teller: 'No message received from the Fortune Teller.',\n  business_coach: 'No message received from the Business Coach.',\n  best_friend: 'No message received from the Best Friend.'\n};\n\nif (jsonMatch) {\n  try {\n    advice = JSON.parse(jsonMatch[0]);\n  } catch(e) {\n    // use defaults on parse failure\n  }\n}\n\nreturn [{\n  json: {\n    userId: prevData.userId,\n    replyToken: prevData.replyToken,\n    messageText: prevData.messageText,\n    fortune_teller: advice.fortune_teller || 'No message received from the Fortune Teller.',\n    business_coach: advice.business_coach || 'No message received from the Business Coach.',\n    best_friend: advice.best_friend || 'No message received from the Best Friend.',\n    SHEET_ID: prevData.SHEET_ID,\n    HISTORY_SHEET_NAME: prevData.HISTORY_SHEET_NAME,\n    LINE_CHANNEL_ACCESS_TOKEN: prevData.LINE_CHANNEL_ACCESS_TOKEN\n  }\n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "65db7340-2e0b-4c83-be13-4e29fa1bc74c",
      "name": "Save advice to Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1680,
        704
      ],
      "parameters": {
        "columns": {
          "value": {
            "Message": "={{ $json.messageText }}",
            "User ID": "={{ $json.userId }}",
            "Timestamp": "={{ $now.toISO() }}",
            "Best Friend": "={{ $json.best_friend }}",
            "Business Coach": "={{ $json.business_coach }}",
            "Fortune Teller": "={{ $json.fortune_teller }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "User ID",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "User ID",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "Message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Message",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "Fortune Teller",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Fortune Teller",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "Business Coach",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Business Coach",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            },
            {
              "id": "Best Friend",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Best Friend",
              "defaultMatch": false,
              "canBeUsedToMatch": false
            }
          ],
          "mappingMode": "defineBelow"
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "={{ $json.HISTORY_SHEET_NAME }}"
        },
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.SHEET_ID }}"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "a89695d2-32a0-4312-b5b7-c3360b1c50c6",
      "name": "Send Flex Message to LINE",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1904,
        704
      ],
      "parameters": {
        "url": "https://api.line.me/v2/bot/message/reply",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"replyToken\": \"{{ $json.replyToken }}\",\n  \"messages\": [\n    {\n      \"type\": \"flex\",\n      \"altText\": \"Advice from your three advisors!\",\n      \"contents\": {\n        \"type\": \"carousel\",\n        \"contents\": [\n          {\n            \"type\": \"bubble\",\n            \"size\": \"kilo\",\n            \"header\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"\ud83d\udd2e Fortune Teller\",\n                  \"weight\": \"bold\",\n                  \"size\": \"md\",\n                  \"color\": \"#ffffff\"\n                }\n              ],\n              \"backgroundColor\": \"#6a0dad\",\n              \"paddingAll\": \"12px\"\n            },\n            \"body\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"{{ $json.fortune_teller }}\",\n                  \"wrap\": true,\n                  \"size\": \"sm\",\n                  \"color\": \"#333333\"\n                }\n              ],\n              \"paddingAll\": \"14px\"\n            }\n          },\n          {\n            \"type\": \"bubble\",\n            \"size\": \"kilo\",\n            \"header\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"\ud83d\udcbc Business Coach\",\n                  \"weight\": \"bold\",\n                  \"size\": \"md\",\n                  \"color\": \"#ffffff\"\n                }\n              ],\n              \"backgroundColor\": \"#1a73e8\",\n              \"paddingAll\": \"12px\"\n            },\n            \"body\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"{{ $json.business_coach }}\",\n                  \"wrap\": true,\n                  \"size\": \"sm\",\n                  \"color\": \"#333333\"\n                }\n              ],\n              \"paddingAll\": \"14px\"\n            }\n          },\n          {\n            \"type\": \"bubble\",\n            \"size\": \"kilo\",\n            \"header\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"\ud83d\ude0a Best Friend\",\n                  \"weight\": \"bold\",\n                  \"size\": \"md\",\n                  \"color\": \"#ffffff\"\n                }\n              ],\n              \"backgroundColor\": \"#34a853\",\n              \"paddingAll\": \"12px\"\n            },\n            \"body\": {\n              \"type\": \"box\",\n              \"layout\": \"vertical\",\n              \"contents\": [\n                {\n                  \"type\": \"text\",\n                  \"text\": \"{{ $json.best_friend }}\",\n                  \"wrap\": true,\n                  \"size\": \"sm\",\n                  \"color\": \"#333333\"\n                }\n              ],\n              \"paddingAll\": \"14px\"\n            }\n          }\n        ]\n      }\n    }\n  ]\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $json.LINE_CHANNEL_ACCESS_TOKEN }}"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e3db4e90-555a-4178-b132-38a41242c3a4",
      "name": "Respond OK",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2128,
        704
      ],
      "parameters": {
        "options": {},
        "respondWith": "text",
        "responseBody": "OK"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "b39e6181-056e-413c-9a50-28eb65eb3b36",
  "connections": {
    "Set config": {
      "main": [
        [
          {
            "node": "Parse LINE event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build context": {
      "main": [
        [
          {
            "node": "Generate advice with Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse LINE event": {
      "main": [
        [
          {
            "node": "Skip if no text event",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Receive LINE message": {
      "main": [
        [
          {
            "node": "Set config",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Gemini response": {
      "main": [
        [
          {
            "node": "Save advice to Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save advice to Sheets": {
      "main": [
        [
          {
            "node": "Send Flex Message to LINE",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Skip if no text event": {
      "main": [
        [
          {
            "node": "Respond OK (skip)",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Build context",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Generate advice with Gemini",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Flex Message to LINE": {
      "main": [
        [
          {
            "node": "Respond OK",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate advice with Gemini": {
      "main": [
        [
          {
            "node": "Parse Gemini response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Anyone who wants a fun and practical AI chatbot on LINE. Great for people who enjoy getting advice from multiple angles — whether they face work stress, personal dilemmas, or everyday decisions.

Source: https://n8n.io/workflows/14308/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

ANIS_HUB 1. Uses gmail, googleDrive, googleSheets, httpRequest. Webhook trigger; 89 nodes.

Gmail, Google Drive, Google Sheets +3
AI & RAG

Resume Screening & Behavioral Interviews with Gemini, Elevenlabs, & Notion ATS copy. Uses outputParserStructured, chainLlm, googleDrive, stickyNote. Webhook trigger; 67 nodes.

Output Parser Structured, Chain Llm, Google Drive +9
AI & RAG

Candidate Engagement | Resume Screening | AI Voice Interviews | Applicant Insights

Output Parser Structured, Chain Llm, Google Drive +9
AI & RAG

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13
AI & RAG

Categories: Accounting Automation • OCR Processing • AI Data Extraction • Business Tools

HTTP Request, OpenRouter Chat, Google Gemini Chat +4