Automate Pay Slip Text Extraction with Line & Google Gemini

This workflow automates extracting key pay slip details sent as images via Line chat, using Google Gemini AI for image analysis, and logs results to Google Sheets, saving hours of manual data entry and reducing errors.
lmChatGoogleGemini
httpRequest
googleSheets
+7
Workflow Identifier: 1690
NODES in Use: memoryBufferWindow, stickyNote, httpRequest, set, switch, agent, chainLlm, googleSheets, webhook, lmChatGoogleGemini

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Somchai, an HR manager at a mid-sized company in Bangkok. Every month, he receives dozens of pay slips sent by employees through the company’s Line chat group. These pay slips come as images, making it tedious for Somchai to manually extract key information like payment dates, amounts, sender, and recipient details. It’s an error-prone and time-consuming process that eats up at least 5 hours every pay cycle. This delay impacts payroll processing, causing frustration and inefficiencies.

This is where our unique automation workflow comes into play. It leverages Line messaging, Google Gemini AI, and Google Sheets to fully automate text extraction from pay slip images sent by employees, transforming a manual chore into a smooth, reliable process.

2. What This Automation Does

In simple terms, this workflow listens to Line chat messages from users and does the following:

  • Identifies if the message is text or an image (specifically a pay slip).
  • If it’s text, processes the message conversationally using Google Gemini AI for text understanding.
  • If it’s an image, downloads the pay slip image from Line’s servers.
  • Uses Google Gemini AI’s advanced image analysis to extract key pay slip details like Status, From, To, Date, and Amount in JSON format.
  • Responds back to the user on Line with extracted information or relevant answers for text messages.
  • Appends the extracted pay slip data into a Google Sheet for further payroll automation or record-keeping.

This workflow can save Somchai and his team at least 4-5 hours per pay cycle by completely removing manual extraction, reducing errors and speeding up payroll management.

3. Prerequisites ⚙️

  • Line Messaging API account connected to n8n for receiving user messages and replying.
  • Google Gemini API (Google PaLM) access for AI-based text and image analysis.
  • Google Sheets account connected to n8n for storing extracted pay slip data.
  • n8n automation platform account (Cloud or Self-hosted).
  • HTTP Header Authentication credential for Line API in n8n.

4. Step-by-Step Guide

Step 1: Set up Line Messaging API Webhook in n8n

– Navigate to Triggers → Webhook and create a new webhook node named Line: Messaging API.
– Set the path to a unique identifier (e.g., 4c0de537-2889-47d2-ac44-3a9cda89c9f3) and HTTP method to POST.
– This webhook will listen to incoming Line messages from users.
– Common mistake: Forgetting to configure the exact webhook URL in the Line Developer Console, so test your webhook URL immediately.

Step 2: Set Message Type Node to Extract Incoming Data

– Drag a Set node named Message Type and connect it to the webhook.
– Map these fields from incoming JSON: body.events[0].message.text, body.events[0].message.id, body.events[0].source.userId, and body.events[0].message.type.
– You should see these fields populated on executing the workflow with test messages.

Step 3: Classify Message Type with Switch Node

– Add a Switch node named Message Classification connected to the Message Type node.
– Configure it with rules to detect:
— Text message (value equals text)
— Image message (value equals image)
— Specific sticker (ID = 150, can be ignored in this workflow).
– This helps to route messages differently based on their content.

Step 4: For Text Messages, Use LangChain Conversational Agent

– Add a LangChain node named Text Message Processing set as Conversational Agent.
– Use a dynamic expression to pass user text: =This is the message from User: {{ $json.body.events[0].message.text }}.
– Connect the Window Buffer Memory LangChain memory node to provide chat session history keyed by user ID.
– Connect Google Gemini for Text node as language model to process these messages.

Step 5: For Image Messages, Download Image from Line Server

– Connect the image output branch of the Switch to an HTTP Request node named Line: Get Image.
– Configure URL dynamically: =https://api-data.line.me/v2/bot/message/{{ $json.body.events[0].message.id }}/content.
– Authenticate using HTTP Header Auth with a stored Line API credential.
– This node retrieves the binary image data from Line.

Step 6: Use Google Gemini AI for Image Analysis

– Add a LangChain AI node named Image Message Processing with prompt:
“Analyze image and then return in JSON Response that has the only following Value: Status, From, To, Date, Amount”.
– Connect this node to the previous HTTP image request output.
– Add a Google Gemini for Image node as the language model.
– This triggers advanced AI processing for structured pay slip text extraction.

Step 7: Reply to User Based on Message Type

– For text messages, connect Text Message Processing output to an HTTP Request Line: Text Response to User.
– For image messages, connect Image Message Processing output to HTTP Request Line: Response to User.
– Both HTTP Requests use the Line Messaging API reply endpoint: https://api.line.me/v2/bot/message/reply, with proper authentication.
– The response body contains extracted information or AI-generated conversational text.

Step 8: Append Extracted Pay Slip Data to Google Sheets

– After image processing, connect the output to a Google Sheets node named Text from Slip Result.
– Map the extracted JSON fields Status, From, To, Date, Amount accordingly.
– Append new rows to a designated Google Sheet for payroll tracking.
– Provide your Google Sheets document URL and Sheet name (Sheet1).
– This completes the automation pipeline for data archiving.

5. Customizations ✏️

  • Expand Pay Slip Fields: In the Image Message Processing node prompt, add extra fields like “Employee ID” or “Department” as needed. Also update the Google Sheets mapping accordingly.
  • Multi-Language Support: Adjust the LangChain prompts in Text Message Processing and Image Message Processing nodes to handle multiple languages depending on your employee base.
  • Auto Notify Payroll Team: Add an email node after Google Sheets to notify the payroll team whenever a new pay slip is logged.
  • Direct PDF Processing: Add a file conversion step to convert PDFs to images before feeding them to the AI nodes if employees send PDF payslips.
  • Session Memory Timeout: In Window Buffer Memory, adjust the session timeout or memory window size to control how much chat history is retained for contextual AI conversations.

6. Troubleshooting 🔧

  • Problem: “Could not retrieve image from Line API.”

    Cause: Incorrect URL or invalid access token.

    Solution: Verify HTTP Request URL and ensure your Line developer channel access token is correctly stored in n8n credentials.
  • Problem: “AI processing returns malformed JSON.”

    Cause: AI model output formatting issue or unexpected input.

    Solution: Refine your AI prompt in LangChain nodes to explicitly request JSON format and sanitize AI outputs before further processing.
  • Problem: “User not receiving reply messages.”

    Cause: Incorrect replyToken usage or expired tokens.

    Solution: Make sure the replyToken is correctly passed to the Line Messaging API response nodes within the allowed timeframe.

7. Pre-Production Checklist ✅

  • Test Line webhook with both text and image messages ensuring proper classification.
  • Validate Google Gemini API key has correct permissions for chat and image models.
  • Confirm Google Sheets mapping fields exactly match prompt outputs.
  • Ensure HTTP Header Auth credential for Line API is active and valid.
  • Run end-to-end test: send pay slip image via Line, verify reply and check Google Sheets entry.

8. Deployment Guide

Activate your workflow by toggling the Active switch in n8n. Monitor via the n8n executions panel for any errors. The workflow runs serverless under the hood once active, processing each Line message event automatically. For long-term stability, consider setting up logging or alerting if you expect high volume.

9. FAQs

  • Q: Can I use a different AI model instead of Google Gemini?
    A: Yes, you can replace the LangChain Google Gemini nodes with other AI models like OpenAI GPT, but output formatting and prompt tuning might differ.
  • Q: Does this workflow consume Google API credits?
    A: Yes, using Google Gemini API will consume your API quota depending on usage volume.
  • Q: Is user data stored securely?
    A: Data is processed in real-time and stored only in your Google Sheets; ensure your n8n instance and Google account have proper security controls.
  • Q: Can this handle hundreds of pay slip images daily?
    A: Yes, but scaling depends on your n8n host capacity and Google API limits.

10. Conclusion

By setting up this Line messaging and Google Gemini AI automation, you’ve transformed pay slip data extraction from a frustrating manual task into a seamless, error-resistant process. Somchai and his HR team can now save hours each pay cycle, improve accuracy, and keep organized payroll records automatically updated in Google Sheets.

Next, consider adding automated payroll notifications, integrating PDF pay slip uploads, or expanding AI capabilities to other HR document processing. This workflow showcases how combining powerful AI with messaging platforms like Line and managing data in Google Sheets can revolutionize routine HR tasks.

Happy automating! We believe you’re now well equipped to build and customize this pay slip extraction assistant tailored to your team’s needs.

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 in n8n (Beginner Guide)

A complete beginner guide to building an AI-powered 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