Send Youtube videos notification to Telegram with persistence

Send Youtube videos notification to Telegram with persistence using BOT

This flow allows you to create a bot for Telegram to send notifications whenever a new video is posted.

Community nodes were used for the construction.

As for software, this bot has an integration with MongoDB to make the videos persist, ensuring that the same video is not sent twice as a message on Telegram.

Informations to change:

  • Youtube Channel ID in Youtube Feed node
  • Channel ID in Set message parameters node
  • Telegram Bot informations in Send Feed node (Token and name of bot)

Youtube serie about this flow (pt_BR): https://www.youtube.com/playlist?list=PLVwomQzHETUEMhaevgm6_QZ4pnaQHZRzr

[{"id":"645a5d24.e35fe4","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"456d4cd8.b7cb1c","type":"mongodb out","z":"645a5d24.e35fe4","mongodb":"543250cb.c3bf68","name":"","collection":"videos","payonly":false,"upsert":true,"multi":false,"operation":"update","x":1270,"y":220,"wires":[]},{"id":"122443ff.9338ec","type":"change","z":"645a5d24.e35fe4","name":"Set database query and save register","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1050,"y":160,"wires":[["456d4cd8.b7cb1c"]]},{"id":"61e44970.863de","type":"switch","z":"645a5d24.e35fe4","name":"Checks if the register existis in the db","property":"payload","propertyType":"msg","rules":[{"t":"null"}],"checkall":"true","repair":false,"outputs":1,"x":930,"y":100,"wires":[["122443ff.9338ec","37178dab.fc34b2"]]},{"id":"50e53ebf.679178","type":"mongodb2 in","z":"645a5d24.e35fe4","service":"_ext_","configNode":"44fc0d6f.e1e8f4","name":"Mongo DB dynamic operation","collection":"videos","operation":"findOne","x":610,"y":100,"wires":[["61e44970.863de"]]},{"id":"37178dab.fc34b2","type":"change","z":"645a5d24.e35fe4","name":"Set message parameters","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t   \"chatId\": 'CHANGE',\t   \"type\": 'message',\t   \"content\": '🎊 SAIU VÍDEO NOVO NO CANAL 🎊 \\n'\t   & msg.video.title\t   & '\\n'\t   & '📌 Assita: '\t   & msg.video.link\t   & '\\n'\t   & '\\n'\t   & '👍 Já aproveita e deixa o joinha e ativa o sininho 👍'\t}","tot":"jsonata"},{"t":"delete","p":"video","pt":"msg"},{"t":"delete","p":"query","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1010,"y":40,"wires":[["a56403e.60dd48","12e7cc6e.3db66c"]]},{"id":"86159df.e7e45e","type":"change","z":"645a5d24.e35fe4","name":"Set db query and values","rules":[{"t":"set","p":"query._id","pt":"msg","to":"article.guid","tot":"msg"},{"t":"set","p":"video.link","pt":"msg","to":"article.link","tot":"msg"},{"t":"set","p":"video.title","pt":"msg","to":"article.title","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\t    '_id': msg.query._id\t}","tot":"jsonata"},{"t":"delete","p":"article","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":100,"wires":[["50e53ebf.679178"]]},{"id":"a56403e.60dd48","type":"debug","z":"645a5d24.e35fe4","name":"debug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1210,"y":20,"wires":[]},{"id":"12e7cc6e.3db66c","type":"telegram sender","z":"645a5d24.e35fe4","name":"Send Feed","bot":"c78c15a8.5ca758","haserroroutput":false,"outputs":1,"x":1230,"y":60,"wires":[[]]},{"id":"aef2e550.7d0d18","type":"feedparse","z":"645a5d24.e35fe4","name":"Youtube Feed","url":"https://www.youtube.com/feeds/videos.xml?channel_id=CHANGE","interval":"10","x":110,"y":120,"wires":[["86159df.e7e45e"]]},{"id":"d28a3a1f.2cf4","type":"inject","z":"645a5d24.e35fe4","name":"Mock","props":[{"p":"article","v":"{\"title\":\"Como instalar TEMAS no UBUNTU 20.04 (Personalize ícones e aplicativos)\",\"description\":null,\"summary\":null,\"date\":\"2020-11-19T14:48:35.000Z\",\"pubdate\":\"2020-12-10T00:00:08.000Z\",\"pubDate\":\"2020-12-10T00:00:08.000Z\",\"link\":\"https://www.youtube.com/watch?v=wXRTBlLJZ7Y\",\"guid\":\"yt:video:1wHwciUikHsp\",\"author\":\"Roveeb\",\"comments\":null,\"origlink\":null,\"image\":{\"url\":\"https://i4.ytimg.com/vi/wXRTBlLJZ7Y/hqdefault.jpg\"},\"source\":{},\"categories\":[],\"enclosures\":[],\"atom:@\":{},\"atom:id\":{\"@\":{},\"#\":\"yt:video:wXRTBlLJZ7Y\"},\"yt:videoid\":{\"@\":{},\"#\":\"wXRTBlLJZ7Y\"},\"yt:channelid\":{\"@\":{},\"#\":\"UCSc4UgSe4WiRpnXS23ZrQvg\"},\"atom:title\":{\"@\":{},\"#\":\"Como instalar TEMAS no UBUNTU 20.04 (Personalize ícones e aplicativos)\"},\"atom:link\":{\"@\":{\"rel\":\"alternate\",\"href\":\"https://www.youtube.com/watch?v=wXRTBlLJZ7Y\"}},\"atom:author\":{\"@\":{},\"name\":{\"@\":{},\"#\":\"Roveeb\"},\"uri\":{\"@\":{},\"#\":\"https://www.youtube.com/channel/UCSc4UgSe4WiRpnXS23ZrQvg\"}},\"atom:published\":{\"@\":{},\"#\":\"2020-09-15T23:00:08+00:00\"},\"atom:updated\":{\"@\":{},\"#\":\"2020-11-19T14:48:35+00:00\"},\"media:group\":{\"@\":{},\"media:title\":{\"@\":{},\"#\":\"Como instalar TEMAS no UBUNTU 20.04 (Personalize ícones e aplicativos)\"},\"media:content\":{\"@\":{\"url\":\"https://www.youtube.com/v/wXRTBlLJZ7Y?version=3\",\"type\":\"application/x-shockwave-flash\",\"width\":\"640\",\"height\":\"390\"}},\"media:thumbnail\":{\"@\":{\"url\":\"https://i4.ytimg.com/vi/wXRTBlLJZ7Y/hqdefault.jpg\",\"width\":\"480\",\"height\":\"360\"}},\"media:description\":{\"@\":{},\"#\":\"Olá, nesse vídeo iremos aprender a como instalar temas e personalizar seu Ubuntu 20.04. No vídeo, aprendemos a instalar de duas maneiras, tanto temas para a área de trabalho (aplicativos) quanto temas de ícones. De quebra, ainda aprendemos a como trocar o cursor do mouse e deixar o Ubuntu a sua cara.\\n\\nSeja nosso apoiador: https://www.catarse.me/roveeb\\n\\nNavegação:\\n00:00 - Introdução\\n00:30 - Apresentação\\n01:51 - Gnome tweak tool\\n04:02 - Instalando temas via PPA\\n07:04 - Instalando temas de ícones e aplicativos sem PPA\\n07:50 - Instalando o tema QOGIR\\n14:20 - Final\\n\\nLinks citados no vídeo:\\n11 temas: https://itsubuntu.com/11-best-ubuntu-20-04-lts-themes-in-2020/\\nGnome-look: https://www.gnome-look.org/browse/cat/\\nTema Qogir: https://www.gnome-look.org/search/projectSearchText/qogir\\n\\nLinks úteis:\\nDiscord do nosso canal: https://discord.gg/WmpW72Y\\nNosso instagram: https://www.instagram.com/roveebsolutions/\\nNosso facebook: https://www.facebook.com/Roveeb-111773970628762\\nTwitch do Lucas (Stream d...\"},\"media:community\":{\"@\":{},\"media:starrating\":{\"@\":{\"count\":\"48\",\"average\":\"5.00\",\"min\":\"1\",\"max\":\"5\"}},\"media:statistics\":{\"@\":{\"views\":\"630\"}}}},\"meta\":{\"#ns\":[{\"xmlns:yt\":\"http://www.youtube.com/xml/schemas/2015\"},{\"xmlns:media\":\"http://search.yahoo.com/mrss/\"},{\"xmlns\":\"http://www.w3.org/2005/Atom\"}],\"@\":[{\"xmlns:yt\":\"http://www.youtube.com/xml/schemas/2015\"},{\"xmlns:media\":\"http://search.yahoo.com/mrss/\"},{\"xmlns\":\"http://www.w3.org/2005/Atom\"}],\"#xml\":{\"version\":\"1.0\",\"encoding\":\"UTF-8\"},\"#type\":\"atom\",\"#version\":\"1.0\",\"title\":\"Roveeb\",\"description\":null,\"date\":\"2020-03-07T16:40:21.000Z\",\"pubdate\":\"2020-03-07T16:40:21.000Z\",\"pubDate\":\"2020-03-07T16:40:21.000Z\",\"link\":\"https://www.youtube.com/channel/UCSc4UgSe4WiRpnXS23ZrQvg\",\"xmlurl\":\"http://www.youtube.com/feeds/videos.xml?channel_id=UCSc4UgSe4WiRpnXS23ZrQvg\",\"xmlUrl\":\"http://www.youtube.com/feeds/videos.xml?channel_id=UCSc4UgSe4WiRpnXS23ZrQvg\",\"author\":\"Roveeb\",\"language\":null,\"favicon\":null,\"copyright\":null,\"generator\":null,\"cloud\":{},\"image\":{},\"categories\":[],\"atom:@\":{\"xmlns:yt\":\"http://www.youtube.com/xml/schemas/2015\",\"xmlns:media\":\"http://search.yahoo.com/mrss/\",\"xmlns\":\"http://www.w3.org/2005/Atom\"},\"atom:link\":[{\"@\":{\"rel\":\"self\",\"href\":\"http://www.youtube.com/feeds/videos.xml?channel_id=UCSc4UgSe4WiRpnXS23ZrQvg\"}},{\"@\":{\"rel\":\"alternate\",\"href\":\"https://www.youtube.com/channel/UCSc4UgSe4WiRpnXS23ZrQvg\"}}],\"atom:id\":{\"@\":{},\"#\":\"yt:channel:UCSc4UgSe4WiRpnXS23ZrQvg\"},\"yt:channelid\":{\"@\":{},\"#\":\"UCSc4UgSe4WiRpnXS23ZrQvg\"},\"atom:title\":{\"@\":{},\"#\":\"Roveeb\"},\"atom:author\":{\"@\":{},\"name\":{\"@\":{},\"#\":\"Roveeb\"},\"uri\":{\"@\":{},\"#\":\"https://www.youtube.com/channel/UCSc4UgSe4WiRpnXS23ZrQvg\"}},\"atom:published\":{\"@\":{},\"#\":\"2020-03-07T16:40:21+00:00\"}},\"_msgid\":\"7be77299.47d64c\"}","vt":"json"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payloadType":"str","x":130,"y":80,"wires":[["86159df.e7e45e"]]},{"id":"543250cb.c3bf68","type":"mongodb","hostname":"127.0.0.1","topology":"direct","port":"27017","db":"youtube","name":"Youtube Database"},{"id":"44fc0d6f.e1e8f4","type":"mongodb2","uri":"mongodb://127.0.0.1:27017/youtube","name":"","options":"","parallelism":""},{"id":"c78c15a8.5ca758","type":"telegram bot","botname":"Change","usernames":"","chatids":"","baseapiurl":"","updatemode":"polling","pollinterval":"300","usesocks":false,"sockshost":"","socksport":"6667","socksusername":"anonymous","sockspassword":"","bothost":"","botpath":"","localbotport":"8443","publicbotport":"8443","privatekey":"","certificate":"","useselfsignedcertificate":false,"sslterminated":false,"verboselogging":false}]

Flow Info

Created 4 years, 7 months ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • change (x3)
  • debug (x1)
  • inject (x1)
  • switch (x1)
Other

Tags

  • telegram
  • bot
  • youtube
  • mongodb
  • persistence
  • feed
  • feedparser
  • mongodb2
  • telegramnode
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option