Linking a bot with your LINE Login channel

By linking a bot developed using the Messaging API with your LINE Login channel, you can display an option to add the bot as a friend when a user logs in to your web app.

If the user selects the Add friend button, the bot will be added as a friend.

Consent screen

For more information on bots, see Messaging API.

Before you begin

To display the option to add your bot as a friend, make sure you have the following:

  • LINE Login v2.1 or above
  • A bot selected in the "Bot linked to this channel" item

Displaying the option to add your bot as friend

To link a bot with your channel, link the bot with your channel on the console and redirect the user to the authorization URL with the bot_prompt query parameter.

Link a bot with your LINE Login channel on the console.

To link a bot to your LINE Login channel, you must satisfy these requirements:

  • At least one bot is linked to a Messaging API channel that belongs to the same provider as your LINE Login channel.
  • You are an administrator of the LINE Login channel and the bot.

    Find your role for the channel in the LINE Developers console. Find your role for the bot in LINE@ Manager.

  1. Log in to the LINE Developers console and click the provider that contains the channel for LINE Login.

  2. Click your LINE Login channel.

  3. Click Edit for the "Bot linked to this channel" item.

    Note: The "Bot linked to this channel" item is displayed only when the app type of the channel is "WEB".

  4. Select the bot you want users to add and click Update.

    You can select a bot for which you are an administrator.

    You can link only one bot to a channel.

Redirect users to the authorization URL

Redirect users to the LINE Login authorization URL with the bot_prompt query parameter as shown below. For more information on redirecting users to the authorization URL, see Making an authorization request.

https://access.line.me/oauth2/v2.1/authorize?response_type=code&client_id={CHANNEL_ID}&redirect_uri={CALLBACK_URL}&state={STATE}&bot_prompt={BOT_PROMPT}&scope={SCOPE_LIST}


Set one of the following values for the bot_prompt query parameter.

Value Description
normal Includes an option to add a bot as friend in the consent screen.
aggressive Opens a new screen to add the bot as friend after the user agrees to the permissions in the consent screen.

The following screens are displayed depending on the bot_prompt value.

Screen to be displayed

The following describes the consent screen and how the process is handled depending on the user's friendship status with the bot before logging in.

Friendship status before login Description
Not a friend A button is displayed to add the bot as a friend. The bot is added as a friend if the user taps the button.
Bot blocked by user A button is displayed to unblock the bot. The bot is unblocked if the user taps the button.
Added as friend Shows that the user has added the bot as a friend. No button is displayed to add the bot as a friend.

Getting the friendship status of the user and the bot

You can get the friendship status of the user and the bot using the following methods.

Use the friendship_status_changed query parameter

If the following conditions are met, the friendship_status_changed query parameter is returned in the callback URL after the authentication and authorization process is complete.

  • The bot_prompt query parameter is specified when making an authorization request.
  • The consent screen with the option to add your bot as friend is displayed to the user.

The following is an example response with the friendship_status_changed parameter in the callback URL.

HTTTP/1.1 302 Found
Location : https://client.example.org/cb?code={CODE}&state={STATE}&friendship_status_changed={FRIENDSHIP_STATUS_CHANGED}

The friendship_status_changed query parameter can take the following values. For more information on the callback URL, see Receiving the authorization code.

Value Description
true The friendship status of the user and bot changed during login. This occurs in the following situations:
  • User added the bot as a friend
  • User unblocked the bot
false The friendship status of the user and bot did not change during login. This occurs in the following situations:
  • User already added the bot as a friend
  • User did not add the bot as a friend
  • User did not unblock the bot

Use the Social API to get friendship status

Send a GET request to the https://api.line.me/friendship/v1/status endpoint after the user has logged in to your app and an access token has been returned.

curl -X GET \
-H 'Authorization: Bearer {access token}' \
https://api.line.me/friendship/v1/status

The friendFlag property is returned if the API call is successful. The value is true if the user has added the bot as a friend and has not blocked the bot. Otherwise, the value is false.

For more information, see Get friendship status in the Social API reference.