n8n

How to Automate LINE Support with Gemini and Sheets?

Give fast, context aware replies on LINE without extra staff. Incoming messages go to an AI that understands Thai, uses past chat history from Google Sheets, and sends a clean reply back to the user. Great for first line customer support and FAQ handling on a LINE Official Account.

Here is how it works. LINE sends a POST request to an n8n webhook. The flow extracts the user message, user ID, and reply token. It then looks up the user’s past chat history in Google Sheets. A prompt is built that includes the history and the new message with a friendly Thai assistant persona. Google Gemini creates the reply. The history is cleaned and split, then updated in Google Sheets with a timestamp. The reply is posted back to the LINE Messaging API using the reply token.

You will need a LINE channel access token, a Google Sheets file with the required columns, and a Google Gemini API key. Expect faster replies, fewer manual tasks, and consistent tone. Use this setup for 24x7 FAQs, simple pre sales questions, and routing to human agents when needed. Start small, then expand the sheet structure as volume grows.

What are the key features?

  • Webhook receives LINE events and captures message text, reply token, and user ID
  • Field mapping extracts values from the incoming payload for easy reuse
  • Google Sheets lookup fetches past chat history by UserID to add context
  • Prompt builder composes a Thai assistant persona with conversation history and the new message
  • AI Agent uses Google Gemini to generate a clear, helpful reply with an output parser
  • Code step splits and cleans history so saved data stays small and readable
  • Google Sheets update appends or updates the user’s row with history and timestamp
  • HTTP Request posts the AI reply back to the LINE Messaging API using the reply token

What are the benefits?

  • Reduce manual replies by up to 70% for common questions
  • Cut response time from minutes to seconds with instant AI replies
  • Handle up to 5 times more concurrent chats without extra staff
  • Improve answer consistency across agents with one controlled prompt
  • Connect LINE, Google Gemini, and Google Sheets in one flow
  • Keep a simple audit trail of each chat inside Google Sheets

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with LINE Messaging API, Google Sheets and Google Gemini. See the Tools Required section above for links to create accounts with these services.
  3. In LINE Developers Console, create or open your LINE Official Account channel. Generate a Channel access token and enable webhooks.
  4. In n8n, open the Webhook node and copy the Production URL. In LINE Developers Console, paste this URL into the Webhook URL field and verify it.
  5. Open the HTTP Request node. In Headers, set Authorization to Bearer YOUR_CHANNEL_ACCESS_TOKEN and Content-Type to application/json. Replace any placeholder token with your real token.
  6. Create a Google Sheet named Sheet1 with columns exactly named: UserID (with a trailing space if present in your template), History, LastUpdated.
  7. Open the Get History node. In the credentials dropdown, click Create new credential for Google Sheets, then follow the on screen steps to connect. Confirm the Document ID and Sheet1 selection.
  8. Open the Save History node. Use the same Google Sheets credential. Confirm the columns map to History, UserID and LastUpdated, and the operation is append or update.
  9. Open the Google Gemini Chat Model node. Create new credential for Google Gemini or Google Palm API. In Google AI Studio, create an API key and paste it into n8n.
  10. Review the Prepare Prompt node. Adjust the Thai instructions and any brand tone if needed. Keep the variables for history and user message.
  11. Click Execute workflow. Send a test message to your LINE Official Account. Check that a reply is sent within seconds.
  12. Open the Google Sheet to confirm a row was created or updated with the correct UserID, history text, and timestamp.
  13. If LINE shows an error or no reply: verify the webhook URL is reachable, confirm the bearer token is valid, and check n8n execution logs for any 401 or 403 responses.
  14. If Google Sheets fails to read or write: ensure the connected Google account has access to the sheet and that column names match exactly.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Gemini

Sign up

Free tier: $0 via Gemini API; e.g., Gemini 2.5 Flash-Lite free limits 1,000 requests/day (15 RPM, 250k TPM). Paid from $0.10/1M input tokens and $0.40/1M output tokens.

Google Sheets

Sign up

Free: $0 (Google Sheets API usage has no additional cost; quota limits apply)

LINE Messaging API

Sign up

Free plan (Communication): $0 / mo, 500 messages / mo (USA/Other regions)

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.