Connect a bot to LINE

APPLIES TO: SDK v4

You can configure your bot to communicate with people through the LINE app. This article describes how to create a LINE channel using the LINE Developers Console, connect your bot to your LINE channel in Azure, and test your bot in the LINE mobile app.

Prerequisites

  • An Azure account. If you don't already have one, create a free account before you begin.
  • An existing bot published to Azure.
  • A mobile device with the LINE app and a QR reader.

Create a channel in the LINE Developers Console

To build bots with LINE, you need to create a channel in the LINE Developers Console. Follow the steps in the documentation below that are relevant to you before continuing:

Get values from your channel settings

Once you've confirmed your channel settings, you'll be directed to your channel's Basic settings page.

  1. Scroll down to find the Channel secret. Copy the value and save it for later steps.
  2. Scroll back up and select the Messaging settings tab.
  3. At the bottom of the page you'll see a Channel access token (long lived) field, with an Issue button. Select that button to get your access token.
  4. Copy and save the access token for later steps.

Connect your LINE channel to your Azure bot

After obtaining the values above, you're ready to connect your Azure bot to LINE in the Azure portal.

  1. Sign in to the Azure portal and find your bot. Then select Channels.
  2. Select LINE from the Available channels list.
  3. Enter the Channel Secret and Channel Access Token you saved earlier. Then select Apply.
  4. If your bot is successfully connected, the Webhook URL will appear. Copy and save the URL for later steps.

Configure LINE webhook settings

After connecting your channel in Azure and obtaining your webhook URL, return to the LINE Developers Console to configure LINE webhook setting.

  1. Go back to the LINE Developers console.

  2. Select the channel you created earlier from Recently visited channels.

  3. Select the Messaging API setting and scroll down to Webhook settings. Enter the Webhook URL from Azure and select Update.

  4. Select the Verify button under the URL. A success message will appear if the webhook URL is properly configured.

  5. Then enable Use webhook, shown below:

    LINE Webhook settings

    Important

    In LINE Developers Console, set the webhook URL before you enable Use webhook. Enabling webhooks with an empty URL won't set the enabled status, even though the UI may say otherwise.

  6. After adding a webhook URL and enabling Use webhook, reload this page and verify that the changes were set correctly.

Test your bot

Once you've completed these steps, your bot will be successfully configured to communicate with users on LINE. The steps below explain how to test your bot.

Add your bot to your LINE mobile app

To test your bot, you need to use the LINE mobile app.

  1. Scroll up in the Messaging API tab to see the bot's QR code.
  2. Using a mobile device with the LINE app installed, scan the QR code and select the link that appears.
  3. You should now be able to interact with your bot in your mobile LINE app and test your bot.

Automatic messages

When you start testing your bot, it may send unexpected messages that aren't the ones you specified in the conversationUpdate activity.

To avoid sending these messages, take the following steps:

  1. Go to the LINE Developers Console and select your channel. Then select the Messaging API tab.

  2. Scroll down to the LINE Official Account features section. Find Auto-reply messages and select the Edit link.

  3. A new page titled Response settings will open up. Under Detailed settings set Auto-response to Disabled.

    LINE Detailed settings

  4. Alternatively, you can choose to keep these messages. Select Auto-response message settings to edit the auto response message.

Additional information

Troubleshooting

  • If your bot isn't responding to any of your messages, go to your bot in Azure portal, and select Test in Web Chat.
    • If the bot works there but doesn't respond in LINE, reload your LINE Developer Console page and repeat the webhook instructions above. Be sure you set the Webhook URL before enabling webhooks.
    • If the bot doesn't work in Web Chat, debug the bot issue and then finish configuring your LINE channel.