# Using Node-RED to read from Telegram bot

**URL:** <https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506>\
**Category:** General\
**Created:** [21 December 2021 04:19 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506 "2021-12-21T04:19:24Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [21 December 2021 04:19 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/1 "2021-12-21T04:19:24Z")

</div>

Looking for some guidance, i installed the telegram node and i can see the message payload and view new messages as they come in.

how do i look within the message payload and look for #ERROR or #CLOSED then based on the condition call an appropriate service to run.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/4/a4acac6730ebdc950a088e497299e1c67f65dc2a.png)

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [21 December 2021 06:49 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/2 "2021-12-21T06:49:46Z")

</div>

Figured i should be using a Switch Node and i tried setting conditions that contains text "test" but the debug doesnt show it exit the switch node...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1ab15703113f75747b1062893447272a6d210d27.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 December 2021 06:52 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/3 "2021-12-21T06:52:11Z")

</div>

Did you try it without the quotes ?

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [21 December 2021 06:55 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/4 "2021-12-21T06:55:30Z")

</div>

yes i did ....i tried with and without ...

The node that i am using is the Receiver Node that points to my telegram bot...and that seems to work and i can see the debug message show the entire message

adding the simple flow that i am using

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a8743d5b6b38570217266f49756ff90dce1f7140.png)

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 December 2021 06:58 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/5 "2021-12-21T06:58:51Z")

</div>

Checking for text is without quotes.

Could you rephrase your question ?

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [21 December 2021 07:02 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/6 "2021-12-21T07:02:53Z")

</div>

So i have this Telegram Bot that writes lots of messages of its activities.

I am looking for specific messages that has withing the body "#ERROR" or "#COMPLETED" so that i can build an automation activity that lets me know either things are working well or do i need to go to my VPS to restart the BOT.

Hence i am using the nodered integration to read the messages then based on the TEXT found perform various home automation tasks.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 December 2021 07:05 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/7 "2021-12-21T07:05:27Z")

</div>

The switch node does exactly this, did you try it ?

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [21 December 2021 07:07 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/8 "2021-12-21T07:07:51Z")

</div>

For some reason....like i had in my earlier screenshot...when i typed test into the bot chat i can see the debug message exit the Receiver Node

but no debug message after the Switch Node.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [21 December 2021 07:22 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/9 "2021-12-21T07:22:02Z")

</div>

Ah i looked over it. In the switch node, instead of `msg.payload`, use `msg.payload.content`

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [22 December 2021 15:43 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/10 "2021-12-22T15:43:13Z")

</div>

Weird this message did not get sent out!

so yes that did work! however here is something interesting, when i Type "Test", it is picked up by NodeRed and the conditions are met.

however, when the Bot is the one that is posting into the Chat, NodeRed does not pick it up because i am guessing Telegram Bot messages are not msg.payload.content.....but something else....

Any thoughts?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 December 2021 18:09 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/11 "2021-12-22T18:09:48Z")

</div>

> [@damon](#):
>
> Any thoughts?

That's what the debug node is for. Just set it to show the whole msg.

If it isn't coming in, it will most likely because you are trying to connect two bots and that doesn't work because otherwise you would be able to do a DOS attack on Telegram by creating a bot loop.

---

<div class="post-metadata">

**Author:** ![damon](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/damon/32/53120_2.png) [@damon](https://discourse.nodered.org/u/damon)\
**Post date:** [23 December 2021 04:31 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/12 "2021-12-23T04:31:30Z")

</div>

just clarifying ...and im a little new with this tool

Within the debug node, it forces me to at min have msg.payload and this comes up blank whenever the bot is the one that posts the message. if i type it works.

So my trading bot is what posts the messages..and its verbrose so i wanted to build an automation to pick up specifc trade closes...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb6b4605f3fcc7fb171ccd7be69ff834cca3afa7.png)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 December 2021 09:13 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/13 "2021-12-23T09:13:27Z")

</div>

Click on the dropdown for the output and you will see that you can choose to output the whole msg instead of just one property of it. 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [21 February 2022 09:13 UTC](https://discourse.nodered.org/t/using-node-red-to-read-from-telegram-bot/55506/14 "2022-02-21T09:13:29Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
