2020年8月31日 星期一

Introductory IoT

 http://cc.ee.ntu.edu.tw/~rbwu//pages/course.html#IoT_Intro

Introductory IoT

Last Update: 7 months ago

Lecture Info

  • Invited Teachers: 賴怡吉博士、李健榮博士、廖書漢博士
  • TA:趙汝晉

  • 期末報告資訊:

    • 時間:

Lecture Notes - 2018

Download Examples

MQTT發送的數據通過Node-RED創建的流程從MQTT通信消息轉換為LINE消息。

MQTT發送的數據通過Node-RED創建的流程從MQTT通信消息轉換為LINE消息。

 Node-RED , Line , MQTT 


參考來源 https://qiita.com/kmaepu/items/6711c127c2a0434d5d98













[{"id":"e650e7b0.c39ae8","type":"tab","label":"MQTT與Node-RED","disabled":false,"info":""},{"id":"3b836a0b.8ed016","type":"inject","z":"e650e7b0.c39ae8","name":"","topic":"","payload":"Hello","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":300,"wires":[["68813400.ac67dc","84138d0b.7d64a"]]},{"id":"bd044a6.39730b8","type":"inject","z":"e650e7b0.c39ae8","name":"","topic":"","payload":"開始您的腹肌訓練!我要你支持我!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":360,"wires":[["cd6e0953.5c6ca8"]]},{"id":"91c15743.930228","type":"inject","z":"e650e7b0.c39ae8","name":"","topic":"","payload":"我想我做了20次!誇獎我!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":420,"wires":[["b1952dda.729eb"]]},{"id":"94627113.a5326","type":"template","z":"e650e7b0.c39ae8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"從現在開始,我將開始肌肉訓練!\n這次支持您的腹肌!","output":"str","x":291,"y":63,"wires":[["68813400.ac67dc","84138d0b.7d64a"]]},{"id":"20006501.84109a","type":"template","z":"e650e7b0.c39ae8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"這次我做了{{payload}}次!\n謝謝你的努力!","output":"str","x":290,"y":120,"wires":[["68813400.ac67dc","84138d0b.7d64a"]]},{"id":"131bafc1.02d7b","type":"template","z":"e650e7b0.c39ae8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"達到{{payload}}次!","output":"str","x":290,"y":180,"wires":[["68813400.ac67dc","84138d0b.7d64a"]]},{"id":"fe70ce7c.f6261","type":"comment","z":"e650e7b0.c39ae8","name":"測試流程","info":"","x":120,"y":240,"wires":[]},{"id":"ffcee50d.2742e8","type":"comment","z":"e650e7b0.c39ae8","name":"通過MQTT與Node-RED 進行數據傳輸/接收","info":"","x":220,"y":20,"wires":[]},{"id":"ff251965.b65f28","type":"mqtt in","z":"e650e7b0.c39ae8","name":"/start","topic":"alex9ufo/IOT/MQTT_test/start","qos":"1","datatype":"auto","broker":"841df58d.ee5e98","x":110,"y":60,"wires":[["94627113.a5326"]]},{"id":"cd6e0953.5c6ca8","type":"mqtt out","z":"e650e7b0.c39ae8","name":"/start","topic":"alex9ufo/IOT/MQTT_test/start","qos":"1","retain":"false","broker":"841df58d.ee5e98","x":470,"y":360,"wires":[]},{"id":"ce743adb.d39768","type":"mqtt in","z":"e650e7b0.c39ae8","name":"/end","topic":"alex9ufo/IOT/MQTT_test/end","qos":"1","datatype":"auto","broker":"841df58d.ee5e98","x":110,"y":120,"wires":[["20006501.84109a"]]},{"id":"e4573e54.a1bd7","type":"mqtt in","z":"e650e7b0.c39ae8","name":"/count","topic":"alex9ufo/IOT/MQTT_test/count","qos":"1","datatype":"auto","broker":"841df58d.ee5e98","x":110,"y":180,"wires":[["131bafc1.02d7b"]]},{"id":"b1952dda.729eb","type":"mqtt out","z":"e650e7b0.c39ae8","name":"/end","topic":"alex9ufo/IOT/MQTT_test/end","qos":"1","retain":"false","broker":"841df58d.ee5e98","x":470,"y":420,"wires":[]},{"id":"68813400.ac67dc","type":"function","z":"e650e7b0.c39ae8","name":"Set Line  Notify API ","func":"msg.headers = {'content-type':'application/x-www-form-urlencoded','Authorization':'Bearer cEI4hx24xyopKGAArgZcKJNHE1V7KeeIi4Lzny3dDNO'};\nmsg.payload = {\"message\":msg.payload};\nreturn msg;","outputs":1,"noerr":0,"x":570,"y":140,"wires":[["fa76df59.8a107"]]},{"id":"fa76df59.8a107","type":"http request","z":"e650e7b0.c39ae8","name":"","method":"POST","ret":"txt","paytoqs":false,"url":"https://notify-api.line.me/api/notify","tls":"","persist":false,"proxy":"","authType":"","x":600,"y":200,"wires":[["d72767b0.3fa668"]]},{"id":"d72767b0.3fa668","type":"debug","z":"e650e7b0.c39ae8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":750,"y":200,"wires":[]},{"id":"84138d0b.7d64a","type":"function","z":"e650e7b0.c39ae8","name":"傳送信息 MQTT2","func":"// CHANNEL_ACCESS_TOKEN = 'Messaging API Token';\n// USER_ID ='使用者ID(不是Line ID)';\n//MQTT2\nCHANNEL_ACCESS_TOKEN = 'UOf9DXSFQxPaDHLPl9jbsqj2Jhf9StEiqqjgLpa8PzKPsWaTAVwIRCmGfHXTkkuctxI1KLs8tc9kLU6VsWvSkCiydI0GQzaI2KnT3e4t7f8OVzy7wuj43qW+Eynp3V+QXKQdk2rZfB1T33fnT7crhwdB04t89/1O/w1cDnyilFU=';\nUSER_ID = 'Ua212f6426d82a75d31dee884a6fdfa95f76'; \nmessage = {\n    type:'text',\n    text: msg.payload\n};\nheaders = {\n    'Content-Type': 'application/json; charset=UTF-8',\n    'Authorization': 'Bearer ' + CHANNEL_ACCESS_TOKEN,\n};\npayload = {\n    'to':  USER_ID,\n    'messages': [message]\n};\nmsg.headers = headers;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":650,"y":300,"wires":[["f7cde34f.82131","2e80e7cc.890338"]]},{"id":"f7cde34f.82131","type":"http request","z":"e650e7b0.c39ae8","name":"Messaging API 傳送","method":"POST","ret":"txt","paytoqs":false,"url":"https://api.line.me/v2/bot/message/push","tls":"","persist":false,"proxy":"","authType":"","x":680,"y":360,"wires":[["69a08235.940abc"]]},{"id":"69a08235.940abc","type":"debug","z":"e650e7b0.c39ae8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":870,"y":360,"wires":[]},{"id":"2e80e7cc.890338","type":"debug","z":"e650e7b0.c39ae8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":880,"y":300,"wires":[]},{"id":"841df58d.ee5e98","type":"mqtt-broker","z":"","name":"","broker":"broker.mqtt-dashboard.com","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"15","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

2020年8月30日 星期日

利用 Node-RED 結合 Line Bot,在匯率低於數值時自動傳送信息。

利用 Node-RED 結合 Line Bot,在匯率低於數值時自動傳送信息。

使用 Node-RED 從台灣銀行網站自動抓取日幣匯率,結合 Messaging API 可以做到當日幣匯率低於一個數值時自動發送信息到你的手機。



參考來源 https://blog.hanlee.co/node-red-line-bot-jpy-currency/






[{"id":"639381b4.decba","type":"inject","z":"2fe5a795.b44618","name":"","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":120,"wires":[["63a4a95.925ad58"]]},{"id":"63a4a95.925ad58","type":"http request","z":"2fe5a795.b44618","name":"","method":"GET","ret":"txt","url":"http://rate.bot.com.tw/xrt?Lang=zh-TW","tls":"","x":240,"y":120,"wires":[["38a8cc.2269c734"]]},{"id":"38a8cc.2269c734","type":"html","z":"2fe5a795.b44618","name":"filter","property":"payload","outproperty":"payload","tag":".rate-content-cash.text-right.print_hide","ret":"html","as":"single","x":370,"y":120,"wires":[["29ecf860.b24508","91e26219.6161e"]]},{"id":"29ecf860.b24508","type":"function","z":"2fe5a795.b44618","name":"Get JPY Currency 1","func":"var currency = 0.20;\n\nvar data = {\n    jpy: Number(msg.payload[15])\n}\n\nvar isLow =  flow.get('isLow') || false;\nmsg.payload = data\nif (data.jpy < currency && !isLow) {\n    isLow = true;\n    flow.set('isLow', isLow);\n    return msg;\n}\nif (data.jpy > currency && !isLow) {\n    isLow = false;\n    flow.set('isLow', isLow);\n    return msg;\n}","outputs":1,"noerr":0,"x":540,"y":120,"wires":[["8dc39773.503288"]]},{"id":"1d418e6a.0e52a2","type":"debug","z":"2fe5a795.b44618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":730,"y":60,"wires":[]},{"id":"8dc397w373.5403288","type":"function","z":"2fe45a795.b444618","name":"傳送信息","func":"//CHANNEL_ACCESS_TOKEN = 'Messaging API Token';\nCHANNEL_ACCESS_TOKEN = 'E2ElxCQeoDszSHF0N1TJsyytnnae+HF1XZ7334YVYj1RQcpjAT1oi2Fa24TScNbOz+q815fFVp4MuFW+UC4PsfKbvtc/o0OM6hchpxuQURZyvizGq+/cAz/TgCwJ9wQ4ebkQyEXEDzaYUZ/Dx3yaaBgwdB04t89/1O/w1cDnyilFU=';\nUSER_ID = 'Ua2f646d82a75d31dee884a6fdfa95f76'; //'使用者ID(不是Line ID)';\nmessage = {\n    type:'text',\n    text:'目前日圓匯率:'+msg.payload.jpy\n};\nheaders = {\n    'Content-Type': 'application/json; charset=UTF-8',\n    'Authorization': 'Bearer ' + CHANNEL_ACCESS_TOKEN,\n};\npayload = {\n    'to':  USER_ID,\n    'messages': [message]\n};\nmsg.headers = headers;\nmsg.payload = payload;\nreturn msg;","outputs":1,"noerr":0,"x":740,"y":160,"wires":[["ea9fccf4.509b4"]]},{"id":"ea9fccf4.509b4","type":"http request","z":"2fe5a795.b44618","name":"Messaging API 傳送","method":"POST","ret":"txt","paytoqs":false,"url":"https://api.line.me/v2/bot/message/push","tls":"","persist":false,"proxy":"","authType":"","x":580,"y":240,"wires":[["5c8619a1.7b35a8"]]},{"id":"a3af338a.4308","type":"http in","z":"2fe5a795.b44618","name":"Messaging API 接收","url":"/line_hook","method":"post","upload":false,"swaggerDoc":"","x":110,"y":320,"wires":[["3774c8fd.50b198"]]},{"id":"3774c8fd.50b198","type":"debug","z":"2fe5a795.b44618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":310,"y":320,"wires":[]},{"id":"69e3a5fb.06462c","type":"inject","z":"2fe5a795.b44618","name":"發送測試信息","topic":"","payload":"{\"jpy\":\"測試信息\"}","payloadType":"json","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":470,"y":160,"wires":[["8dc39773.503288"]]},{"id":"5c8619a1.7b35a8","type":"debug","z":"2fe5a795.b44618","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":580,"y":320,"wires":[]},{"id":"91e26219.6161e","type":"function","z":"2fe5a795.b44618","name":"GET JP Currency 2","func":"//var jp = msg.payload[15];\nvar data = {\n    jpy: Number(msg.payload[15])\n}\nvar date = new Date();\nmsg.payload = data\nvar h = date.getHours();\nvar m = date.getMinutes();\nvar s = date.getSeconds();\nif(h<10){\n    h = '0'+h;\n}\nif(m<10){\n    m = '0' + m;\n}\nif(s<10){\n    s = '0' + s;\n}\nmsg.payload = '(' + h + ':' + m + ':' + s + ')\\n'+\n'日幣匯率:' + data.jpy ;\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":60,"wires":[["1d418e6a.0e52a2"]]}]



PushMessage節點:使用LINE Messaging API發送消息的節點。

 PushMessage節點:使用LINE Messaging API發送消息的節點。

Push message Use with free plan Impossible  無法使用



參考來源  https://qiita.com/kmaepu/items/6711c127c2a0434d5d98

LINE Messaging API is an interface that can do various things from HTTP communication.
There are a wide variety of functions, but I think that the main work of LINE is to send messages to somebody, so I summarized the messages that can be sent using the API as follows.

nameOverviewUse with free plan
Push messageSend a message to users and groups. Common guyImpossible
Reply messageA message that responds to the reception of a message as a triggerYes
Multicast messageSend a message to multiple usersImpossible
Broadcast messageSend a message to all users who have friends registeredYes

In other words, it seems that you can't send a message to a specific person except for a reply in the free plan.


參考來源 https://qiita.com/kmaepu/items/6711c127c2a0434d5d98

inject節點:輸出固定短語。用於調試

debug節點:在調試日誌中顯示一條消息。用於調試

MQTT in節點:使用MQTT訂閱(接收)數據的節點

MQTT out節點:使用MQTT發布(發送)數據的節點。用於調試

template節點:將輸入數據應用於固定格式並輸出的節點

PushMessage節點:使用LINE Messaging API發送消息的節點。


概要

 この記事は2020年6月18日にIoTLTでプレゼンしたシステムの技術編です。技術要素を3つの記事に分けて書いています。今回は2つ目のNode-RED編です。

  1. M5Atomを使って、遠隔で嫁が筋トレを応援してくれるシステムを作ってみた
  2. Node-RED
  3. LINE Message

こちらがLTを行ったプレゼンスライドです。
https://speakerdeck.com/maepu/yuan-ge-dejia-nijin-torewoying-yuan-sitemorau

 最近、ストレスのせいか暴飲暴食で太ってしまいました。そこで痩せたいと思い、筋トレを始めました。しかし長続きせずということで、嫁に応援してもらおうと思いました。

 しかしながら、嫁は里帰り出産のため沖縄に...。

 ということで、遠隔で嫁が筋トレを応援してくれるシステムを作ってみました!

簡易的なシステム.jpg

こちらがのデモです。
https://www.youtube.com/watch?v=ufq9XtmmxMs

レシピ

開発環境

  • M5Atom Lite
  • Arduino IDE ver1.8.12
  • Node-RED ver1.0.4
  • Node.js v10.15.3

システム構成

 システム構成は次のようになっています。M5Atomのボタンを押したイベントが発生すると、MQTT通信でNode-REDにデータが送られます。MQTT通信をしている間に「Shiftr.io」というものがあります。これはMQTT通信を管理するサーバーです。無料で理想することができます。

 MQTTで送られてきたデータは、Node-REDで作成したフローによりMQTT通信のメッセージからLINE Messageに変換していてます。
 
 LINE botは使用したいグループLINEに招待して使います。筋トレが開始された時と、10回ごと、終了時にメッセージを送ります。

image.png

Node-RED

 MQTTで受けたメッセージをLINE Messageで送信するには、Node.jsのサーバーが必要となります。今回はコードを書きたくなかったのと、制作期間を短くする目的でビジュアルプログラミングツールの「Node-RED」を使用しました。

 Node-REDは処理ブロックをつなげていくことにより、Node.jsの処理を視覚的に作る事ができます。

 今回は次のフローとなっています。使用したノードは次の6種類です

  • injectノード:定型文を出力する。デバッグ用
  • debugノード:デバッグログにメッセージが表示される。デバッグ用
  • MQTT inノード:MQTTでデータをサブスクライブ(受け取る)ノード
  • MQTT outノード:MQTTでデータをパブリッシュ(送信する)ノード。デバッグ用
  • templateノード:入力されたデータを定型フォーマットに当てはめて出力するノード
  • PushMessageノード:LINE Messsaging APIを利用してメッセージ送信するノード。

image.png

このフローは、次のjsonファイルをNode-REDで読み込むと簡単に作る事ができます。

line.json
[{"id":"6c4fba82.317ca4","type":"tab","label":"フロー 1","disabled":false,"info":""},{"id":"9952729d.04df4","type":"PushMessage","z":"6c4fba82.317ca4","name":"","channelSecret":"5ecabb2029cc0419fc30d67c29e1abe8","channelAccessToken":"vMTHMcB1WdOoVGNxu8loF5yfpsPZQQOjAK4wuUfSLUdqi8Inqvlie3aXZmiYVYuWlB0WGItYce7rUGstlTf2GW3z7fu5eHYf7i2ErCuGXPpNWcUTv2GdT2Inl6H3TTYLqQzNY1eDb2QNNN67UXBcBQdB04t89/1O/w1cDnyilFU=","targetId":"U6ec107f4dac58cefe4e0b2b8af14ce4c","x":560,"y":260,"wires":[]},{"id":"a3cc0103.f5e7b","type":"inject","z":"6c4fba82.317ca4","name":"","topic":"","payload":"Hello","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":130,"y":480,"wires":[["9952729d.04df4"]]},{"id":"cc9751ec.45e6d","type":"inject","z":"6c4fba82.317ca4","name":"","topic":"","payload":"腹筋を始めたみたいだよ~。応援してほしいな!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":520,"wires":[["9952729d.04df4","3a63051b.817c5a"]]},{"id":"8e5177c2.85cfe8","type":"inject","z":"6c4fba82.317ca4","name":"","topic":"","payload":"今回は20回したみたい!褒めてあげて!","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":240,"y":560,"wires":[["9952729d.04df4","5fc686e3.303308"]]},{"id":"88751d95.ddc0d","type":"mqtt in","z":"6c4fba82.317ca4","name":"","topic":"/start","qos":"2","datatype":"auto","broker":"bb52bb64.521f38","x":110,"y":200,"wires":[["a3dcd94c.4d8378","55d68f9d.f4e8c"]]},{"id":"a3dcd94c.4d8378","type":"debug","z":"6c4fba82.317ca4","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":550,"y":400,"wires":[]},{"id":"14e2687f.829048","type":"mqtt in","z":"6c4fba82.317ca4","name":"","topic":"/end","qos":"2","datatype":"auto","broker":"bb52bb64.521f38","x":108,"y":264.0000057220459,"wires":[["a3dcd94c.4d8378","846f5959.b247d8"]]},{"id":"3a63051b.817c5a","type":"mqtt out","z":"6c4fba82.317ca4","name":"","topic":"/start","qos":"","retain":"","broker":"bb52bb64.521f38","x":530,"y":520,"wires":[]},{"id":"5fc686e3.303308","type":"mqtt out","z":"6c4fba82.317ca4","name":"","topic":"/end","qos":"","retain":"","broker":"bb52bb64.521f38","x":530,"y":580,"wires":[]},{"id":"55d68f9d.f4e8c","type":"template","z":"6c4fba82.317ca4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"これから筋トレ開始するよ~!\n今回は腹筋、応援してね!","output":"str","x":291,"y":198,"wires":[["9952729d.04df4"]]},{"id":"846f5959.b247d8","type":"template","z":"6c4fba82.317ca4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"今回は {{payload}} 回やったよ!\nお疲れさまでした~!","output":"str","x":296,"y":257,"wires":[["9952729d.04df4"]]},{"id":"77d79f4d.646b4","type":"mqtt in","z":"6c4fba82.317ca4","name":"","topic":"/count","qos":"2","datatype":"auto","broker":"bb52bb64.521f38","x":108,"y":336,"wires":[["128ac3c3.526d5c","a3dcd94c.4d8378"]]},{"id":"128ac3c3.526d5c","type":"template","z":"6c4fba82.317ca4","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":" {{payload}} 回に到達!","output":"str","x":299,"y":335,"wires":[["9952729d.04df4"]]},{"id":"1ce53c7.dc107c4","type":"comment","z":"6c4fba82.317ca4","name":"テスト用のフロー","info":"","x":150,"y":440,"wires":[]},{"id":"bb52bb64.521f38","type":"mqtt-broker","z":"","name":"","broker":"broker.shiftr.io","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

injectノード

image.png
ノード左のボタンを押すと、対応した文字列が出力されます。今回はMQTTの疎通を確認するのと、LINEへのメッセージ送信確認用に使用しています。

MQTT outノード

image.png
このノードも動作確認用に使用しています。injectノードから文字列を受けて、特定のMQTTブローカのトピックへデータを送信します。

設定は特に複雑な事はしておらず、MQTTのサーバー(URL,名前,パスワード)と接続先のトピック名のみです。

トピック名は、筋トレ開始時のメッセージを「/start」、終了時のメッセージを「/end」にしています。

MQTT inノード

image.png
このノードでMQTTブローカを経由してデータを受取っています。
今回はデータ種類によって異なる処理をするように、3つのトピックを用意してみました。

  • /start : 筋トレ開始時のデータ
  • /end :筋トレ終了時のデータ
  • count :筋トレ中の回数データ

 このノードも特に複雑な設定はしておらず、MQTTブローカとトピックのみです。

templateノード

image.png
このノードは入力されたデータを、定型フォーマットにして出力するノードです。

・MQTT inノード「/start」と接続したtemplateノードの内容:
image.png

・MQTT inノード「/end」と接続したtemplateノードの内容:
image.png

・MQTT inノード「/count」と接続したtemplateノードの内容:
image.png

PushMassegノード

image.png
このノードで、入力されたデータをLINE botからメッセージ送信するようにしています。

ここには使用するLINE botの情報などを入力します。ここの解説はLINEの説明で行います。



Introduction

LINE Messaging API is an interface that can do various things from HTTP communication.
There are a wide variety of functions, but I think that the main work of LINE is to send messages to somebody, so I summarized the messages that can be sent using the API as follows.

nameOverviewUse with free plan
Push messageSend a message to users and groups. Common guyImpossible
Reply messageA message that responds to the reception of a message as a triggerYes
Multicast messageSend a message to multiple usersImpossible
Broadcast messageSend a message to all users who have friends registeredYes

In other words, it seems that you can't send a message to a specific person except for a reply in the free plan.

What to do this time

Send a broadcast message from Node-RED.
As mentioned above, the simplest thing to do is that the free plan does not allow you to send to a specific person.

LINE Messaging API specifications (quoted)

You can use the Messaging API to exchange data between your bot server and the LINE platform. The request is sent in JSON format using HTTPS.

The user sends a message to the LINE official account.
Webhook events are sent from the LINE platform to the bot server's webhook URL.
The bot server responds to the user via the LINE platform in response to a webhook event.

HTTPS is required.
Naturally speaking from recent security trends.

Mechanism and procedure

According to the LINE official reference , it seems that you can send a POST request to a fixed endpoint.
Therefore, the flow is as follows.

Sketch.png

It is very easy to see only the flow configuration. I will explain one by one.

  • Inject node It is
    just a firing point. The payload will be deleted after this so it doesn't matter.
  • Change node
    Sketch.png

    1. Value substitution
      Content-type=json is specified in the request header. It's a fixed phrase.
    2. Value substitution
      access token. Substitute the value that is updated regularly in
      the first time .
    3. Delete value
      Initializing the contents of payload.
    4. Assigning value Creating
      request body. Specify in an array of messages object. It looks like you can send some messages at the same time.
      In the case of a text message, the messages object consists of the type property and text property. It seems that the stamp is delayed by specifying the type property.
    5. Value assignment
      Request body. Specify what to send. This time I am trying to send the contents entered in the dashboard as I introduced in the previous time, so I brought it from the global variable.
      Let's change it according to the purpose.
  • http request node
    Sketch.png

    • Method
      POST method.

    • Specifies the endpoint for URL broadcast messages.
    • Output format
      Specify with a JSON object.

This time I'm sending it so I haven't received the response to the request.
If you want to handle exceptions, please accept the request.

Messaging API作為替代方案

  LINE超好用功能要沒了!LINE Notify明年3月底終止服務,有什麼替代方案? LINE Notify將於2025年3月31日結束服務,官方建議改用Messaging API作為替代方案。 //CHANNEL_ACCESS_TOKEN = 'Messaging ...