Flex Messageの要素のテキストとボタンを試してみました
何かメッセージを投稿した時に
設定したテキストとボタンを返してみる
コード.gs
var CHANNEL_ACCESS_TOKEN = "TOKEN"; function doPost(e) { var contents = e.postData.contents; var obj = JSON.parse(contents); var events = obj["events"]; for (var i = 0; i < events.length; i++) { if (events[i].type == "message") { reply_message(events[i]); } } } function reply_message(e) { var postData = { "replyToken": e.replyToken, "messages": [{ "type": "flex", "altText": "this is a flex message", "contents": { "type": "bubble", "body": { "type": "box", "layout": "vertical", "spacing": "md", "contents": [ { "type": "text", "text": "hello" }, { "type": "button", "style": "primary", "action": { "type": "uri", "label": "Primary style button", "uri": "https://example.com" } } ] } } }] }; var options = { "method": "post", "headers": { "Content-Type": "application/json", "Authorization": "Bearer " + CHANNEL_ACCESS_TOKEN }, "payload": JSON.stringify(postData) }; UrlFetchApp.fetch("https://api.line.me/v2/bot/message/reply", options); } |
関連記事
参考
flex-messages
https://developers.line.me/ja/docs/messaging-api/message-types/#flex-messages
Flex Messageを使う
https://developers.line.me/ja/docs/messaging-api/using-flex-messages/
Flex Message
https://developers.line.me/ja/reference/messaging-api/#flex-message
Flex Messageの要素
https://developers.line.me/ja/docs/messaging-api/flex-message-elements/
Flex Messageのレイアウト
https://developers.line.me/ja/docs/messaging-api/flex-message-layout/
flex-messages
https://developers.line.me/ja/docs/messaging-api/message-types/#flex-messages
https://developers.line.me/ja/docs/messaging-api/using-flex-messages/
Flex Message
https://developers.line.me/ja/reference/messaging-api/#flex-message
Flex Messageの要素
https://developers.line.me/ja/docs/messaging-api/flex-message-elements/
Flex Messageのレイアウト
https://developers.line.me/ja/docs/messaging-api/flex-message-layout/