Animated data flow diagram

AI Agent: LINE Assistant with Google Calendar & Gmail Integration

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

LINE OpenAI Google Calendar Gmail Wikipedia

Overview

Unlock Smart Assistance in LINE with this AI Agent

This n8n AI Agent transforms your LINE account into a powerful, conversational personal or business assistant. It intelligently understands user requests in natural language, manages Google Calendar events, retrieves information from your Gmail inbox, and can even look up facts on Wikipedia. Ideal for solopreneurs and teams looking to automate scheduling, information retrieval, and provide quick responses directly within LINE.

This AI Agent leverages LangChain with an OpenAI model (like GPT-4o-mini) to interpret user intent and decide which tool to use – whether it's creating a new meeting in Google Calendar, finding an old email, or answering a general question. It maintains conversational context using session memory, ensuring interactions are smooth and natural.

Key Features & Benefits

  • Conversational AI on LINE: Delivers an interactive chatbot experience within the popular LINE messaging app.
  • Intelligent Task Execution: Dynamically uses tools like Google Calendar (create/read events), Gmail (read emails), and Wikipedia based on your conversation.
  • Smart Scheduling: Ask the agent to create new calendar events (e.g., "Schedule a meeting with John tomorrow at 2 PM about project X") or query your existing schedule.
  • Email Insights: Request summaries or details from your Gmail, like "Find recent emails from client Y."
  • Wikipedia Knowledge Base: Get quick answers to general knowledge questions directly in chat.
  • Context-Aware Conversations: Employs window buffer memory to remember the gist of recent interactions for more relevant follow-ups.
  • Optimized Responses: AI-generated answers are further condensed and cleaned for clear, concise replies on LINE.
  • Error Handling: Includes logic to manage non-text inputs and provide user-friendly error messages.

Use Cases

  • For B2C e-commerce: Provide instant customer support via LINE for order status, appointment scheduling, or product inquiries, pulling info from email confirmations or internal calendars.
  • For B2C e-commerce: Automate booking confirmations and reminders for services by creating Google Calendar events directly from LINE conversations.
  • For B2B SaaS: Offer an internal AI assistant for teams on LINE to quickly schedule meetings, find client communication history in Gmail, or look up industry information via Wikipedia.
  • For B2B SaaS: Streamline lead qualification or initial support on LINE by answering common questions and scheduling demos in Google Calendar.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • OpenAI API Key (compatible with models like gpt-4o-mini or similar).
  • LINE Developer account with a Messaging API channel (Channel Access Token required).
  • Google Cloud Platform project with Calendar API and Gmail API enabled, and OAuth2 credentials configured in n8n for both services.

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure the 'Line Receiving' (Webhook) node:
    • Copy the generated Webhook URL from this node after saving the workflow initially.
    • In your LINE Developer Console, for your Messaging API channel, paste this URL into the 'Webhook URL' field and enable webhooks.
  4. Configure OpenAI Nodes:
    • In the 'OpenAI Chat Model' node (connected to the 'AI Agent'), select or create your OpenAI credentials using your API Key.
    • In the 'OpenAI' node (used for condensing output), select or create your OpenAI credentials and ensure 'gpt-4o-mini' or a similar capable model is selected.
  5. Configure Google Credentials in n8n:
    • Create Google Calendar OAuth2 credentials in your n8n instance. Select these in the 'Google Calendar Create' and 'Google Calendar Read' nodes. Ensure the correct Calendar ID is specified in these nodes (e.g., your primary calendar email address).
    • Create Gmail OAuth2 credentials in your n8n instance. Select these in the 'Gmail Read' node.
  6. Configure LINE Reply Nodes:
    • In both 'Line Answering (Ordinary Case)' and 'Line Answering (Error Case)' HTTP Request nodes, expand the 'Authentication' section, choose 'Header Auth'.
    • Under 'Headers', find or add the 'Authorization' header. Set its value to Bearer YOUR_LINE_CHANNEL_ACCESS_TOKEN. Replace YOUR_LINE_CHANNEL_ACCESS_TOKEN with your actual token from the LINE Developer Console.
  7. Customize AI Behavior (Optional):
    • Modify the systemMessage in the 'AI Agent' node to change the assistant's personality or specific instructions.
    • Review the $fromAI prompts within the 'Google Calendar Create', 'Google Calendar Read', and 'Gmail Read' nodes to fine-tune how the AI extracts parameters for these tools based on user input.
  8. Test and Activate: Send a message to your LINE bot to test its functionality. Once satisfied, activate the workflow for continuous operation.

Tags:

AI AgentAutomationLINEChatbotGoogle CalendarGmailOpenAIProductivityLangChain

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation