How to Connect Generative AI (ChatGPT, Gemini, Claude) to Line OA

Published March 6, 2024Last updated July 3, 2026Sornkan อ่านภาษาไทย
How to Connect Generative AI (ChatGPT, Gemini, Claude) to Line OA

In this guide, we'll connect Generative AI services — ChatGPT, Gemini, and Claude — to a Line Official Account through their APIs.

From here on, we'll refer to the OpenAI Platform (ChatGPT) API, the Gemini API, the Claude API (Anthropic Console), and similar services collectively as the "GenAI API".

By the end of this article, you'll have a Line chatbot that answers users as if they were chatting with the GenAI API directly.

Overview

Line OA can't call the GenAI platforms directly — it talks to external systems only through something called a Webhook. So the fastest route is to place a middleman between the two sides, and in this guide that middleman is Botnoi Chatbot: it receives each Line message, calls the AI you chose, and replies for you.

If we don't want to build that webhook ourselves, we need an intermediary to do the job, as the diagram below shows.

How the three systems connect

Diagram of the connection between Line OA, Botnoi Chatbot, and the GenAI API

For this setup I chose Botnoi Chatbot as the intermediary, because it connects to the Line side easily and needs almost no extra code.

Which GenAI provider should you pick?

Any of the four providers below works with this setup — the connection steps through Botnoi are nearly identical for all of them. Gemini's free tier makes it the easiest place to start, OpenAI and Claude bill by usage, and Dify.ai adds a prompt layer on top when you want a more specialized bot.

ProviderWhere to create the API keyCost noteGood to know
OpenAI Platform (ChatGPT)OpenAI Platform consolePay-per-use, billed on usage — keep it under controlConnects to Botnoi via the chat/completions endpoint
Google AI Studio (Gemini)Google AI StudioOffers a free tierAnswers tend to be broad unless you steer them with a prompt (e.g. via Dify.ai)
Anthropic Console (Claude)Anthropic ConsolePay-per-use, billed on usage — keep it under controlConnects to Botnoi much like ChatGPT
Dify.aiThe Dify app you createDepends on the LLM you connect behind itThe right choice when you want prompt templates and user inputs

Pricing and free-tier terms change over time, so check each provider's current pricing page before you commit.

Prepare your Line OA

Three things need to happen on the Line side: create a Line Official Account, turn off auto-reply and enable the webhook connection, then link the account to Botnoi Chatbot. Each step takes only a few minutes in the Line OA manager.

A Line Official Account

Create and prepare your chatbot account in advance. If you've never done this before, check the official guide here.

Enable the webhook connection

By default, a Line bot has automatic replies turned on. We need to disable those settings and enable the webhook connection, as shown in the image.

Line OA settings with auto-reply disabled and the webhook connection enabled

Or view the steps here.

Connect Line to Botnoi Chatbot

Click here for the steps.

Prepare the AI platform APIs

Next, sign up for the developer platform of the provider you chose and create an API key. This is not the regular front end where you chat with the AI — it's the platform's back end, which lets external systems (like our chatbot) call the model through an API.

OpenAI Platform (ChatGPT)

Create an API key on the OpenAI Platform — see the steps.

Google AI Studio (Gemini)

Create an API key from Google AI Studio on this page.

Claude by Anthropic

Create an API key from the Anthropic Console — see the steps.

Dify.ai

Create an API key for the app you want to use — see the steps.

Connect your GenAI API key to Botnoi

Now wire the two sides together inside Botnoi: configure the bot so that every message a user sends is forwarded to the GenAI API you prepared, and the model's reply comes back as the bot's answer. Pick the walkthrough below that matches your provider.

OpenAI Platform (ChatGPT)

Using the OpenAI Platform without proper usage control can lead to high costs.

Connect ChatGPT through chat/completion — see the steps here.

Google AI Studio (Gemini)

Google AI Studio offers a free tier, but on its own Gemini tends to give very broad answers. To get more out of it, consider pairing it with Dify.ai (below) to build a prompt that steers the responses.

Take your API details and connect them to Botnoi — see the steps here.

Anthropic Platform (Claude)

Using the Claude API without proper usage control can lead to high costs.

Connect the Claude API to Botnoi — see the steps here.

Dify.ai (text generation, no input)

Connect Dify.ai with a bot that needs no input (text generation only) — see the steps here.

Build a more specialized bot

A direct API connection gives you a bot that behaves exactly like chatting with ChatGPT or Gemini inside Line OA — no persona, no rules, no special job. To make the bot more useful, put a prompt layer in front of the model with a tool like Dify.ai, then adjust the connection as shown below.

Sample Line chat where the bot replies straight from ChatGPT

Sample Line chat where the bot replies straight from Gemini

If you want your bot to handle a wider range of tasks, connect the API to an assistant or prepare the bot through a tool like Dify.ai, then modify the connection as follows.

How to add an input

(Text generation with one input)

The Dify example above is a quote-of-the-day bot: its prompt simply returns a quote, with no input from the user.

In this example, we'll adjust it to accept one extra input. Whatever the user types, the bot will generate a related quote for them.

Dify.ai prompt template with a topic input variable for generating quotes

Then modify the Botnoi API so it also sends whatever the user typed, using the body below — the topic field is the part that changes.

{
    "inputs": {
        "topic": "<<keyword>>"
    },
    "response_mode": "blocking",
    "user": "abc-123"
}

Update this in the Body section of the Botnoi API, as in the example below.

Botnoi API body settings passing the user's message as the topic input

Now, whatever message we send the bot, it generates a related quote for us.

Line chat showing the bot returning a quote related to the user's message

Line OA can act as the front end in certain contexts. As the owner of a GenAI app, choose the front end that fits how your AI actually works.

Cautions

One habit protects you from surprise bills: treat your Line OA like a door into your API account. From this point on, every message sent to the bot calls the Generative AI you connected through Botnoi Chatbot — so control who can reach the bot and keep an eye on usage.

If you chose a Generative AI that charges based on usage — like ChatGPT, Claude, or Dify.ai when it's linked to a paid LLM API behind the scenes — take extra care.

Don't distribute your Line OA to people outside your target users. Anyone who becomes a friend of your Line OA can start using your Generative AI API immediately, just by chatting with the bot.

With Gemini's free tier there's a little more breathing room, but the same habit still applies.


Good luck!

Frequently Asked Questions (FAQ)

Do I need to write code to connect ChatGPT to a Line OA?

No. Botnoi Chatbot acts as the webhook middleman, so everything is configured through web consoles: create an API key on the AI platform, paste it into Botnoi, and link Botnoi to your Line Official Account. Only the Dify input example asks you to edit a small JSON body, and copy-paste is enough.

Why can't Line OA talk to ChatGPT or Gemini directly?

A Line Official Account communicates with external systems only through a webhook. The GenAI platforms expose APIs, not webhooks, so something has to sit in the middle to receive each Line message, call the AI's API, and send the reply back. That middleman is either your own code or a platform like Botnoi.

Which Generative AI should I connect to my Line chatbot?

All four options in this guide connect through Botnoi in almost the same way. Google AI Studio (Gemini) offers a free tier, which makes it a low-risk starting point. OpenAI and Claude bill by usage, so check their current pricing pages first. Choose Dify.ai when you want prompt templates that shape the bot's answers.

Can my Line bot do more than repeat plain ChatGPT answers?

Yes. Instead of calling the model directly, connect through Dify.ai or an assistant-style setup. You write a prompt template that defines the bot's job, add an input variable for the user's message, and Botnoi forwards every chat message into that template — turning a generic chatbot into a specialized one.

Can other people spend my API credits through the bot?

Yes. Anyone who adds your Line OA as a friend can chat with it, and every message triggers a call to your GenAI API. Share the account only with your target users, monitor usage in the provider's console, and set spending limits wherever the platform supports them.

What is Botnoi Chatbot and why is it used here?

Botnoi Chatbot is a chatbot-building platform that links to a Line OA in a few clicks and can call external APIs. In this setup it plays the webhook role: it receives every Line message, forwards it to the GenAI API you configured, and returns the AI's answer to the user.