1. Documents
  2. Messaging API

Getting started with the Messaging API

Here we’ll show you how to create a bot on LINE using the Messaging API so you can interact more closely with your users. To use the Messaging API, you first need to have either a LINE@ or LINE official account.

Note: For more information on account types, see LINE official accounts and LINE@ account. Pricing for accounts and plans varies by country. For more information, see LINE@ Plans and Prices.

What you need to start

To create a bot you first need to have a registered account on the LINE Business Center. You can create an account by signing in to the “LINE Business Center and providing your information. Follow the appropriate link below and complete the steps to start creating a bot.

Note: If you have a LINE official account, please contact your LINE representative for more information on creating a bot.

Create a LINE@ account with the Messaging API enabled

  1. In the LINE Business Center, select Messaging API under the “Service” category at the top of the page.
  2. Select either Start using Messaging API or Start Developer Trial. For more information on the Developer Trial plan, see Messaging API.
  3. Enter the required information (account name, business type) for your new LINE@ account. Confirm the information.
  4. Click the LINE@ MANAGER button at the bottom of the confirmation page to go to the “Bot Settings” page of the LINE@ Manager.
  5. On the “Bot Settings” page, click Enable API.
  6. Configure your bot by following the steps in Configure your bot.

Enable the Messaging API for your LINE@ account

  1. Go to your LINE@ account page in the LINE Business Center
  2. Select the Start using Messaging API button at the bottom of the page. Click OK, after agreeing to the terms and conditions. Note: If you don’t see the Start using Messaging API button, follow the steps below.
  3. Click the LINE@ MANAGER button at the bottom of the confirmation page to go to the “Bot Settings” page of the LINE@ Manager.
  4. On the “Bot Settings” page, click Enable API.
  5. Configure your bot by following the steps in Configure your bot.

If you don’t see the Start using Messaging API button on your LINE@ account page, follow the steps below.

  1. In the LINE@ Manager, go to your LINE@ account page.
  2. Go to the Bot Settings page, which can be found under “Settings” on the side menu
  3. On the “Bot Settings” page, click Enable API.
  4. Configure your bot by following the steps in Configure your bot.

Configure your LINE@ account

To respond to messages from your users using the Messaging API, you first need to enable webhooks for your LINE@ account on the LINE@ Manager. You’ll then need to get a Channel access token and set a webhook URL on the Channel Console.

LINE@ Manager

  1. In the LINE@ Manager, go to the Bot Settings page, which can be found under “Settings” on the side menu
  2. To reply to messages using webhooks, select Allow for “Use webhooks” under “Request Settings”
  3. Optional settings:
    1. To participate in group chats, select Allow for the “Allow bots to join group chats” option
    2. To send a customized response message to user messages, select Allow for the “Auto Reply Message” option
    3. To send a customized greeting message when users add your account as a friend, select Allow for the “Greeting Message” option

Channel Console

Your bot application requires a Channel access token to call APIs and a webhook URL to receive webhook payloads. Channel access tokens are issued from the Channel Console and the webhook URL is the endpoint of your bot application’s server where webhooks payloads are sent.

For an example of how to quickly build a simple bot deployed to Heroku, go to Build a sample echo bot.

  1. Go to your LINE@ account page in the LINE Business Center.
  2. In the “Messaging API” section, select the LINE Developers button to go to the Channel Console.
  3. To issue a Channel access token for accessing APIs, click ISSUE for the “Channel access token” item
  4. Click EDIT and set a webhook URL for your Channel
    • Note: The webhook URL must use HTTPS and have an SSL certificate issued by an authorized CA. You can check that your webhook URL is valid by clicking the VERIFY button.
  5. (Optional) To increase security, register the IP addresses of your server(s) on the Server IP whitelist page.

After completing these steps, you can start developing your LINE bot.

Develop your bot

To help you start developing your bot, you can use our various SDKs and the sample echo bot and kitchen sink applications that are included in each of the SDKs. You can also refer to the API reference to see the endpoint and webhook information for the Messaging API.

LINE Bot SDKs

Messaging API reference

Build a sample echo bot

This is a simple tutorial to help you quickly build a sample echo bot on LINE that repeats text messages that you send it. In this tutorial, you’ll use the sample-spring-boot-echo application in the Java LINE Bot SDK and deploy the bot on Heroku.

Requirements

To build this simple LINE bot, you’ll need to have the following:

  • A LINE@ account with the Messaging API and webhook options enabled (instructions above)
  • A Heroku account (you can create one for free)
  • Java version 8 or higher

Deploy the bot

You can follow the instructions on the readme file in the sample-spring-boot-echo GitHub directory or the instructions below to create the bot.

  1. Get the Channel secret and Channel access token from the Channel Console
  2. Click the Deploy to Heroku button on the readme file in the sample-spring-boot-echo GitHub directory
  3. Fill in the form for the Heroku app and click Deploy
  4. Enter the webhook URL in the Channel Console using the following URL format: https://{HEROKU_APP_NAME}.herokuapp.com/callback
  5. Add your bot as a friend on LINE by scanning the QR code on the basic information page
  6. Test your bot by sending it a message on LINE

Your bot should be able to respond to simple text messages and look something like this:

bot demo iOS

Next steps

Check logs with Heroku CLI

To see the logs of your echo bot on Heroku, follow the steps below.

  1. Download and install Heroku CLI
  2. Login to Heroku
    $ heroku login
  3. Clone your repository
    $ heroku git:clone -a bot-demo-for-line
    $ cd bot-demo-for-line
  4. Check your logs
    $ heroku logs --tail

Deploy the kitchensink sample bot application

To get a more complete picture of what a bot on LINE can do, you can use the kitchensink sample bot application in the LINE Bot SDK. With the kitchensink application, your bot can send different types of template messages and other hypermedia in addition to simple text messages. The following instructions, explain how to easily deploy the Java kitchensink application using the Heroku account you created in Build a sample echo bot.

  1. Clone the line-bot-sdk-java GitHub repository onto your local machine
  2. Replace “echo” with “kitchensink” in Procfile
    java $JAVA_OPTS -jar sample-spring-boot-kitchensink/build/libs/sample-spring-boot-kitchensink-*.jar --server.port=$PORT
  3. Push to Heroku
    $ git push heroku master
  4. Try the following with your bot on LINE
    • Send “profile”. Bot replies with your LINE profile information.
    • Send “confirm”. Bot replies with a sample confirm template message.
    • Send “buttons”. Bot replies with a sample buttons template message.
    • Send “carousel”. Bot replies with a sample carousel template message.
    • Send an image, audio message, video message, or your location. Bot retrieves the content and replies with the same content
    • Send “bye”. Bot leaves the group if in a group.

Although this tutorial uses Java as an example, you can also use the echo and kitchensink sample applications that are available in our other LINE Bot SDKs. To continue developing your bot and to see all the resources available, see Messaging API reference.