Q&A

カルーセルのバブルに同じ数のアクションを設定しないとエラになります。

前提・実現したいこと

Messaging APIを利用してカルーセルを送信します。 (複数バブルを送信します。)

発生している問題・エラーメッセージ

複数バブルの場合、個々のバブルに同じ数のアクションオブジェクトを揃えないとエラーになります。 これはMessaging APIの仕様でしょうか?

statusCode: 400, statusMessage: 'Bad Request', originalError: Error: Request failed with status code 400 at createError (〇〇〇/node_modules/@line/bot-sdk/node_modules/axios/lib/core/createError.js:16:15) at settle (〇〇〇/node_modules/@line/bot-sdk/node_modules/axios/lib/core/settle.js:17:12) at IncomingMessage.handleStreamEnd (〇〇〇/node_modules/@line/bot-sdk/node_modules/axios/lib/adapters/http.js:269:11)

該当のソースコード

2つ目のバブルに1つのアクションを設定するとエラーになります。

{
  "type": "template",
  "altText": "カルーセルテンプレート",
  "template": {
    type: 'carousel',
    columns: [
      {
        "text":"カルーセルメッセージ1",
        "actions":[
          {"type":"message","label":"ボタン1ラベル","text":"ボタン1"},
          {"type":"message","label":"ボタン2ラベル","text":"ボタン2"},
          {"type":"message","label":"ボタン3ラベル","text":"ボタン3"},
        ],
      },
      {
        "text":"カルーセルメッセージ2",
        "actions":[
          {"type":"message","label":"ボタン4ラベル","text":"ボタン4"},
        ]
      },
    ],
  },
}

試したこと

1)各バブルに同じ数のアクションを設定すればエラーになりません。

{
  "type": "template",
  "altText": "カルーセルテンプレート",
  "template": {
    type: 'carousel',
    columns: [
      {
        "text":"カルーセルメッセージ1",
        "actions":[
          {"type":"message","label":"ボタン1ラベル","text":"ボタン1"},
          {"type":"message","label":"ボタン2ラベル","text":"ボタン2"},
        ],
      },
      {
        "text":"カルーセルメッセージ2",
        "actions":[
          {"type":"message","label":"ボタン4ラベル","text":"ボタン4"},
          {"type":"message","label":"ボタン5ラベル","text":"ボタン5"},
        ]
      },
    ],
  },
}

2)バブルが1つしかない場合は、アクションが1つでもエラーになりません。

{
  "type": "template",
  "altText": "カルーセルテンプレート",
  "template": {
    type: 'carousel',
    columns: [
      {
        "text":"カルーセルメッセージ1",
        "actions":[
          {"type":"message","label":"ボタン1ラベル","text":"ボタン1"},
        ],
      },
    ],
  },
}

補足情報(FW/ツールのバージョンなど)

利用している @line/bot-sdk のバージョン: 7.5.0 開発言語:nodeJS

  • 0
  • 2
  • 1199
  • X(旧Twitter) facebook

flex messageではactionの数が異なっていても問題ないようです。 https://developers.line.biz/ja/docs/messaging-api/using-flex-messages/

  • 0

https://developers.line.biz/ja/reference/messaging-api/#column-object-for-carousel

各カラムのアクションの数は同じにします。画像またはタイトルの有無も、各カラムで統一してください。

と書いてあるので仕様みたいですね。

  • 1
Are you sure? question.vm