Advertisement
xangin

line flex message sample

Oct 8th, 2024 (edited)
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.82 KB | None | 0 0
  1. rest_command:
  2.   linebot_flex_info: #改成你要的名字,呼叫就是rest_command.linebot_flex_info
  3.     url: 'https://api.line.me/v2/bot/message/reply' #reply要有reply token,主動發就改push
  4.     method: POST
  5.     content_type: 'application/json'
  6.     headers:
  7.       Authorization: !secret linebot_token_rest #就是"Bearer xxxx"
  8.     #記得下面任何地方都不能在後面加註解!!
  9.     #架構分解:
  10.     #payload: '{
  11.     #    "replyToken": "{{ reply_token }}", #要主動發把這行改為 "to": "group_id or user_id",
  12.     #    "messages":[
  13.     #        {
  14.     #          "type": "flex",
  15.     #          "altText": "Flex message",
  16.     #          "contents":
  17.     #          JSON貼這
  18.     #        
  19.     #       } //messages結尾
  20.     #     ] //messages結尾
  21.     #   }'//payload結尾
  22.              
  23.     payload: '{
  24.         "replyToken": "{{ reply_token }}",
  25.         "messages":
  26.         [
  27.             {
  28.               "type": "flex",
  29.               "altText": "Flex message",
  30.               "contents":
  31.                 {
  32.                   "type": "bubble",
  33.                   "hero": {
  34.                     "type": "image",
  35.                     "url": "https://developers-resource.landpress.line.me/fx/img/01_1_cafe.png",
  36.                     "size": "full",
  37.                     "aspectRatio": "20:13",
  38.                     "aspectMode": "cover",
  39.                     "action": {
  40.                       "type": "uri",
  41.                       "uri": "https://line.me/"
  42.                     }
  43.                   },
  44.                   "body": {
  45.                     "type": "box",
  46.                     "layout": "vertical",
  47.                     "contents": [
  48.                       {
  49.                         "type": "text",
  50.                         "text": "地震通知",
  51.                         "weight": "bold",
  52.                         "size": "xl"
  53.                       },
  54.                       {
  55.                         "type": "box",
  56.                         "layout": "vertical",
  57.                         "margin": "lg",
  58.                         "spacing": "sm",
  59.                         "contents": [
  60.                           {
  61.                             "type": "box",
  62.                             "layout": "baseline",
  63.                             "spacing": "sm",
  64.                             "contents": [
  65.                               {
  66.                                 "type": "text",
  67.                                 "text": "A級地震將在A秒後抵達",
  68.                                 "wrap": true,
  69.                                 "color": "#666666",
  70.                                 "size": "sm",
  71.                                 "flex": 5
  72.                               }
  73.                             ]
  74.                           }
  75.                         ]
  76.                       }
  77.                     ]
  78.                   }
  79.                 }
  80.           }
  81.         ]
  82.      }'    
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement