This entry is the 21st day of GMO Advent Calendar 2018 (https://qiita.com/advent-calendar/2018/gmo-am). The day before was @ thomi40's About the WebVR framework "A-Frame".
Hello, my name is @zakisanbaiman. I am usually in charge of the logic part (Java) of the ad delivery application.
I've been playing with LINE bot recently, so I'll show you how to build it.
First, create a LINE @ account There are two types of accounts, but if you are a hobby, you can use a general account.
This is the account creation screen. The type of business may be "individual".
Once your account is issued, you can log in to LINE @ MANAGER. Here you can set the bot icon and status message. However, I don't use this screen very much.
This time we will use the Messaging API for bots, so let's move on to "LINE Developers". ¥
The following is the "LINE Developers" screen. I mainly use this site to set up bots.
We will set the "provider". The provider here is the service provider of the bot.
The provider has been created. Then create a channel.
I think the plan should be "Developer Trial" once.
Set the app name and app icon here.
The app is now complete. There is a QR code for adding friends at the bottom of "Channel basic settings", so let's add friends.
If you register as a friend, they will only say hello by default.
If this is OK, let's continue to create a bot program.
Prepare a server to put the program on. This time, we will use a cloud platform called heroku, which is free and easy to prepare.
Here, let's just sign up once. I'll set up heroku a little later.
First, let's clone the SDK for LINE Bot development prepared by LINE from GitHub. This time I will introduce Java ones, but there are also PHP, Go, Perl, Ruby, Python, Node.js and so on. https://github.com/line/line-bot-sdk-java
The directory structure is complicated, but if you just want to give a simple reply All you have to do is mess with sample-spring-boot-echo. Since the parrot return process works even if the code is as it is, the Java file is not changed here.
There is a file that you have to create if you have one, which is application.yml. There is application-template.yml in resources, so let's copy it to make application.yml. (Path: line-bot-sdk-java / sample-spring-boot-echo / src / main / resources / application-template.yml)
Set the channel token and channel secret in application.yml. (Both are listed in the basic channel settings)
application.yml
line.bot:
channel-token: '{Channel token}'
channel-secret: '{Channel secret}'
handler.path: /callback
There is a button called "Deploy to Heroku" in line-bot-sdk-java / sample-spring-boot-echo / README.md, so let's press it.
Then the browser will open and the login screen will open, so log in. Then enter the app name, channel secret and channel token and press "Deploy app".
It takes a few minutes to deploy, but if you see "Your app was successfully deployed.", The deployment is successful.
Set Webhook transmission to "Use".
Set the Webhook URL to "https: // $ {YOUR_HEROKU_APP_NAME} .herokuapp.com / callback". {YOUR_HEROKU_APP_NAME} is the app name you set on heroku.
Set the automatic response message to "Not used". If you do not set this, the created program will not be called.
↑ Even if the above settings are made, it may not be reflected properly. In that case, if you update the screen, it will be reflected, so let's update the screen.
For the time being, we have a bot that will return the parrot!
https://qiita.com/skycat_me/items/9f27cbd9354515df744a
../gradlew bootRun does not pass Because the "This is tempalte ~" part of application.yml is not commented out
I don't know gradle home
$ echo $gradle_home
/usr/local/gradle
@AllArgsConstructor(onConstructor = @__(@JsonCreator)) Error: (27, 38) java: symbol not found Symbol: class __ Checking "Enable annotation processing" fixed it. (For IntelliJ)
Tomorrow is @ yoshishin's [Try Rails 6 action text]. have a nice Christmas~
Recommended Posts