Home technology How to automatically forward, ‘Wikiquote: Quote of the day’ to your family/friends group using Node Red

How to automatically forward, ‘Wikiquote: Quote of the day’ to your family/friends group using Node Red

by satcit

Wikiquote is a free compendium of quotations that is being written collaboratively by numerous contributors from around the world.

Here is a Node Red flow to extract the ‘Wikiquote: Quote of the day’ and forward it to a telegram group. Of course, instead of a telegram group, it can be forwarded to any medium that is supported by Node Red.

Here is a flowchart showing the idea.

quote of the day (5)

Here is the Node Red flow. Import this flow to run the algorithm

[{"id":"81e125e.d8dc5d8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"4a8257407f2003f0","type":"inject","z":"81e125e.d8dc5d8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 13 * * *","once":false,"onceDelay":0.1,"topic":"","payloadType":"date","x":90,"y":1060,"wires":[["39f87d05ccfba003"]]},{"id":"39f87d05ccfba003","type":"function","z":"81e125e.d8dc5d8","name":"Quote of the day","func":"let d = new Date();\nconst months = [\"January\", \"February\", \"March\", \"April\", \"May\", \"June\", \"July\", \"August\", \"September\", \"October\", \"November\", \"December\"];\nlet month = months[d.getMonth()];\nlet today = `https://en.wikiquote.org/wiki/Wikiquote:Quote_of_the_day/${month}_${d.getDate()},_${d.getFullYear()}`;\nmsg = {payload : today, url : today }\nreturn msg","outputs":1,"noerr":0,"initialize":"","finalize":"","x":330,"y":1120,"wires":[["846c20a348320d74"]]},{"id":"846c20a348320d74","type":"http request","z":"81e125e.d8dc5d8","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"","tls":"","persist":false,"proxy":"","authType":"","x":600,"y":980,"wires":[["8a2fba6fe9a307ab"]]},{"id":"8a2fba6fe9a307ab","type":"html","z":"81e125e.d8dc5d8","name":"","property":"payload","outproperty":"payload","tag":".mw-parser-output","ret":"text","as":"single","x":790,"y":880,"wires":[["5bdd8292877a5113"]]},{"id":"5bdd8292877a5113","type":"change","z":"81e125e.d8dc5d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":900,"y":740,"wires":[["a7a51e8b6149e04c"]]},{"id":"a7a51e8b6149e04c","type":"function","z":"81e125e.d8dc5d8","name":"Unnamed function","func":"msg.payload= {\n    chatId: '********',\n    type: 'message',\n    content: msg.payload\n   \n}\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":930,"y":80,"wires":[["0a292a305198e0bf"]]},{"id":"0a292a305198e0bf","type":"telegram sender","z":"81e125e.d8dc5d8","name":"","bot":"","haserroroutput":false,"outputs":1,"x":970,"y":160,"wires":[[]]}]

Here is how the Node Red flow will look like after importing.

Screenshot from 2021-12-30 15-40-40

Leave a Comment