1.1.0 • Published 3 years ago

messaging-api-line v1.1.0

Weekly downloads
881
License
MIT
Repository
github
Last release
3 years ago

messaging-api-line

Messaging API client for LINE

Table of Contents

Installation

npm i --save messaging-api-line

or

yarn add messaging-api-line

Usage

Initialize

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

// get accessToken and channelSecret from LINE developers website
const client = new LineClient({
  accessToken: ACCESS_TOKEN,
  channelSecret: CHANNEL_SECRET,
});

Error Handling

messaging-api-line uses axios as HTTP client. We use axios-error package to wrap API error instances for better formatting error messages. Directly calling console.log with the error instance will return 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); // formatted error message
  console.log(error.stack); // error stack trace
  console.log(error.config); // axios request config
  console.log(error.request); // HTTP request
  console.log(error.response); // HTTP response
});

API Reference

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.

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.

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.

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).
1.1.0

3 years ago

1.0.6

3 years ago

1.0.4

3 years ago

1.1.0-alpha.0

3 years ago

1.0.1

4 years ago

1.0.0-beta.34

4 years ago

1.0.0

4 years ago

1.0.0-beta.33

4 years ago

1.0.0-beta.30

4 years ago

1.0.0-beta.29

4 years ago

1.0.0-beta.27

4 years ago

1.0.0-beta.26

4 years ago

1.0.0-beta.24

4 years ago

1.0.0-beta.25

4 years ago

1.0.0-beta.23

4 years ago

1.0.0-beta.21

4 years ago

1.0.0-beta.20

4 years ago

1.0.0-beta.19

4 years ago

1.0.0-beta.18

4 years ago

1.0.0-beta.17

4 years ago

0.8.5

4 years ago

0.7.18

4 years ago

0.7.17

4 years ago

1.0.0-beta.15

4 years ago

1.0.0-beta.16

4 years ago

1.0.0-beta.14

4 years ago

1.0.0-beta.13

4 years ago

1.0.0-beta.12

4 years ago

1.0.0-beta.11

4 years ago

1.0.0-beta.10

4 years ago

1.0.0-beta.6

4 years ago

1.0.0-beta.5

4 years ago

1.0.0-beta.2

4 years ago

1.0.0-beta.1

4 years ago

1.0.0-beta.0

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.2

5 years ago

0.8.3

5 years ago

1.0.0-alpha.0

5 years ago

0.8.2

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.8.0-alpha.7

5 years ago

0.8.0-alpha.6

5 years ago

0.8.0-alpha.5

5 years ago

0.8.0-alpha.4

5 years ago

0.8.0-alpha.3

5 years ago

0.8.0-alpha.2

5 years ago

0.8.0-alpha.1

5 years ago

0.8.0-alpha.0

5 years ago

0.7.15

5 years ago

0.7.12

5 years ago

0.7.11

6 years ago

0.7.9

6 years ago

0.7.8

6 years ago

0.7.7

6 years ago

0.7.6

6 years ago

0.7.5

6 years ago

0.7.4

6 years ago

0.7.3

6 years ago

0.7.2

6 years ago

0.7.0

6 years ago

0.7.0-rc.3

6 years ago

0.7.0-rc.2

6 years ago

0.7.0-rc.1

6 years ago

0.7.0-beta.5

6 years ago

0.7.0-beta.4

6 years ago

0.7.0-beta.3

6 years ago

0.7.0-beta.2

6 years ago

0.7.0-beta.1

6 years ago

0.6.16

6 years ago

0.6.13

6 years ago

0.7.0-alpha.2

6 years ago

0.6.12

6 years ago

0.7.0-alpha.1

6 years ago

0.6.7

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.16

6 years ago

0.5.14

6 years ago

0.5.7

6 years ago

0.5.5

6 years ago

0.5.4

6 years ago

0.5.4-0

6 years ago

0.5.2

6 years ago

0.5.0

7 years ago

0.5.0-0

7 years ago

0.4.4

7 years ago

0.4.2

7 years ago

0.4.1

7 years ago

0.4.0

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.0

7 years ago

0.2.4

7 years ago

0.2.3

7 years ago

0.2.2

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.1.0-2

7 years ago

0.1.0-1

7 years ago