6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Node.js x LINE Messaging APIで複数メッセージを1度に送ってみた

Posted at

はじめに

LINEの公式ドキュメントでは単一メッセージを送るサンプルコードしか記載がなかったため、複数メッセージを特定ユーザに送ることは可能かを検証してみました。

方法

$ npm install @line/bot-sdk
test.js
const line = require('@line/bot-sdk');

const client = new line.Client({
  channelAccessToken: '<channel access token>'
});

const message = [
	  {
	      "type":"text",
	      "text":"Hello, world1"
	  },
	  {
	      "type":"text",
	      "text":"Hello, world2"
	  }
];

client.pushMessage('<to>', message)
  .then(() => {
    console.log('Success');
  })
  .catch((err) => {
    console.error('Failed', JSON.stringify(err));
  });

検証

プログラムを実行してみます。

node test.js

2つのメッセージが送信されることを確認できました。
image.png

参考

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?