Line Chatbot AI Replies with Groq & Llama3 in n8n

Struggling with managing complex chatbot replies on Line? This n8n workflow uses Groq and Llama3 AI models to automate intelligent, long-message responses seamlessly, eliminating JSON errors and boosting chatbot efficiency.
webhook
httpRequest
set
+1
Workflow Identifier: 1958
NODES in Use: webhook, set, httpRequest, stickyNote
Automate Line chatbot replies with n8n and Groq

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

Learn how to Build this Workflow with AI:

What This Workflow Does

This workflow takes messages sent by users on Line and sends them to a smart AI to get answers.

It fixes issues with long AI replies breaking the chatbot by handling data right.

The workflow sends the AI’s reply back to the user in Line without errors.

This saves you time and gives better replies to customers fast.


Tools and Services Used

  • Line Messaging API: Receives and sends messages on Line platform.
  • Groq AI API: Uses the Llama-3.3-70b-versatile model to generate replies.
  • n8n: Automation platform that connects Line and Groq APIs.

How This Workflow Works: Input → Process → Output

Input

The workflow starts when a user sends a message on Line.

The Webhook node listens for incoming messages using the Line API webhook.

Process

The Set node pulls out the text, user ID, and message ID from the webhook data.

Next, the HTTP Request node calls Groq’s AI endpoint, passing the user’s message to the Llama AI model.

The AI reply is then taken and put into another HTTP Request node that replies back on Line using the correct replyToken.

Output

The user gets a text reply on Line with the AI’s answer.

The reply works without JSON errors, no matter how long or complex the text is.


Who Should Use This Workflow

Anyone running a Line official account who wants to automate customer replies.

Good for small business owners, customer support teams, or marketers needing quick AI answers.

No advanced coding skill is required, only basic understanding of n8n and API keys.


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

Step 1: Import the Workflow

  1. Download the workflow file using the Download button on this page.
  2. Open the n8n editor.
  3. Click on the menu and select Import from File.
  4. Select the downloaded workflow file to import it.

Step 2: Configure Credentials and IDs

  1. Add your Line Channel Access Token credentials in n8n credentials manager.
  2. Add your Groq API Key in n8n credentials manager using HTTP Header Auth.
  3. Check the Webhook node URL matches your Line Developer Console webhook URL.
  4. Verify IDs, emails, or folder names in each node (like replyToken, userId) are correct if customized.

Step 3: Test and Activate

  1. Send a test message from Line to trigger the workflow.
  2. Check n8n execution log to verify that the AI response and Line reply worked.
  3. Turn the workflow toggle to Active to start live operation.
  4. If self-hosting n8n, consider reviewing self-host n8n for stable hosting.

Customization Ideas

  • Switch AI model by changing the model field in Groq HTTP node JSON body.
  • Adjust max_completion_tokens to shorten or lengthen AI replies.
  • Add a Google Sheets node to log all messages and replies for review.
  • Use system messages in AI payload to make replies formal or casual.
  • Change Line reply format to send images, buttons, or quick replies instead of plain text.

Common Errors and Fixes

Groq API “401 Unauthorized”

This means the API key is wrong or expired.

Update the HTTP Header Auth credentials in n8n with a valid Groq API Key.

Line API “ReplyToken is invalid”

This error happens if the replyToken is expired or used more than once.

Make sure to use the replyToken only once right after receiving it from the webhook without big delays.

Summary: What You Get

✓ AI answers sent fast to users on Line with no JSON errors.

✓ Saves agents hours by automating replies.

✓ Works well even with long, complex AI messages.

→ A smoother chat experience on Line for customers.


{
  "messages": [
    {
      "role": "user",
      "content": "{{ $json.body.events[0].message.text }}"
    }
  ],
  "model": "llama-3.3-70b-versatile",
  "temperature": 1,
  "max_completion_tokens": 2500,
  "top_p": 1
}

This is the JSON sent to Groq AI. It uses the user message from Line as input.

{
  "replyToken":"{{ $('Line: Messaging API').item.json.body.events[0].replyToken }}",
  "messages":[
    {
      "type":"text",
      "text": {{ JSON.stringify($('Groq AI Assistant').item.json.choices[0].message.content) }}
    }
  ]
}

This is the JSON sent to Line API to reply with AI content using dynamic expressions.


Automate Line chatbot replies with n8n and Groq

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

Check and update the Groq API Key in n8n HTTP Header Auth credentials to a valid one.
ReplyToken expires quickly; ensure it is used immediately after receiving from webhook and only once.
Yes, but the user must update authentication and request format to match the new AI provider’s API.
It supports real-time chat but for heavy loads, the user should scale n8n and Groq service accordingly.

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.