AI Chatbot By BOTNOI

May 1, 2023

How to use ChatGPT on LINE OA: no code writing, no tech skills needed, 100% guaranteed!

How to use ChatGPT on LINE OA: no code writing, no tech skills needed, 100% guaranteed!

With ChatGPT, it's like having a super-intelligent personal assistant that's on call 24/7, providing you with instant information in your daily life and helping you increase your productivity. Now, wouldn't it be great to have this convenience right at our fingertips with our favorite messenger app LINE, without having to constantly switch to the website and the app?

But here's the problem: to establish the connection between ChatGPT and your LINE account, you first need to become a certified programmer. Or do you?

In the clip above, you can see the cool things you can do when you link ChatGPT to your LINE. You can ask about global warming, write a resume, crunch numbers, or plan a trip—all right from the same app!

In this article, I'll show you how to connect ChatGPT to your LINE OA without writing a single line of code. You can easily follow these steps even if you've never programmed before. No tech skills needed!

1. Create a chatbot to be connected to LINE OA.

First, we need to create an official LINE account (OA), this is the channel through which you will communicate with ChatGPT.

1a. Create LINE OA

  • After logging in, go to https://manager.line.biz/ and look to the left. There is a button you can press to create a new account (as shown in picture 1).

  • Enter the information required and follow the steps (as shown in figure number 2).

  • You will then receive your LINE OA and a QR code to invite people to use it (as shown in figure number 3)


    step-create-lineOA

1b. Create a chatbot on the BOTNOI platform.

  • Go to https://botnoi.ai and log in.

  • In the upper right corner you will find a button to create a chatbot (New Chatbot).

  • Enter the information as required and click “Create” (as shown in figure number 1).

  • In the bottom left corner you will find the Settings option in the form of a gear, press it and select Connection (as shown in Figure 2).

  • Select LINE, which has two connection methods. We’re going for the simpler method between the two, so press LINE Modular Setting (as shown in figure 3).

  • Then press to select an account (as shown in figure number 4) and choose to connect with the LINE OA we’ve previously created. After that, press the connect button (as shown in figure number 5).

    step-create-chatbot-botnoi

2. Get the API key from OpenAI.

3. Create an API object in the BOTNOI tool.

At this point you might be wondering what an API is? Don't worry, I'll explain it to you in layman terms. To put it simply, it's similar to a website with a URL, but instead of typing the URL and getting a website, we get data with key and value instead. Below is an example of what a response from the API looks like. This is what we call the JSON format.

{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-003",
"choices": [
{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}

3a. First, we need to understand how to call OpenAI's API. Documentation regarding this can be found at this link: https://platform.openai.com/docs/api-reference/completions/create

Here we will see the method to call the API for completions:

curl https://api.openai.com/v1/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "text-davinci-003",
"prompt": "Say this is a test",
"max_tokens": 7,
"temperature": 0
}'

The explanation of the different values ​​that can be used as parameters is as follows:

The Header-H section contains the following:

  • Content-Type is the type of data, which is JSON.

  • Authorization is the key to deduct the points used.

For the Body-d section there will be:

  • Whatever model we want to use. The accuracy and speed of each article is also different. You can try things out and experiment.


    example-api-model

The prompt is the input or message we want to ask ChatGPT, for example questions about addition, subtraction, multiplication and division to help us with some math equations or general questions like what species of tigers are there.

  • As for max_token, it refers to the length of the text. In the documentation we chose 7, which might be too little. You can even add more up to 1,000 if you want, but keep in mind that the longer it is, the more it costs.

  • The last thing is temperature, which means that the randomness of the answer increases when we enter more values.

    example-of-using-chatgpt-with-chatbot

3b. Create an API object in the BOTNOI tool.

If you’ve never used BOTNOI's chatbot tools before, you can start by going through this playlist: youtube playlist tutorial.

Otherwise, go to the BOTNOI chatbot generator, then go to the API Object section. Select what you want to create as a Post, and then fill in the information according to how you want to call the ChatGPT API (Section 2a).

Note that the structure consists of three parts, including the URL part, the Header part, and the Body part. Change the value in the prompt to <<keyword>>.

create-api-object-in-botnoi-tool

A little explanation of what goes on here: the BOTNOI system stores the message that the user last sent in the chatbot in the keyword variable. When the API is called, the system retrieves the value in the keyword variable and sends it to the value of the registered prompt.

4. Bind the created API object to a topic or intent and display the results.

Simply put, binding is about creating a connection between two or more programming objects, which is what we are going to do now.

After all the steps we have done above, we can finally bind the API object to any Intent or topic, but in this example, I am going to bind this API object to Fallback. This means if the message that the user sends to the chatbot does not match any intent, the ChatGPT API object will be called.

This should, in my opinion, make the chatbot more sophisticated, as it is better tailored to your preferences and needs. For each topic we want the chatbot to answer, we can train the Intent as usual, such as asking about special offers or store opening hours. But anything else that is beyond the scope of these questions we teach the chatbot, we leave to ChatGPT.

The binding method is as follows:

step-binding

4a. Go to the Train Bot tab on the left, select Default Fallback and click BOT RESPONSE.

4b. Press Existing Objects and select the created API Object.

4c. Enter <<API_chatgpt-test.choices.0.text>> to extract values ​​from the received API response.

The value of c added from the response received from the API can be explained as follows:

{
"id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
"object": "text_completion",
"created": 1589478378,
"model": "text-davinci-003",
"choices": [
{
"text": "\n\nThis is indeed a test",
"index": 0,
"logprobs": null,
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 7,
"total_tokens": 12
}
}

We need "text" which is the API response, so we need .choices which is an array to access the first object in the array which is .0. Then to access the text we once again need .text, so we need to enter <<API_chatgpt-test.choices.0.text>> to extract the responses and display them via the chatbot.

And it’s a wrap! Below is a short clip I created to summarize all the steps so anyone can easily follow them:

For anyone interested in building a chatbot, BOTNOI provides tools to develop complex but easy to develop AI chatbots. Why not have a go and try your hand at https://botnoi.ai and you can also find a playlist tutorial link here -> YouTube playlist tutorial.

If you are interested in using BOTNOI’s service to create chatbots or are looking for advice on the topic of “AI & Data Science”, please feel free to contact us via the website -> “Botnoi” and “FB page Botnoi Consulting”.

กลับ

Collaborate to Innovate

Together, We Build the Future.

Collaborate to Innovate

Together, We Build the Future.