# Extract info from chatbot

**URL:** <https://discourse.nodered.org/t/extract-info-from-chatbot/61378>\
**Category:** General\
**Created:** [16 April 2022 23:52 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378 "2022-04-16T23:52:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [16 April 2022 23:52 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/1 "2022-04-16T23:52:59Z")

</div>

Hi everyone,

Need some help for extracting information that I'm receiving using Telegram with the chatbot.  
I need to send some words that will trigger what I need, in this case a a gate node.  
When I copy the path from the message content I receive the path os "payload.content", if I use that for a switch node, nothing is === to /toggle.  
What I'm doing wrong?

 ![telegram message](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/9/b9344be319e6b9aae3adf02f986af6b80e489a7a.jpeg)  
,

Thanks

Tete

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 07:42 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/2 "2022-04-17T07:42:15Z")

</div>

how have you set the switch node rule? did you select msg from the dropdown list, or did you leave it as A/Z?

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [17 April 2022 10:07 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/3 "2022-04-17T10:07:28Z")

</div>

Hi,

I'm using msg.

Tete

 ![switch mode](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/3/13b3fe8ddd9a1d79a8aa7788cd3340c83162db3f.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 10:23 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/4 "2022-04-17T10:23:41Z")

</div>

Please post your flow , so we can see what is happening.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [17 April 2022 13:22 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/5 "2022-04-17T13:22:17Z")

</div>

Sorry for the delay.  
This is the flow.  
[flows.json](https://discourse.nodered.org/uploads/short-url/6SkEHCqlBQWRkuJ9LYMnmbiaQ2H.json) (3.3 KB)

All the best,

Tete

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 13:46 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/6 "2022-04-17T13:46:27Z")

</div>

I see nothing wrong, are you sure the incoming message from the receiver node is outputting msg.payload.content? Could you capture the message in a debug using complete message setting, and use the copy value button to copy the complete message, and paste here in text format.

P.S. use the \</\> button to post the result.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [17 April 2022 15:49 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/7 "2022-04-17T15:49:08Z")

</div>

```auto
{"originalMessage":{"message_id":91,"from":{"id":785831859,"is_bot":false,"first_name":"TT","username":"tete","language_code":"en"},"chat":{"id":785831859,"first_name":"TT","username":"tete","type":"private"},"date":1650210291,"text":"/toggle","entities":[{"offset":0,"length":7,"type":"bot_command"}],"chatId":785831859,"userId":785831859,"messageId":91,"transport":"telegram","language":"en","ts":"2022-04-17T15:44:51.000Z"},"payload":{"type":"message","chatId":785831859,"userId":785831859,"ts":"2022-04-17T15:44:51.000Z","transport":"telegram","inbound":true,"content":"/toggle","arguments":[]},"_msgid":"2239b513712bafe1"}

```

The problem is that everything seems right, and I'm stuck in this, without any success in detecting the error.

Tete

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 16:08 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/8 "2022-04-17T16:08:31Z")

</div>

Everything is fine there to.  
Have you you tried deleting the flow and adding new nodes. Are all the nodes wired correctly? try moving nodes and check for bypass wires.  
I use node-red-contrib-telegrambot so unable to run your flow.  
Does the switch output to otherwise, as it should if the switch does not recognised "/toggle".

can you clear the debug and give the debug node a name, then show us a screenshot of the debug message including the time and name, just incase your crop removed some thing.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [17 April 2022 16:27 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/9 "2022-04-17T16:27:21Z")

</div>

Hi again,

This is with the node-red-contrib-telegrambot:

```auto
{"payload":{"chatId":785831859,"messageId":94,"type":"message","content":""},"originalMessage":{"message_id":94,"from":{"id":785831859,"is_bot":false,"first_name":"TT","username":"tete","language_code":"en"},"chat":{"id":785831859,"first_name":"TT","username":"tete","type":"private"},"date":1650212239,"text":"/toggle","entities":[{"offset":0,"length":7,"type":"bot_command"}]},"_msgid":"bccdc722e77afe84"}

```

the path for the switc is originalMessage.text, and this is the flow:

```auto
[{"id":"bfd968a9974ea2e3","type":"tab","label":"Flow 2","disabled":false,"info":"","env":[]},{"id":"c73331c92dd9e628","type":"telegram command","z":"bfd968a9974ea2e3","name":"/toggle","command":"/toggle","description":"","registercommand":false,"language":"","bot":"","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":170,"y":440,"wires":[["1536e074d67162f6","27f2863923cc7d38"]]},{"id":"1536e074d67162f6","type":"switch","z":"bfd968a9974ea2e3","name":"toggle, open, close","property":"originalMessage.text","propertyType":"msg","rules":[{"t":"eq","v":"/toggle","vt":"str"},{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"close","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":470,"y":440,"wires":[["4b91581b8d13357d"],["3d6e6e189586eb93"],["16e9f4a703e5eff0"],["d79b0546e6d370ce"]]},{"id":"3d6e6e189586eb93","type":"debug","z":"bfd968a9974ea2e3","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":400,"wires":[]},{"id":"16e9f4a703e5eff0","type":"debug","z":"bfd968a9974ea2e3","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":440,"wires":[]},{"id":"d79b0546e6d370ce","type":"debug","z":"bfd968a9974ea2e3","name":"4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":480,"wires":[]},{"id":"27f2863923cc7d38","type":"debug","z":"bfd968a9974ea2e3","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":290,"y":500,"wires":[]},{"id":"4b91581b8d13357d","type":"debug","z":"bfd968a9974ea2e3","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":750,"y":360,"wires":[]}]

```

 ![message](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/8664ec54ef858300177bb8c85ce369a2f0ff7ffe.jpeg)

/toggle is just the exemple, but I already tried "open", "close" and "toggle".

Tete

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 16:42 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/10 "2022-04-17T16:42:39Z")

</div>

That is working fine my end with telegrambot.  
as you can see in image

 ![Screenshot_20220417-174406](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/c/1ce0aac837e3cd69fb5327da5ef85c19fcd7963e.png)

I wanted to see the image from your chatbot telegram flow. Please could you try again with that telegram chatbot. As i suspect there is missing info not in original image.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [17 April 2022 16:58 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/11 "2022-04-17T16:58:48Z")

</div>

![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/95a1d06b4c7e873a64e710525da7c4b3ba7eea73.jpeg)

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [17 April 2022 17:13 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/12 "2022-04-17T17:13:12Z")

</div>

Did it output to otherwise? the image does not show two messages.  
if it did not then the issue is in the switch node. I would try deleting the flow and tab and start again.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [18 April 2022 07:31 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/13 "2022-04-18T07:31:25Z")

</div>

Hi,

Yes, it did output for the otherwise.  
I just installed a new raspberry with the node red (just in case), made everything from scratch and I still have the same problem.  
Can you please send your flow, just as last resort?

Tete

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [18 April 2022 07:35 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/14 "2022-04-18T07:35:58Z")

</div>

Can you also try. “contains” toggle ?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [18 April 2022 07:49 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/15 "2022-04-18T07:49:23Z")

</div>

Sure  
here is the command one

```auto
[{"id":"c73331c92dd9e628","type":"telegram command","z":"bf9e1e33.030598","name":"/toggle","command":"/toggle","description":"","registercommand":false,"language":"","bot":"125415a2.b4e0e2","strict":false,"hasresponse":false,"useregex":false,"removeregexcommand":false,"outputs":1,"x":120,"y":1260,"wires":[["1536e074d67162f6","27f2863923cc7d38"]]},{"id":"1536e074d67162f6","type":"switch","z":"bf9e1e33.030598","name":"toggle, open, close","property":"originalMessage.text","propertyType":"msg","rules":[{"t":"eq","v":"/toggle","vt":"str"},{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"close","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":420,"y":1260,"wires":[["4b91581b8d13357d"],["3d6e6e189586eb93"],["16e9f4a703e5eff0"],["d79b0546e6d370ce"]]},{"id":"27f2863923cc7d38","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":240,"y":1320,"wires":[]},{"id":"4b91581b8d13357d","type":"debug","z":"bf9e1e33.030598","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1180,"wires":[]},{"id":"3d6e6e189586eb93","type":"debug","z":"bf9e1e33.030598","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1220,"wires":[]},{"id":"16e9f4a703e5eff0","type":"debug","z":"bf9e1e33.030598","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1260,"wires":[]},{"id":"d79b0546e6d370ce","type":"debug","z":"bf9e1e33.030598","name":"4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1300,"wires":[]},{"id":"125415a2.b4e0e2","type":"telegram bot","botname":"mybot","usernames":"","chatids":"-1001361034082","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}]

```

and here is one with receiver node

```auto
[{"id":"924e655b.62c95","type":"telegram receiver","z":"bf9e1e33.030598","name":"","bot":"125415a2.b4e0e2","saveDataDir":"","filterCommands":false,"x":120,"y":1260,"wires":[["1536e074d67162f6","27f2863923cc7d38"],[]]},{"id":"1536e074d67162f6","type":"switch","z":"bf9e1e33.030598","name":"toggle, open, close","property":"originalMessage.text","propertyType":"msg","rules":[{"t":"eq","v":"/toggle","vt":"str"},{"t":"eq","v":"open","vt":"str"},{"t":"eq","v":"close","vt":"str"},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":420,"y":1260,"wires":[["4b91581b8d13357d"],["3d6e6e189586eb93"],["16e9f4a703e5eff0"],["d79b0546e6d370ce"]]},{"id":"27f2863923cc7d38","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":240,"y":1320,"wires":[]},{"id":"4b91581b8d13357d","type":"debug","z":"bf9e1e33.030598","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1180,"wires":[]},{"id":"3d6e6e189586eb93","type":"debug","z":"bf9e1e33.030598","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1220,"wires":[]},{"id":"16e9f4a703e5eff0","type":"debug","z":"bf9e1e33.030598","name":"3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1260,"wires":[]},{"id":"d79b0546e6d370ce","type":"debug","z":"bf9e1e33.030598","name":"4","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":700,"y":1300,"wires":[]},{"id":"125415a2.b4e0e2","type":"telegram bot","botname":"mybot","usernames":"","chatids":"-1001361034082","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}]

```

Both work and output two messages.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [19 April 2022 07:44 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/16 "2022-04-19T07:44:30Z")

</div>

Hi,

Using your flow and changing to the "contains" suggested by dceejay, the message with the "close" goes out in the second output, like you sent does not go out. So at least now I have an output to the right "gate", the problem now is that the output isn't "clean", so I can't activate the simple gate, with the commands, open, close and toggle.  
The message is like the one in the image.

Tete

 ![Screenshot_1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c7d14f40c521271d911b53cd42d7c5369ef1de03.jpeg)

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [19 April 2022 09:53 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/17 "2022-04-19T09:53:01Z")

</div>

Hi,

I just solved in a archaic form, but it's solved.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/b/2b64b33d4436aa7903221ec595e72b0005aaae7d.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/6/9670377c2c3949fed11f9422fc9d819b4c446368.png)  
Many thanks for all the help!

All the best,

Tete

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [10 May 2022 07:56 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/18 "2022-05-10T07:56:30Z")

</div>

Hi,

Now I have a problem with the switch node, it's getting bigger:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/5/953064484a5f12ee563774de3b32aa2d501d1631.png)  
Is there any alternative for this system? I know that in NR there is more than a option for the same problem, but this is the only one, that I know.

All the best,

Tete

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [10 May 2022 08:04 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/19 "2022-05-10T08:04:02Z")

</div>

It depends what you are doing with the result.

For example, if those last 6 HTTP requests perform something like `http://fixed-ip/variable_path` and `variable_path` is the value coming from telegram, then you can make the URL by adding `variable_path` to `http://fixed-ip/`

Also, you could restructure the commands to make the whole thing more dynamic. e.g. `/command door open` and `/command door close` then you can direct all `door` items to a single output that understands `open` and `close` and any future commands like, for example `status`.

---

<div class="post-metadata">

**Author:** ![geotete](https://avatars.discourse-cdn.com/v4/letter/g/76d3ee/32.png) [@geotete](https://discourse.nodered.org/u/geotete)\
**Post date:** [10 May 2022 08:10 UTC](https://discourse.nodered.org/t/extract-info-from-chatbot/61378/20 "2022-05-10T08:10:12Z")

</div>

Hi,

I have everything that I need in the Telegram, so there is a mix of items.  
For instance, this one is to close a gate in NR to stop receiving alerts of movement in a determinate sensor:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/d/fd925bbad5ea4a318d0a6965abf161103946ffd6.png)  
Then I have for the info about the WAN IP.  
5x HTTP request for CCTV  
and 1 to turn off a light.

Tete

[Next page](https://discourse.nodered.org/t/extract-info-from-chatbot/61378.md?page=2)
