Automate LINE Chatbot with Google Calendar & Gmail via n8n

Struggling with managing schedule requests and email checks on LINE? This n8n workflow integrates LINE chatbot with Google Calendar and Gmail to automate event management and email retrieval, saving you hours and reducing errors.
agent
googleCalendarTool
gmailTool
+7
Workflow Identifier: 1981
NODES in Use: agent, memoryBufferWindow, lmChatOpenAi, toolWikipedia, switch, webhook, set, httpRequest, googleCalendarTool, gmailTool

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

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What This Automation Does

This workflow listens for text messages sent to a LINE chatbot.
It uses an AI agent with OpenAI and LangChain to understand user requests.
It reads and makes events on Google Calendar based on user words.
It fetches emails from Gmail by date if asked.
After processing, it sends back easy-to-read answers on LINE.
If message type is not text or AI fails, it replies with an error message.
This saves time on checking calendar and emails by doing it inside LINE chat.


Tools and Services Used

  • LINE Messaging API: Receives user messages and sends replies.
  • n8n Workflow Automation: Manages the API calls and data flow.
  • OpenAI Chat Model: Powers the natural language understanding.
  • LangChain AI Agent: Handles conversation memory and tool integration.
  • Google Calendar API: Reads and creates calendar events.
  • Gmail API: Reads emails filtered by specified criteria.
  • Wikipedia Tool: Provides background information if requested.

Inputs, Processing Steps, and Outputs

Inputs

  • Incoming LINE webhook POST requests.
  • User message text from LINE.
  • Google Calendar and Gmail OAuth2 authenticated access.
  • OpenAI API Key to run AI agent.

Processing Steps

  • Webhook node receives LINE messages.
  • Switch node checks if message type is text.
  • AI Agent (LangChain agent) processes text input, using current date context.
  • OpenAI Chat Model provides AI understanding for the agent.
  • Window Buffer Memory stores conversation context by user ID.
  • Wikipedia tool, Google Calendar read/create, and Gmail read work as AI tools.
  • Switch node filters valid AI responses.
  • Set node cleans text (removes markdown, line breaks, HTML tags).
  • HTTP Request nodes reply to LINE with success or error messages.

Outputs

  • User receives clear and clean text answer inside LINE chat.
  • Errors or non-text messages get polite fallback replies.

Who Should Use This Workflow

If managing calendar and emails through LINE is needed, this suits well.
People who dislike switching apps or want quick answers inside LINE chat will gain time.
Users with busy schedules and many event requests get fewer errors like double bookings.
Anyone with basic n8n and API setup knowledge can use it effectively.


Beginner Step-by-Step: How to Use This Workflow in n8n

Step 1: Download and Import

  1. Download the workflow file using the Download button on this page.
  2. Open n8n editor where you want to add the workflow.
  3. Click “Import from File” and select the downloaded workflow JSON.

Step 2: Configure Credentials and Settings

  1. Go to each credential node: Add LINE Messaging API key, Google Calendar OAuth2, Gmail OAuth2, and OpenAI API Key.
  2. Update IDs, like calendar ID or Gmail folder ID if needed.
  3. Check any hardcoded emails or tokens and replace with your own.
  4. Confirm the webhook URL matches the URL set in LINE Messaging API console.

Step 3: Test the Workflow

  1. Send a test text message to the LINE chatbot.
  2. Watch n8n executions to see if AI processes and replies correctly.
  3. Check Google Calendar and Gmail nodes return expected data.

Step 4: Activate for Production

  1. Toggle the workflow active switch in n8n dashboard.
  2. Confirm webhook stays connected and responds live.
  3. Monitor workflow for errors and logs regularly.

Consider using self-host n8n for full control of your data and uptime.


Common Edge Cases and Error Handling

  • Non-text messages like images or stickers receive a polite error reply.
  • If AI returns empty or unclear replies, sends a fallback message like “กรุณาส่งอย่างอื่นเถอะนะเตงอัว”.
  • Invalid or wrong OAuth2 credentials cause failure in Google or Gmail nodes which should be checked.
  • Wrong date or format from AI to calendar creates event errors, so confirm date strings.
  • LINE reply API 401 errors usually mean incorrect channel access token.

Customization Ideas

  • Change AI model in OpenAI Chat Model node to cheaper or stronger versions.
  • Tweak system message prompt in AI Agent to adjust language style or formality.
  • Add new tools like Todoist or weather API nodes to expand assistant tasks.
  • Edit error reply text in second HTTP Request node for personalized fallback.

Summary of What You Get

→ Handling LINE messages as inputs
→ AI understands requests with memory and tools
→ Access to Google Calendar events and create new ones
→ Read Gmail emails filtered by date
→ Clear, friendly messages replying to users in LINE
→ Error and non-text message handling for smooth user experience
→ Saves time by managing daily events and emails inside LINE chat


Frequently Asked Questions

The 401 Unauthorized error happens when the LINE channel access token is missing or incorrect in the HTTP Request nodes.
Check that the AI Agent prompt and system messages are properly configured and that user input is correctly passed.
This is caused by incorrect date formats passed from AI to the calendar nodes. Dates should be ISO strings and verified in node settings.
Non-text messages are filtered by a Switch node and trigger a polite fallback reply that asks the user to send a different message.

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 Workflows in n8n

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