Daily Motivational Telegram Message
What it does
This flow uses a http GET request at 11am daily to get a random quote from https://type.fit/api/quotes.
The quote is displayed on the NodeRED dashboard as well as sent to phone via the Telegram Bot
What Needs Modified for you to run
- The Telegram Sender Node needs to have the BOT configuration field filled in
- Your ChatID needs to be set in the Change Node
- Your Group needs to be set in the Dashboard Text Node
Contact
Alex Trostle - GitHub - Email - LinkedIn - Instagram - My Website
Check out my NodeRED template for creating your own flows: https://gist.github.com/Alextros00/57903819eef31f4beaa4cd24c9d57865
[{"id":"877abdbd.80d6e","type":"comment","z":"f0403142.05187","g":"cbea36fe.113488","name":"Use an API to disply a motivational quote to the motivation tab","info":"","x":320,"y":2900,"wires":[]},{"id":"f04fd779.cea4c8","type":"inject","z":"f0403142.05187","g":"cbea36fe.113488","name":"At 11:00am","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 11 * * *","once":false,"onceDelay":"","topic":"","payload":"","payloadType":"date","x":170,"y":2940,"wires":[["b031a18e.59b03"]]},{"id":"b031a18e.59b03","type":"http request","z":"f0403142.05187","g":"cbea36fe.113488","name":"","method":"GET","ret":"obj","paytoqs":"ignore","url":"https://type.fit/api/quotes","tls":"","persist":false,"proxy":"","authType":"","x":330,"y":2940,"wires":[["e6a4d14d.ce6a8"]]},{"id":"e6a4d14d.ce6a8","type":"function","z":"f0403142.05187","g":"cbea36fe.113488","name":"","func":"msg.payload = msg.payload[getRndInteger(0,1642)];\nreturn msg;\n\n// this code gets a random interger\nfunction getRndInteger(min, max) {\n return Math.floor(Math.random() * (max - min + 1) ) + min;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":480,"y":2940,"wires":[["94bfd95f.2c89a8","88378938.731448"]]},{"id":"94bfd95f.2c89a8","type":"ui_text","z":"f0403142.05187","g":"cbea36fe.113488","group":"cbe50c39.f38f1","order":1,"width":6,"height":3,"name":"Daily Quote from https://type.fit/api/quotes","label":"text","format":"{{msg.payload.text}}","layout":"col-center","x":740,"y":2940,"wires":[]},{"id":"88378938.731448","type":"change","z":"f0403142.05187","g":"cbea36fe.113488","name":"set","rules":[{"t":"delete","p":"_msgid","pt":"msg"},{"t":"move","p":"payload.text","pt":"msg","to":"payload.content","tot":"msg"},{"t":"delete","p":"payload.author","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"delete","p":"statusCode","pt":"msg"},{"t":"delete","p":"headers","pt":"msg"},{"t":"delete","p":"responseUrl","pt":"msg"},{"t":"delete","p":"redirectList","pt":"msg"},{"t":"delete","p":"responseCookies","pt":"msg"},{"t":"set","p":"payload.chatId","pt":"msg","to":"","tot":"str"},{"t":"set","p":"payload.type","pt":"msg","to":"message","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":2900,"wires":[["fdd86dc2.a28f2"]]},{"id":"fdd86dc2.a28f2","type":"telegram sender","z":"f0403142.05187","g":"cbea36fe.113488","name":"","bot":"","haserroroutput":false,"outputs":1,"x":810,"y":2900,"wires":[[]]},{"id":"cbe50c39.f38f1","type":"ui_group","z":"","name":"Quote","tab":"27a5131.81170ec","order":2,"disp":true,"width":6,"collapse":false},{"id":"27a5131.81170ec","type":"ui_tab","z":"","name":"Motivation","icon":"dashboard","disabled":false,"hidden":false}]