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
Automate LINE chatbot with n8n and Gmail

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

Learn how to Build this Workflow with AI:

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

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


Automate LINE chatbot with n8n and Gmail

Visit through Desktop to Interact with the Workflow.

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 Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.