[Code release]I tried to make Ledge a bot using BOT TREE for MEDIA

[Code release]I tried to make Ledge a bot using BOT TREE for MEDIA

[Code release]I tried to make Ledge a bot using BOT TREE for MEDIA

good morning. This is Onodera.

It was talked about a while ago that TechCrunch created an article distribution bot. Aside from ease of use, it seems necessary to pay attention to “bots as a new form of media” in the future.

In Japan as well, ZEALS recently released a production tool “BOT TREE for MEDIA” that allows you to create bots that deliver articles using your own media.

It’s still in beta now, but I immediately made a bot that introduces Ledge’s article, so I will introduce the process and impressions of making it.

What is BOT TREE for MEDIA?

zeals1

BOT TREE for MEDIA is a “tool for BOT development specialized in Internet media”. One of the features is that you can make a bot without coding.

With this, you can judge the user’s interests from the conversation.“This article is recommended!”You can make a bot that recommends.

By providing article distribution of your own media in the form of a bot, you can communicate with users in a two-way manner, so what kind of articles do users want to read? You may be able to obtain information that was difficult to obtain until now.

By narrowing the distance to the user,Media design that more reflects the opinions of usersShould be able to.

This time I will try to make it work in cooperation so that it works on LINE. It was created by the following procedure.

  • Creating a LINE Business Account
  • BOT TREE for MEDIA account creation and settings
  • Cooperation between LINE account and BOT TREE for MEDIA

I will explain each of them.

Creating a LINE Business Account

It is an account required to make a LINE bot, but since other articles have been published about how to make it, I will omit it this time.

I wrote an article on Ledge before, so please refer to that. >> Is this really the case?I tried to make the topic LINE bot (only with momentum)

Make a note of the ID, Secret Key, and MID as they will be used later.

Creating and setting up a BOT TREE for MEDIA account

First, create an account on the BOT TREE for MEDIA site. When you register, you will receive an email, so be sure to make a note of the api code provided.

Once you have created an account, there are two settings you need to do.

  • Registration of articles and related keywords
  • Setting up the initial conversation with the user

Registration of articles and related keywords

Register the article you want to recommend from the bot in BOT TREE for MEDIA. You can register all articles in the media, or even some.

The information you need here is

  • Publication date and time
  • title
  • URL
  • Related keywords

is.

ZEALS ①

Keywords are used when recommending articles. Think for yourself the keywords that were in the article.

Setting up the initial conversation with the user

Next, first decide what to talk to the user.

Here you can set questions such as nickname, gender, and age as needed. This time it’s almost the default.
ZEALS-5

The information obtained from the question can be confirmed on BOT TREE, so you can check later, “Most of the readers of the media are of this age.”

By the way, the chat function is installed by default without any special settings, so you can handle words that are not related to keywords.

Connecting BOT TREE for MEDIA and LINE

After that, you can use it by connecting BOT TREE and LINE.

This requires a server, but if you just want to use it, the free Heroku is fine.

Also refer to here in cooperation with Heroku >> Is it like this?I tried to make the topic LINE bot (only with momentum)

It’s annoying to think about it, so copy and paste the following code (I got it from ZEALS!) In index.php.

Enter the information you wrote down in the xxxxxxxxxxx part of lines 27,64 to 66 in the code.

[code]ini_set (“display_errors”, On);
error_reporting (E_ALL);
error_log (“callback start.”);
$ json_string = file_get_contents (‘php: // input’);
$ jsonObj = json_decode ($ json_string);
$ to = $ jsonObj-> {“result”}[0]-> {“content”}-> {“from”};
$ text = $ jsonObj-> {“result”}[0]-> {“content”}-> {“text”};

$ response_arrays = chat ($ to, $ text);

foreach ($ response_arrays as $ response_array) {
$ response_text[]= $ response_array[‘content’];
}

// Since toChannel and eventType are fixed values, there is no need to change them.
$ post_data = [“to”=>[$to]”ToChannel” => ”1383378250 ″, ”eventType” => ”138311608800106203”, ”content” => $ response_format_text];

foreach ($ response_text as $ val) {
$ response_format_text = [‘contentType’=>1,”toType”=>1,”text”=>$val];
line ($ to, $ post_data, $ response_format_text);
}

function chat ($ to, $ send_message) {
// Enter the API Key issued by Zeels (11 digits)
$ api_key =’xxxxxxxxxxx’;
$ api_url =’https://bottree.tokyo’;
$ req_body = array (
‘api’ => $ api_key,
‘content’ => $ content,
);
$ req_body[‘content’] = array (
‘userid’ => $ to,
‘text’ => $ send_message
);
$ headers = array (
‘Content-Type: application / json; charset = UTF-8’,
);
$ options = array (
‘http’ => array (
‘method’ =>’POST’,
‘header’ => implode (“rn”, $ headers),
‘content’ => json_encode ($ req_body),
)
);
$ stream = stream_context_create ($ options);
$ res = json_decode (file_get_contents ($ api_url, false, $ stream), true);
return $ res[‘contents’];
}

function line ($ to, $ post_data, $ response_format_text) {
// Since toChannel and eventType are fixed values, there is no need to change them.
error_log (“line called”);
$ post_data = [“to”=>[$to]”ToChannel” => ”1383378250 ″, ”eventType” => ”138311608800106203”, ”content” => $ response_format_text];
$ ch = curl_init (“https://trialbot-api.line.me/v1/events”);
curl_setopt ($ ch, CURLOPT_POST, true);
curl_setopt ($ ch, CURLOPT_CUSTOMREQUEST,’POST’);
curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ ch, CURLOPT_POSTFIELDS, json_encode ($ post_data));
// Rewrite to what is displayed on the LINE setting screen
curl_setopt ($ ch, CURLOPT_HTTPHEADER, array (
‘Content-Type: application / json; charser = UTF-8’,
‘X-Line-ChannelID: xxxxxxxxxxx’,
‘X-Line-Channel Secret: xxxxxxxxxxx’,
‘X-Line-Trusted-User-With-ACL: xxxxxxxxxxx’
));
$ result = curl_exec ($ ch);
$ debug = json_encode ($ post_data);
error_log (“have posted”);
error_log ($ debug);
error_log ($ result);
curl_close ($ ch);
}

?>
[/code]

This completes the settings. It took about 30 to 60 minutes including the server settings.

I will try using the created bot immediately.

Try using Ledgebot

Ledgebot first,

  • nickname
  • age
  • sex
  • Profession

It is designed to listen to. It’s annoying to make it myself, but I will answer.

ZEALSBOT_LINE

All you have to do is chat about what articles you want to read.

For example, if you listen to an article about artificial intelligence and chatbots, it will collate with the registered keywords and introduce the article.

ZEALSBOT_LINE

Like this, he recommended an article in which the keywords “artificial intelligence” and “chatbot” were registered.

All information about who had what kind of conversation can be confirmed on the BOT TREE side. You can see the conversation log as well as the necessary information you set yourself, such as your nickname, name, and occupation.

ZEALS-2

The QR code of LINEbot created in this article is as follows. Please use it by all means.

chatbot_url

By the way, you can also go from here.

There is still a point that it is still difficult to use …

When I raise the point that I personally felt that improvement was necessary,

  • Introducing one article at a time.Will not introduce multiple articles at once
  • Even if you answer the wrong nickname or gender, you cannot correct it later.
  • You can’t do it without programming.Have coding knowledge
  • Even if you tell the set keyword, it may not work properly.
  • You have to register the article and register the keyword of the article by yourself
  • The information to be entered first cannot be used for the recommendation rule
  • The default chat response is too light.Cannot be used with solid media

etc. This area is not the official version yet, so I’m looking forward to future development.

At the end

Article distribution from bots seems to have more problems. To be honest, at this stage, I wonder if it will exceed the experience / usability of web media.

Just by making it a bot, cooperation with other services, personalization support, etc. will be done from now onCombine with technologies that will come out one after anotherYou can do it, and I think it’s better to follow it sideways.

If you get smarter, you reallyWill recommend Don Pisha’s articleThat’s right. And if the number of articles is messed up, it seems to be more effective than searching for articles by yourself.

I’m looking forward to future developments.

Then it was Onodera.