Telegram - sending commands to trigger flows and questions

No offense to @Domoticon, but I had some difficulty following the tutorial myself so I took another approach to get this done. I can set this off by sending /al and the menus popup in telegram, after I make my choice the function node send the appropriate command HA. To secure it the telegram nodes allows me to restrict who can send a command. In addition, I have another node tied to telegram that sends me the status of the alarm each time I choose one of the option to ensure it went through.

[{"id":"34052197.65fc5e","type":"telegrambot-switch","z":"210599c3.81f106","name":"Alarm Choices","bot":"6cf9d125.c9a1f","chatId":"364959066","question":"What would you like to do with the alarm?","answers":["arm_home","arm_away","disarm"],"outputs":3,"autoAnswerCallback":true,"timeoutValue":"","timeoutUnits":"","x":620,"y":680,"wires":[["f8eef33e.406ab"],["566dbe0.a166644"],["ecf3dfbc.1d5f9"]]},{"id":"6b091eec.dc7aa","type":"telegrambot-command","z":"210599c3.81f106","bot":"6cf9d125.c9a1f","command":"/al","commandType":"str","commandCase":false,"x":430,"y":680,"wires":[["34052197.65fc5e"]]},{"id":"42a9b95.4d6dc48","type":"mqtt out","z":"210599c3.81f106","name":"Alarm out-put","topic":"","qos":"","retain":"","broker":"d22d2dd3.efb5","x":1000,"y":640,"wires":[]},{"id":"f8eef33e.406ab","type":"function","z":"210599c3.81f106","name":"Set Home Alarm","func":"var newMsg = {\"payload\":\"ARM_HOME\",\"topic\":\"home/alarm/set\"};\nreturn newMsg;\n","outputs":1,"noerr":0,"x":820,"y":640,"wires":[["42a9b95.4d6dc48","16dfde83.1b9a21"]]},{"id":"ea46fbd.096e508","type":"mqtt out","z":"210599c3.81f106","name":"Alarm out-put","topic":"","qos":"","retain":"","broker":"d22d2dd3.efb5","x":1000,"y":680,"wires":[]},{"id":"566dbe0.a166644","type":"function","z":"210599c3.81f106","name":"Set Away Alarm","func":"var newMsg = {\"payload\":\"ARM_AWAY\",\"topic\":\"home/alarm/set\"};\nreturn newMsg;\n","outputs":1,"noerr":0,"x":820,"y":680,"wires":[["ea46fbd.096e508","16dfde83.1b9a21"]]},{"id":"d332c82f.103f38","type":"mqtt out","z":"210599c3.81f106","name":"Alarm out-put","topic":"","qos":"","retain":"","broker":"d22d2dd3.efb5","x":1000,"y":720,"wires":[]},{"id":"ecf3dfbc.1d5f9","type":"function","z":"210599c3.81f106","name":"Disarm Alarm","func":"var newMsg = {\"payload\":\"DISARM 9999\",\"topic\":\"home/alarm/set\"};\nreturn newMsg;\n","outputs":1,"noerr":0,"x":820,"y":720,"wires":[["d332c82f.103f38","832e43c9.4a88a"]]},{"id":"16dfde83.1b9a21","type":"telegrambot-notify","z":"210599c3.81f106","name":"The alarm has been set","bot":"6cf9d125.c9a1f","chatId":"111111111","message":"The alarm has been set","parseMode":"","x":1210,"y":660,"wires":[]},{"id":"832e43c9.4a88a","type":"telegrambot-notify","z":"210599c3.81f106","name":"The alarm has been disarmed","bot":"6cf9d125.c9a1f","chatId":"111111111","message":"The alarm has been disarmed","parseMode":"","x":1230,"y":720,"wires":[]},{"id":"6cf9d125.c9a1f","type":"telegrambot-config","z":"","botname":"DoorSensorBot","usernames":"walkintothelight","chatIds":"111111111","pollInterval":"300"},{"id":"d22d2dd3.efb5","type":"mqtt-broker","z":"","name":"Win-Mosquitto","broker":"192.168.1.999","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

@commandcontrolit Do you have a screenshot of your nodes and wiring?

None taken :wink: If your approach is working, then it is okay. There are many road which leads to Rome.

Perfect!! I knew eventually someone much smarter than me could reverse engineer what was started here and and make it work.

I’ll give this a shot when I get hime, but it seems like you were trying to achieve exactly what I have been.

Edit: You’re also using the other node red package which seems to work a little easier.

It’s the same as yours. Same problem I described above.

I’m going to try what @William_Rodriguez shared and see how that works.

Thanks!

BTW, do you have an IP-camera?

Yes I do, if you were asking me

Do you have a command to get a snapshot from it?

Just an example (rearranged, with no exit to the loop) with just 2 options: 1 to show menu and one to get an snapshot from an IP-camera:

Maybe this example make it more clear?

  • The http request-node is to get a snapshot from the cam
  • The Waiting node shows a message in Telegram that an picture is being send while getting it from the cam.

Yes, though I never considered grabbing a snapshot from them in this way. My camera system is Ubiquiti, so I get all kinds of videos and stills based on motion, etc.

Okay, just consider the example as clarification then.

Just off-topic, does the Ubiquity Unifi Video system meets your demands?
I have build my complete network with Unifi products and I like it very well. I was looking at the Unifi Video range, but I was wondering if their camera’s can also be used outside, for example, and how do they do in practise.

Can you give me your opinion, please?

I’m using node-red-contrib-telegrambot-home.

Nice! Looks indeed more basic and could be easier to start with.

Yes - I am full UniFi and Unifi Video and I love it. Best solution I’ve chosen.

I would love to see them pull UniFi Video into the UniFi data interface. For single dashboard and software solution.

1 Like

Yep - I tried using it as well, but I couldn’t secure the messages/chat, so I gave up and went with the chatbot package.

1 - Is it possible to add none Unifi cams to the system?
2 - Is it integrated with the CloudKey or other Unifi network controller?

When you have answered these questions I will go on topic again. Promised :slightly_smiling_face:

So my setup didn’t work for you?

Hi @Domoticon

I know this is an old thread, my I’m approaching now Telegram Bots…

I’ve tried to do something similar, I hope, to a simple flow you showed in this thread.

Like this

The button node is defined like this

but when I send a /start command I get several time the button menu

and when I click /arm or /disarm I get several times the info in the debug nodes, like it was pressed several times.

On the Telegram Sender node I have marked Pass Through and Track

Any suggestion?

Thanks

try wiht saving ALL NODE, not only modified one.

1 Like

Thanks!

That worked, trying to understand why, I don’t have any other RedBot node in other flows…

Hello; thanks for all the infoirmation; would you know if it would be possible to add a wait for lets say 2 mins and if no action is selected to run a default action on its own?