# How to send messages by telegram when a condition is met

**URL:** <https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981>\
**Category:** General\
**Tags:** telegram\
**Created:** [12 July 2022 05:13 UTC](https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981 "2022-07-12T05:13:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Surfb](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Surfb](https://discourse.nodered.org/u/Surfb)\
**Post date:** [12 July 2022 05:13 UTC](https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981/1 "2022-07-12T05:13:05Z")

</div>

hello guys I have this project, but I want to add a function that sends me a message by telegram when the capacity is full I'm a newbie in this I hope you can help me

 ![Captura de pantalla 2022-07-11 225520](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/d/dd0e19ca36c902f740b7db91ab63e77874d1b86c.png)

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [12 July 2022 05:36 UTC](https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981/2 "2022-07-12T05:36:17Z")

</div>

Hello and welcome to the forum.

The contents of your function node looks fine to me. One thing I would do is change the test to \>=5, otherwise it will only send a message when the capacity is **exactly** 5.

Have you tried a simple test-flow with an Inject node, your function and the Telegram sender node?

This is my test flow - that works fine on my Raspberry Pi.

 ![node-red-answer_B](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bb9eabb7226b869c914a5c6a7680d201d1e6e831.png)

I don't know if the chatId you show is your actual chatId. If it is I suggest you edit it or remove it, otherwise people could send you spurious messages. I'm using a global for my chatId in the function node.

 ![node-red-answer_A](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/9/494726b36e9410e282522029b6e5d982198f9f6d.png)

I've also introduced a 'Rate Limit' (an option in the delay node) as I'm sure your next question (once you get your flow working) will be "I only want to send a single message, not loads of messages".

![node-red-answer_C](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/0/60eb045bfdc5500fd659b55bc32a895b99077317.png)

Hope this helps you get your flow working.

---

<div class="post-metadata">

**Author:** ![Surfb](https://avatars.discourse-cdn.com/v4/letter/s/4af34b/32.png) [@Surfb](https://discourse.nodered.org/u/Surfb)\
**Post date:** [12 July 2022 19:30 UTC](https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981/3 "2022-07-12T19:30:09Z")

</div>

thank you very much for your help, it works fine

---

<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:** [26 July 2022 19:30 UTC](https://discourse.nodered.org/t/how-to-send-messages-by-telegram-when-a-condition-is-met/64981/4 "2022-07-26T19:30:36Z")

</div>

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