Advertisement
xangin

HA simple webhook command

Apr 2nd, 2023 (edited)
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 1.41 KB | None | 0 0
  1. ###########################################################
  2. ##       Automation
  3. ###########################################################
  4. automation:
  5.   - id: line_webhook_cmds
  6.     alias: line_webhook_cmds
  7.     description: "Line下指令"
  8.     mode: single
  9.     trigger:
  10.       - platform: webhook
  11.         webhook_id: my_webhook_id #記得更換成自己的webhook_id
  12.     condition: []
  13.     action:
  14.       - choose:
  15.           - alias: "簡易回覆指令"
  16.             conditions:
  17.               - condition: template
  18.                 value_template: "{{ trigger.json.events.0.message.text == '測試' }}"
  19.             sequence:
  20.               - service: rest_command.linebot_reply
  21.                 data:
  22.                   reply_token: "{{ trigger.json.events.0.replyToken }}"
  23.                   msg_text: "你好!"
  24.  
  25.  
  26. ###########################################################
  27. ##       Rest command
  28. ###########################################################
  29. ## 利用reply token回覆純文字給使用者
  30. rest_command:
  31.   linebot_reply:  
  32.     url: 'https://api.line.me/v2/bot/message/reply'
  33.     method: POST
  34.     content_type: 'application/json'
  35.     headers:
  36.       Authorization: !secret linebot_token_rest
  37.     payload: '{
  38.         "replyToken": "{{ reply_token }}",
  39.         "messages":[
  40.             {
  41.                 "type":"text",
  42.                 "text":"{{ msg_text }}"
  43.             }
  44.         ]
  45.       }'
Tags: ha
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement