Skip to main content
Version: Next

LineClient

Usage

Get the LineClient instance using the getClient function:

const { getClient } = require('bottender');

// This `client` variable is a `LineClient` instance
const client = getClient('line');

await client.pushText(USER_ID, 'Hello!');

Or, get the LineClient instance from the context:

async function MyAction(context) {
if (context.platform === 'line') {
// `context.client` is a `LineClient` instance
await context.client.pushText(USER_ID, 'Hello!');
}
}

Error Handling

LineClient uses axios as HTTP client. We use axios-error package to wrap API error instances for better formatting error messages. Calling console.log with the error instance returns the formatted message. If you'd like to get the axios request, response, or config, you can still get them via those keys on the error instance.

client.replyText(token, text).catch((error) => {
console.log(error); // the formatted error message
console.log(error.stack); // stack trace of the error
console.log(error.config); // axios request config
console.log(error.request); // axios HTTP request
console.log(error.response); // axios HTTP response
});

Methods

All methods return a Promise.


Reply API - Official Docs

Responds to events from users, groups, and rooms.

reply(token, messages)

Responds messages using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
messagesArray<Object>Array of objects which contains the contents of the message to be sent.

Example:

client.reply(REPLY_TOKEN, [
{
type: 'text',
text: 'Hello!',
},
]);

replyToken can only be used once, but you can send up to 5 messages using the same token.

const { Line } = require('messaging-api-line');

client.reply(REPLY_TOKEN, [
Line.createText('Hello'),
Line.createImage({
originalContentUrl: 'https://example.com/original.jpg',
previewImageUrl: 'https://example.com/preview.jpg',
}),
Line.createText('End'),
]);

There are a bunch of factory methods can be used to create messages:

  • Line.createText(text, options)
  • Line.createImage(image, options)
  • Line.createVideo(video, options)
  • Line.createAudio(audio, options)
  • Line.createLocation(location, options)
  • Line.createSticker(sticker, options)
  • Line.createImagemap(altText, imagemap, options)
  • Line.createTemplate(altText, template, options)
  • Line.createButtonTemplate(altText, buttonTemplate, options)
  • Line.createConfirmTemplate(altText, confirmTemplate, options)
  • Line.createCarouselTemplate(altText, columns, options)
  • Line.createImageCarouselTemplate(altText, columns, options)
  • Line.createFlex(altText, contents, options)

replyText(token, text, options) - Official Docs

Responds text message using specified reply token.

You can include LINE original emoji in text messages using character codes. For a list of LINE emoji that can be sent in LINE chats, see the emoji list.

ParamTypeDescription
tokenStringreplyToken received via webhook.
textStringText of the message to be sent.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyText(REPLY_TOKEN, 'Hello!');

replyImage(token, image, options) - Official Docs

Responds image message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
image.originalContentUrlStringImage URL.
image.previewImageUrlStringPreview image URL.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyImage(REPLY_TOKEN, {
originalContentUrl: 'https://example.com/original.jpg',
previewImageUrl: 'https://example.com/preview.jpg',
});

replyVideo(token, video, options) - Official Docs

Responds video message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
video.originalContentUrlStringURL of video file.
video.previewImageUrlStringURL of preview image.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyVideo(REPLY_TOKEN, {
originalContentUrl: 'https://example.com/original.mp4',
previewImageUrl: 'https://example.com/preview.jpg',
});

replyAudio(token, audio, options) - Official Docs

Responds audio message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
audio.originalContentUrlStringURL of audio file.
audio.durationNumberLength of audio file (milliseconds).
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyAudio(REPLY_TOKEN, {
originalContentUrl: 'https://example.com/original.m4a',
duration: 240000,
});

replyLocation(token, location, options) - Official Docs

Responds location message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
locationObjectObject contains location's parameters.
location.titleStringTitle of the location.
location.addressStringAddress of the location.
location.latitudeNumberLatitude of the location.
location.longitudeNumberLongitude of the location.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyLocation(REPLY_TOKEN, {
title: 'my location',
address: '〒150-0002 東京都渋谷区渋谷2丁目21−1',
latitude: 35.65910807942215,
longitude: 139.70372892916203,
});

replySticker(token, sticker, options) - Official Docs

Responds sticker message using specified reply token.


For a list of stickers that can be sent with the Messaging API, see the [sticker list](https://developers.line.me/media/messaging-api/messages/sticker_list.pdf).
ParamTypeDescription
tokenStringreplyToken received via webhook.
sticker.packageIdStringPackage ID.
sticker.stickerIdStringSticker ID.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replySticker(REPLY_TOKEN, { packageId: '1', stickerId: '1' });

Reply Imagemap Messages

replyImagemap(token, altText, imagemap, options) - Official Docs

Responds imagemap message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
imagemapObjectObject contains imagemap's parameters.
imagemap.baseUrlStringBase URL of image.
imagemap.baseSizeObjectBase size object.
imagemap.baseSize.widthNumberWidth of base image.
imagemap.baseSize.heightNumberHeight of base image.
imagemap.videoObjectVideo object.
imagemap.video.originalContentUrlStringURL of the video file (Max: 1000 characters).
imagemap.video.previewImageUrlStringURL of the preview image (Max: 1000 characters).
imagemap.video.area.xNumberHorizontal position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.yNumberVertical position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.widthNumberWidth of the video area.
imagemap.video.area.heightNumberHeight of the video area.
imagemap.video.externalLink.linkUriStringWebpage URL. Called when the label displayed after the video is tapped.
imagemap.video.externalLink.labelStringLabel. Displayed after the video is finished.
imagemap.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyImagemap(REPLY_TOKEN, 'this is an imagemap', {
baseUrl: 'https://example.com/bot/images/rm001',
baseSize: {
width: 1040,
height: 1040,
},
actions: [
{
type: 'uri',
linkUri: 'https://example.com/',
area: {
x: 0,
y: 0,
width: 520,
height: 1040,
},
},
{
type: 'message',
text: 'hello',
area: {
x: 520,
y: 0,
width: 520,
height: 1040,
},
},
],
});

Reply Template Messages

replyTemplate(token, altText, template, options) - Official Docs

Responds template message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
templateObjectObject with the contents of the template.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyTemplate(REPLY_TOKEN, 'this is a template', {
type: 'buttons',
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

replyButtonTemplate(token, altText, buttonTemplate, options) - Official Docs

Alias: replyButtonsTemplate.

Responds button template message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
buttonTemplateObjectObject contains buttonTemplate's parameters.
buttonTemplate.thumbnailImageUrlStringImage URL of buttonTemplate.
buttonTemplate.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
buttonTemplate.imageSizeStringSize of the image. Specify one of the following values: cover, contain
buttonTemplate.imageBackgroundColorStringBackground color of image. Specify a RGB color value. The default value is #FFFFFF (white).
buttonTemplate.titleStringTitle of buttonTemplate.
buttonTemplate.textStringMessage text of buttonTemplate.
buttonTemplate.defaultActionObjectAction when image is tapped; set for the entire image, title, and text area.
buttonTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyButtonTemplate(REPLY_TOKEN, 'this is a template', {
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

replyConfirmTemplate(token, altText, confirmTemplate, options) - Official Docs

Responds confirm template message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
confirmTemplateObjectObject contains confirmTemplate's parameters.
confirmTemplate.textStringMessage text of confirmTemplate.
confirmTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyConfirmTemplate(REPLY_TOKEN, 'this is a confirm template', {
text: 'Are you sure?',
actions: [
{
type: 'message',
label: 'Yes',
text: 'yes',
},
{
type: 'message',
label: 'No',
text: 'no',
},
],
});

replyCarouselTemplate(token, altText, carouselItems, options) - Official Docs

Responds carousel template message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for carousel.
optionsObjectObject contains options.
options.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
options.imageSizeStringSize of the image. Specify one of the following values: cover, contain
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyCarouselTemplate(REPLY_TOKEN, 'this is a carousel template', [
{
thumbnailImageUrl: 'https://example.com/bot/images/item1.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=111',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/111',
},
],
},
{
thumbnailImageUrl: 'https://example.com/bot/images/item2.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=222',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=222',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
],
},
]);

replyImageCarouselTemplate(token, altText, carouselItems, options) - Official Docs

Responds image carousel template message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for image carousel.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyImageCarouselTemplate(
REPLY_TOKEN,
'this is an image carousel template',
[
{
imageUrl: 'https://example.com/bot/images/item1.jpg',
action: {
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
},
{
imageUrl: 'https://example.com/bot/images/item2.jpg',
action: {
type: 'message',
label: 'Yes',
text: 'yes',
},
},
{
imageUrl: 'https://example.com/bot/images/item3.jpg',
action: {
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
},
]
);

Reply Flex Messages

replyFlex(token, altText, contents, options) - Official Docs

Responds flex message using specified reply token.

ParamTypeDescription
tokenStringreplyToken received via webhook.
altTextStringAlternative text.
contentsObjectFlex Message container object.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.replyFlex(REPLY_TOKEN, 'this is a flex', {
type: 'bubble',
header: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Header text',
},
],
},
hero: {
type: 'image',
url: 'https://example.com/flex/images/image.jpg',
},
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Body text',
},
],
},
footer: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Footer text',
},
],
},
styles: {
comment: 'See the example of a bubble style object',
},
});

Push API - Official Docs

Sends messages to a user, group, or room at any time.

push(userId, messages)

Sends messages using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
messagesArray<Object>Array of objects which contains the contents of the message to be sent.

Example:

client.push(USER_ID, [
{
type: 'text',
text: 'Hello!',
},
]);

pushText(userId, text, options) - Official Docs

Sends text message using ID of the receiver.

You can include LINE original emoji in text messages using character codes. For a list of LINE emoji that can be sent in LINE chats, see the emoji list.

ParamTypeDescription
userIdStringID of the receiver.
textStringText of the message to be sent.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushText(USER_ID, 'Hello!');

pushImage(userId, image, options) - Official Docs

Sends image message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
image.originalContentUrlStringImage URL.
image.previewImageUrlStringPreview image URL.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushImage(USER_ID, {
originalContentUrl: 'https://example.com/original.jpg',
previewImageUrl: 'https://example.com/preview.jpg',
});

pushVideo(userId, video, options) - Official Docs

Sends video message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
video.originalContentUrlStringURL of video file.
video.previewImageUrlStringURL of preview image.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushVideo(USER_ID, {
originalContentUrl: 'https://example.com/original.mp4',
previewImageUrl: 'https://example.com/preview.jpg',
});

pushAudio(userId, audio, options) - Official Docs

Sends audio message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
audio.originalContentUrlStringURL of audio file.
audio.durationNumberLength of audio file (milliseconds).
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushAudio(USER_ID, {
originalContentUrl: 'https://example.com/original.m4a',
duration: 240000,
});

pushLocation(userId, location, options) - Official Docs

Sends location message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
locationObjectObject contains location's parameters.
location.titleStringTitle of the location.
location.addressStringAddress of the location.
location.latitudeNumberLatitude of the location.
location.longitudeNumberLongitude of the location.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushLocation(USER_ID, {
title: 'my location',
address: '〒150-0002 東京都渋谷区渋谷2丁目21−1',
latitude: 35.65910807942215,
longitude: 139.70372892916203,
});

pushSticker(userId, sticker, options) - Official Docs

Sends sticker message using ID of the receiver.


For a list of stickers that can be sent with the Messaging API, see the [sticker list](https://developers.line.me/media/messaging-api/messages/sticker_list.pdf).
ParamTypeDescription
userIdStringID of the receiver.
sticker.packageIdStringPackage ID.
sticker.stickerIdStringSticker ID.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushSticker(USER_ID, { packageId: '1', stickerId: '1' });

Push Imagemap Messages

pushImagemap(userId, altText, imagemap, options) - Official Docs

Sends imagemap message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
imagemapObjectObject contains imagemap's parameters.
imagemap.baseUrlStringBase URL of image.
imagemap.baseSizeObjectBase size object.
imagemap.baseSize.widthNumberWidth of base image.
imagemap.baseSize.heightNumberHeight of base image.
imagemap.videoObjectVideo object.
imagemap.video.originalContentUrlStringURL of the video file (Max: 1000 characters).
imagemap.video.previewImageUrlStringURL of the preview image (Max: 1000 characters).
imagemap.video.area.xNumberHorizontal position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.yNumberVertical position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.widthNumberWidth of the video area.
imagemap.video.area.heightNumberHeight of the video area.
imagemap.video.externalLink.linkUriStringWebpage URL. Called when the label displayed after the video is tapped.
imagemap.video.externalLink.labelStringLabel. Displayed after the video is finished.
imagemap.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushImagemap(USER_ID, 'this is an imagemap', {
baseUrl: 'https://example.com/bot/images/rm001',
baseSize: {
width: 1040,
height: 1040,
},
actions: [
{
type: 'uri',
linkUri: 'https://example.com/',
area: {
x: 0,
y: 0,
width: 520,
height: 1040,
},
},
{
type: 'message',
text: 'hello',
area: {
x: 520,
y: 0,
width: 520,
height: 1040,
},
},
],
});

Push Template Messages

pushTemplate(userId, altText, template, options) - Official Docs

Sends template message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
templateObjectObject with the contents of the template.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushTemplate(USER_ID, 'this is a template', {
type: 'buttons',
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

pushButtonTemplate(userId, altText, buttonTemplate, options) - Official Docs

Alias: pushButtonsTemplate.

Sends button template message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
buttonTemplateObjectObject contains buttonTemplate's parameters.
buttonTemplate.thumbnailImageUrlStringImage URL of buttonTemplate.
buttonTemplate.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
buttonTemplate.imageSizeStringSize of the image. Specify one of the following values: cover, contain
buttonTemplate.imageBackgroundColorStringBackground color of image. Specify a RGB color value. The default value is #FFFFFF (white).
buttonTemplate.titleStringTitle of buttonTemplate.
buttonTemplate.textStringMessage text of buttonTemplate.
buttonTemplate.defaultActionObjectAction when image is tapped; set for the entire image, title, and text area.
buttonTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushButtonTemplate(USER_ID, 'this is a template', {
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

pushConfirmTemplate(userId, altText, confirmTemplate, options) - Official Docs

Sends confirm template message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
confirmTemplateObjectObject contains confirmTemplate's parameters.
confirmTemplate.textStringMessage text of confirmTemplate.
confirmTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushConfirmTemplate(USER_ID, 'this is a confirm template', {
text: 'Are you sure?',
actions: [
{
type: 'message',
label: 'Yes',
text: 'yes',
},
{
type: 'message',
label: 'No',
text: 'no',
},
],
});

pushCarouselTemplate(userId, altText, carouselItems, options) - Official Docs

Sends carousel template message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for carousel.
optionsObjectObject contains options.
options.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
options.imageSizeStringSize of the image. Specify one of the following values: cover, contain
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushCarouselTemplate(USER_ID, 'this is a carousel template', [
{
thumbnailImageUrl: 'https://example.com/bot/images/item1.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=111',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/111',
},
],
},
{
thumbnailImageUrl: 'https://example.com/bot/images/item2.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=222',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=222',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
],
},
]);

pushImageCarouselTemplate(userId, altText, carouselItems, options) - Official Docs

Sends image carousel template message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for image carousel.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushImageCarouselTemplate(
USER_ID,
'this is an image carousel template',
[
{
imageUrl: 'https://example.com/bot/images/item1.jpg',
action: {
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
},
{
imageUrl: 'https://example.com/bot/images/item2.jpg',
action: {
type: 'message',
label: 'Yes',
text: 'yes',
},
},
{
imageUrl: 'https://example.com/bot/images/item3.jpg',
action: {
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
},
]
);

Push Flex Messages

pushFlex(userId, altText, contents, options) - Official Docs

Sends flex message using ID of the receiver.

ParamTypeDescription
userIdStringID of the receiver.
altTextStringAlternative text.
contentsObjectFlex Message container object.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.pushFlex(USER_ID, 'this is a flex', {
type: 'bubble',
header: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Header text',
},
],
},
hero: {
type: 'image',
url: 'https://example.com/flex/images/image.jpg',
},
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Body text',
},
],
},
footer: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Footer text',
},
],
},
styles: {
comment: 'See the example of a bubble style object',
},
});

Multicast API - Official Docs

Sends messages to multiple users at any time.

multicast(userIds, messages)

Sends messages to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
messagesArray<Object>Array of objects which contains the contents of the message to be sent.

Example:

client.multicast(
[USER_ID],
[
{
type: 'text',
text: 'Hello!',
},
]
);

multicastText(userIds, text, options) - Official Docs

Sends text message to multiple users.

You can include LINE original emoji in text messages using character codes. For a list of LINE emoji that can be sent in LINE chats, see the emoji list.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
textStringText of the message to be sent.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastText([USER_ID], 'Hello!');

multicastImage(userIds, image, options) - Official Docs

Sends image message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
image.originalContentUrlStringImage URL.
image.previewImageUrlStringPreview image URL.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastImage([USER_ID], {
originalContentUrl: 'https://example.com/original.jpg',
previewImageUrl: 'https://example.com/preview.jpg',
});

multicastVideo(userIds, video, options) - Official Docs

Sends video message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
video.originalContentUrlStringURL of video file.
video.previewImageUrlStringURL of preview image.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastVideo([USER_ID], {
originalContentUrl: 'https://example.com/original.mp4',
previewImageUrl: 'https://example.com/preview.jpg',
});

multicastAudio(userIds, audio, options) - Official Docs

Sends audio message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
audio.originalContentUrlStringURL of audio file.
audio.durationNumberLength of audio file (milliseconds).
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastAudio([USER_ID], {
originalContentUrl: 'https://example.com/original.m4a',
duration: 240000,
});

multicastLocation(userIds, location, options) - Official Docs

Sends location message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
locationObjectObject contains location's parameters.
location.titleStringTitle of the location.
location.addressStringAddress of the location.
location.latitudeNumberLatitude of the location.
location.longitudeNumberLongitude of the location.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastLocation([USER_ID], {
title: 'my location',
address: '〒150-0002 東京都渋谷区渋谷2丁目21−1',
latitude: 35.65910807942215,
longitude: 139.70372892916203,
});

multicastSticker(userIds, sticker, options) - Official Docs

Sends sticker message to multiple users.


For a list of stickers that can be sent with the Messaging API, see the [sticker list](https://developers.line.me/media/messaging-api/messages/sticker_list.pdf).
ParamTypeDescription
userIdsArray<String>IDs of the receivers.
sticker.packageIdStringPackage ID.
sticker.stickerIdStringSticker ID.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastSticker([USER_ID], {
packageId: '1',
stickerId: '1',
});

Multicast Imagemap Messages

multicastImagemap(userIds, altText, imagemap, options) - Official Docs

Sends imagemap message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
imagemapObjectObject contains imagemap's parameters.
imagemap.baseUrlStringBase URL of image.
imagemap.baseSizeObjectBase size object.
imagemap.baseSize.widthNumberWidth of base image.
imagemap.baseSize.heightNumberHeight of base image.
imagemap.videoObjectVideo object.
imagemap.video.originalContentUrlStringURL of the video file (Max: 1000 characters).
imagemap.video.previewImageUrlStringURL of the preview image (Max: 1000 characters).
imagemap.video.area.xNumberHorizontal position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.yNumberVertical position of the video area relative to the top-left corner of the imagemap area.
imagemap.video.area.widthNumberWidth of the video area.
imagemap.video.area.heightNumberHeight of the video area.
imagemap.video.externalLink.linkUriStringWebpage URL. Called when the label displayed after the video is tapped.
imagemap.video.externalLink.labelStringLabel. Displayed after the video is finished.
imagemap.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastImagemap([USER_ID], 'this is an imagemap', {
baseUrl: 'https://example.com/bot/images/rm001',
baseSize: {
width: 1040,
height: 1040,
},
actions: [
{
type: 'uri',
linkUri: 'https://example.com/',
area: {
x: 0,
y: 0,
width: 520,
height: 1040,
},
},
{
type: 'message',
text: 'hello',
area: {
x: 520,
y: 0,
width: 520,
height: 1040,
},
},
],
});

Multicast Template Messages

multicastTemplate(userIds, altText, template, options) - Official Docs

Sends template message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
templateObjectObject with the contents of the template.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastTemplate([USER_ID], 'this is a template', {
type: 'buttons',
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

multicastButtonTemplate(userIds, altText, buttonTemplate, options) - Official Docs

Alias: multicastButtonsTemplate.

Sends button template message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
buttonTemplateObjectObject contains buttonTemplate's parameters.
buttonTemplate.thumbnailImageUrlStringImage URL of buttonTemplate.
buttonTemplate.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
buttonTemplate.imageSizeStringSize of the image. Specify one of the following values: cover, contain
buttonTemplate.imageBackgroundColorStringBackground color of image. Specify a RGB color value. The default value is #FFFFFF (white).
buttonTemplate.titleStringTitle of buttonTemplate.
buttonTemplate.textStringMessage text of buttonTemplate.
buttonTemplate.defaultActionObjectAction when image is tapped; set for the entire image, title, and text area.
buttonTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastButtonTemplate([USER_ID], 'this is a template', {
thumbnailImageUrl: 'https://example.com/bot/images/image.jpg',
title: 'Menu',
text: 'Please select',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=123',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=123',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/123',
},
],
});

multicastConfirmTemplate(userIds, altText, confirmTemplate, options) - Official Docs

Sends confirm template message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
confirmTemplateObjectObject contains confirmTemplate's parameters.
confirmTemplate.textStringMessage text of confirmTemplate.
confirmTemplate.actionsArray<Object>Action when tapped.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastConfirmTemplate([USER_ID], 'this is a confirm template', {
text: 'Are you sure?',
actions: [
{
type: 'message',
label: 'Yes',
text: 'yes',
},
{
type: 'message',
label: 'No',
text: 'no',
},
],
});

multicastCarouselTemplate(userIds, altText, carouselItems, options) - Official Docs

Sends carousel template message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for carousel.
optionsObjectObject contains options.
options.imageAspectRatioStringAspect ratio of the image. Specify one of the following values: rectangle, square
options.imageSizeStringSize of the image. Specify one of the following values: cover, contain
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastCarouselTemplate([USER_ID], 'this is a carousel template', [
{
thumbnailImageUrl: 'https://example.com/bot/images/item1.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=111',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/111',
},
],
},
{
thumbnailImageUrl: 'https://example.com/bot/images/item2.jpg',
title: 'this is menu',
text: 'description',
actions: [
{
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=222',
},
{
type: 'postback',
label: 'Add to cart',
data: 'action=add&itemid=222',
},
{
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
],
},
]);

multicastImageCarouselTemplate(userIds, altText, carouselItems, options) - Official Docs

Sends image carousel template message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
carouselItemsArray<Object>Array of columns which contains object for image carousel.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastImageCarouselTemplate(
[USER_ID],
'this is an image carousel template',
[
{
imageUrl: 'https://example.com/bot/images/item1.jpg',
action: {
type: 'postback',
label: 'Buy',
data: 'action=buy&itemid=111',
},
},
{
imageUrl: 'https://example.com/bot/images/item2.jpg',
action: {
type: 'message',
label: 'Yes',
text: 'yes',
},
},
{
imageUrl: 'https://example.com/bot/images/item3.jpg',
action: {
type: 'uri',
label: 'View detail',
uri: 'http://example.com/page/222',
},
},
]
);

Multicast Flex Messages

multicastFlex(userIds, altText, contents, options) - Official Docs

Sends flex message to multiple users.

ParamTypeDescription
userIdsArray<String>IDs of the receivers.
altTextStringAlternative text.
contentsObjectFlex Message container object.
optionsObjectOptional options.
options.quickReplyObjectQuick reply object to attach to the message.
options.quickReply.itemsArrayQuick reply items.

Example:

client.multicastFlex([USER_ID], 'this is a flex', {
type: 'bubble',
header: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Header text',
},
],
},
hero: {
type: 'image',
url: 'https://example.com/flex/images/image.jpg',
},
body: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Body text',
},
],
},
footer: {
type: 'box',
layout: 'vertical',
contents: [
{
type: 'text',
text: 'Footer text',
},
],
},
styles: {
comment: 'See the example of a bubble style object',
},
});

Quick Replies - Official Docs

Sends message with buttons appear at the bottom of the chat screen.

context.replyText(
REPLY_TOKEN,
'Select your favorite food category or send me your location!',
{
quickReply: {
items: [
{
type: 'action',
imageUrl: 'https://example.com/sushi.png',
action: {
type: 'message',
label: 'Sushi',
text: 'Sushi',
},
},
{
type: 'action',
imageUrl: 'https://example.com/tempura.png',
action: {
type: 'message',
label: 'Tempura',
text: 'Tempura',
},
},
{
type: 'action',
action: {
type: 'location',
label: 'Send location',
},
},
],
},
}
);

Content API - Official Docs

getMessageContent(messageId)

Retrieves image, video, and audio data sent in specified message.

ParamTypeDescription
messageIdStringMessage ID.

Example:

client.getMessageContent(MESSAGE_ID).then((buffer) => {
console.log(buffer);
// <Buffer 61 61 73 64 ...>
});

Profile API - Official Docs

getUserProfile(userId)

Gets user profile information.

ParamTypeDescription
userIdStringID of the user.

Example:

client.getUserProfile(USER_ID).then((profile) => {
console.log(profile);
// {
// displayName: 'LINE taro',
// userId: USER_ID,
// pictureUrl: 'http://obs.line-apps.com/...',
// statusMessage: 'Hello, LINE!',
// }
});

Group/Room Member Profile API - Official Docs

getGroupMemberProfile(groupId, userId) - Official Docs

Gets the user profile of a member of a group that the bot is in. This includes the user IDs of users who has not added the bot as a friend or has blocked the bot.

ParamTypeDescription
groupIdStringID of the group.
userIdStringID of the user.

Example:

client.getGroupMemberProfile(GROUP_ID, USER_ID).then((member) => {
console.log(member);
// {
// "displayName":"LINE taro",
// "userId":"Uxxxxxxxxxxxxxx...",
// "pictureUrl":"http://obs.line-apps.com/..."
// }
});

getRoomMemberProfile(roomId, userId) - Official Docs

Gets the user profile of a member of a room that the bot is in. This includes the user IDs of users who has not added the bot as a friend or has blocked the bot.

ParamTypeDescription
roomIdStringID of the group.
userIdStringID of the user.

Example:

client.getRoomMemberProfile(ROOM_ID, USER_ID).then((member) => {
console.log(member);
// {
// "displayName":"LINE taro",
// "userId":"Uxxxxxxxxxxxxxx...",
// "pictureUrl":"http://obs.line-apps.com/..."
// }
});

Group/Room Member IDs API - Official Docs

getGroupMemberIds(groupId, start) - Official Docs

Gets the ID of the users of the members of a group that the bot is in. This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.


This feature is only available for LINE@ Approved accounts or official accounts.
ParamTypeDescription
groupIdStringID of the group.
startStringcontinuationToken.

Example:

client.getGroupMemberIds(GROUP_ID, CURSOR).then((res) => {
console.log(res);
// {
// memberIds: [
// 'Uxxxxxxxxxxxxxx...',
// 'Uxxxxxxxxxxxxxx...',
// 'Uxxxxxxxxxxxxxx...'
// ],
// next: 'jxEWCEEP...'
// }
});

getAllGroupMemberIds(groupId)

Recursively gets the ID of the users of the members of a group that the bot is in using cursors.


This feature is only available for LINE@ Approved accounts or official accounts.
ParamTypeDescription
groupIdStringID of the group.

Example:

client.getAllGroupMemberIds(GROUP_ID).then((ids) => {
console.log(ids);
// [
// 'Uxxxxxxxxxxxxxx..1',
// 'Uxxxxxxxxxxxxxx..2',
// 'Uxxxxxxxxxxxxxx..3',
// 'Uxxxxxxxxxxxxxx..4',
// 'Uxxxxxxxxxxxxxx..5',
// 'Uxxxxxxxxxxxxxx..6',
// ]
});

getRoomMemberIds(roomId, start) - Official Docs

Gets the ID of the users of the members of a room that the bot is in. This includes the user IDs of users who have not added the bot as a friend or has blocked the bot.


This feature is only available for LINE@ Approved accounts or official accounts.
ParamTypeDescription
roomIdStringID of the room.
startStringcontinuationToken.

Example:

client.getRoomMemberIds(ROOM_ID, CURSOR).then((res) => {
console.log(res);
// {
// memberIds: [
// 'Uxxxxxxxxxxxxxx...',
// 'Uxxxxxxxxxxxxxx...',
// 'Uxxxxxxxxxxxxxx...'
// ],
// next: 'jxEWCEEP...'
// }
});

getAllRoomMemberIds(roomId)

Recursively gets the ID of the users of the members of a room that the bot is in using cursors.


This feature is only available for LINE@ Approved accounts or official accounts.
ParamTypeDescription
roomIdStringID of the room.

Example:

client.getAllRoomMemberIds(ROOM_ID).then((ids) => {
console.log(ids);
// [
// 'Uxxxxxxxxxxxxxx..1',
// 'Uxxxxxxxxxxxxxx..2',
// 'Uxxxxxxxxxxxxxx..3',
// 'Uxxxxxxxxxxxxxx..4',
// 'Uxxxxxxxxxxxxxx..5',
// 'Uxxxxxxxxxxxxxx..6',
// ]
});

Leave API - Official Docs

leaveGroup(groupId) - Official Docs

Leave a group.

ParamTypeDescription
groupIdStringID of the group.

Example:

client.leaveGroup(GROUP_ID);

leaveRoom(roomId) - Official Docs

Leave a room.

ParamTypeDescription
roomIdStringID of the room.

Example:

client.leaveRoom(ROOM_ID);

Rich Menu API - Official Docs

getRichMenuList() - Official Docs

Gets a list of all uploaded rich menus.

Example:

client.getRichMenuList().then((richMenus) => {
console.log(richMenus);
// [
// {
// richMenuId: 'RICH_MENU_ID',
// size: {
// width: 2500,
// height: 1686,
// },
// selected: false,
// name: 'Nice richmenu',
// chatBarText: 'Tap here',
// areas: [
// {
// bounds: {
// x: 0,
// y: 0,
// width: 2500,
// height: 1686,
// },
// action: {
// type: 'postback',
// data: 'action=buy&itemid=123',
// },
// },
// ],
// },
// ]
});

getRichMenu(richMenuId) - Official Docs

Gets a rich menu via a rich menu ID.

ParamTypeDescription
richMenuIdStringID of an uploaded rich menu.

Example:

client.getRichMenu(RICH_MENU_ID).then((richMenu) => {
console.log(richMenu);
// {
// richMenuId: 'RICH_MENU_ID',
// size: {
// width: 2500,
// height: 1686,
// },
// selected: false,
// name: 'Nice richmenu',
// chatBarText: 'Tap here',
// areas: [
// {
// bounds: {
// x: 0,
// y: 0,
// width: 2500,
// height: 1686,
// },
// action: {
// type: 'postback',
// data: 'action=buy&itemid=123',
// },
// },
// ],
// }
});

createRichMenu(richMenu) - Official Docs

Creates a rich menu.

ParamTypeDescription
richMenuRichMenuA rich menu object.

Example:

client
.createRichMenu({
size: {
width: 2500,
height: 1686,
},
selected: false,
name: 'Nice richmenu',
chatBarText: 'Tap here',
areas: [
{
bounds: {
x: 0,
y: 0,
width: 2500,
height: 1686,
},
action: {
type: 'postback',
data: 'action=buy&itemid=123',
},
},
],
})
.then((richMenu) => {
console.log(richMenu);
// {
// richMenuId: "{richMenuId}"
// }
});

deleteRichMenu(richMenuId) - Official Docs

Deletes a rich menu.

ParamTypeDescription
richMenuIdStringID of an uploaded rich menu.

Example:

client.deleteRichMenu(RICH_MENU_ID);

getLinkedRichMenu(userId) - Official Docs

Gets the ID of the rich menu linked to a user.

ParamTypeDescription
userIdStringID of the user.

Example:

client.getLinkedRichMenu(USER_ID).then((richMenu) => {
console.log(richMenu);
// {
// richMenuId: "{richMenuId}"
// }
});

linkRichMenu(userId, richMenuId) - Official Docs

Links a rich menu to a user.

ParamTypeDescription
userIdStringID of the user.
richMenuIdStringID of an uploaded rich menu.

Example:

client.linkRichMenu(USER_ID, RICH_MENU_ID);

unlinkRichMenu(userId) - Official Docs

Unlinks a rich menu from a user.

ParamTypeDescription
userIdStringID of the user.

Example:

client.unlinkRichMenu(USER_ID);

downloadRichMenuImage(richMenuId) - Official Docs

Downloads an image associated with a rich menu.

ParamTypeDescription
richMenuIdStringID of an uploaded rich menu.

Example:

client.downloadRichMenuImage(RICH_MENU_ID).then((imageBuffer) => {
console.log(imageBuffer);
// <Buffer 61 61 73 64 ...>
});

uploadRichMenuImage(richMenuId, buffer) - Official Docs

Uploads and attaches an image to a rich menu.

ParamTypeDescription
richMenuIdStringID of an uploaded rich menu.
bufferBufferImage buffer which must be jpeg or png format.

Example:

const fs = require('fs');

client.uploadRichMenuImage(RICH_MENU_ID, fs.readFileSync('image.png'));

getDefaultRichMenu() - Official Docs

Gets the ID of the default rich menu set with the Messaging API.

Example:

client.getDefaultRichMenu().then((richMenu) => {
console.log(richMenu);
// {
// "richMenuId": "{richMenuId}"
// }
});

setDefaultRichMenu(richMenuId) - Official Docs

Sets the default rich menu. The default rich menu is displayed to all users who have added your bot as a friend and are not linked to any per-user rich menu.

ParamTypeDescription
richMenuIdStringID of an uploaded rich menu.

Example:

client.setDefaultRichMenu('{richMenuId}');

The rich menu is displayed in the following order of priority (highest to lowest): The per-user rich menu set with the Messaging API, the default rich menu set with the Messaging API, and the default rich menu set with LINE@ Manager.


deleteDefaultRichMenu() - Official Docs

Cancels the default rich menu set with the Messaging API.

Example:

client.deleteDefaultRichMenu();

issueLinkToken(userId) - Official Docs

Issues a link token used for the account link feature.

ParamTypeDescription
userIdStringID of the user.

Example:

client.issueLinkToken(USER_ID).then((result) => {
console.log(result);
// {
// linkToken: 'NMZTNuVrPTqlr2IF8Bnymkb7rXfYv5EY',
// }
});

LINE Front-end Framework API - Official Docs

createLiffApp(view)

Adds an app to LIFF. You can add up to 10 LIFF apps on one channel.

ParamTypeDescription
view.typeStringSize of the LIFF app view.
view.urlStringURL of the LIFF app. Must start with HTTPS.

Example:

client.createLiffApp({
type: 'compact',
url: 'https://example.com/liff-app',
});

View type can be specified one of the following values:

  • compact: 50% of the screen height of the device. This size can be specified only for the chat screen.
  • tall: 80% of the screen height of the device. This size can be specified only for the chat screen.
  • full: 100% of the screen height of the device. This size can be specified for any screens in the LINE app.

updateLiffApp(liffId, view)

Updates LIFF app settings.

ParamTypeDescription
liffIdStringID of the LIFF app to be updated.
view.typeStringSize of the LIFF app view.
view.urlStringURL of the LIFF app. Must start with HTTPS.

Example:

client.updateLiffApp(LIFF_ID, {
type: 'compact',
url: 'https://example.com/liff-app',
});

getLiffAppList

Gets information on all the LIFF apps registered in the channel.

Example:

client.getLiffApps().then((apps) => {
console.log(apps);
// [
// {
// liffId: '{liffId}',
// view: {
// type: 'full',
// url: 'https://example.com/myservice',
// },
// },
// {
// liffId: '{liffId}',
// view: {
// type: 'tall',
// url: 'https://example.com/myservice2',
// },
// },
// ]
});

deleteLiffApp(liffId)

Deletes a LIFF app.

ParamTypeDescription
liffIdStringID of the LIFF app to be deleted.

Example:

client.deleteLiffApp(LIFF_ID);

Debug Tips

Log Requests Details

To enable default request debugger, use following DEBUG env variable:

DEBUG=messaging-api-line

Test

Send Requests to Your Dummy Server

To avoid sending requests to the real LINE server, provide the origin option in your bottender.js.config file:

module.exports = {
channels: {
line: {
enabled: true,
path: '/webhooks/line',
accessToken: process.env.LINE_ACCESS_TOKEN,
channelSecret: process.env.LINE_CHANNEL_SECRET,
origin:
process.env.NODE_ENV === 'test'
? 'https://mydummytestserver.com'
: undefined,
},
},
};

Warning: Don't do this on the production server.