# Multiple topics in single functin node - how to parse

**URL:** <https://discourse.nodered.org/t/multiple-topics-in-single-functin-node-how-to-parse/68451>\
**Category:** General\
**Created:** [1 October 2022 13:48 UTC](https://discourse.nodered.org/t/multiple-topics-in-single-functin-node-how-to-parse/68451 "2022-10-01T13:48:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BIIINO](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/biiino/32/68507_2.png) [@BIIINO](https://discourse.nodered.org/u/BIIINO)\
**Post date:** [1 October 2022 13:48 UTC](https://discourse.nodered.org/t/multiple-topics-in-single-functin-node-how-to-parse/68451/1 "2022-10-01T13:48:32Z")

</div>

Hello good day

I would like to ask for your advice, I would need to process more msg.payload from several topics in 1 functional node and then publish it. I don't know how to parse it. I have multiple topics like mete/hum, meteo/temp, meteo/wind and each of them sending value by msg.payload. I need to catch these values and publish to domoticz/in in a single function node. Is that possible?

I have allready did somethinh like this, but it doesnt work

 ![obrázok](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/c/dc59d385b6e32c7e2d5cbb8b6d076023af25e8f2.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:** [1 October 2022 14:23 UTC](https://discourse.nodered.org/t/multiple-topics-in-single-functin-node-how-to-parse/68451/2 "2022-10-01T14:23:29Z")

</div>

Hi, welcome to the forum.

NB: Best to show code in a pre-formatted text block `</>` rather than an image. It makes it easier to read and for people to copy/change/paste.

So I assume that you are getting multiple messages, each with a different msg.topic? And you want to do different processing depending on the topic?

If that is so, something like this might be helpful:

```auto
switch (msg.topic) {
    case 'meteo/temp': {
        // ...
        break
    }

    case 'meteo/hum: {
        // ...
        break
    }

    default: {
        // If you want to handle an unknown topic, you can use this section
        break
    }
}

return msg

```

But take care reusing the input msg as output as you will need to ensure that you are doing things in the right order. If in doubt, create a new msg with `const msg2 = {}` and set everything on that then do `return msg2` at the end.

---

<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:** [30 November 2022 14:57 UTC](https://discourse.nodered.org/t/multiple-topics-in-single-functin-node-how-to-parse/68451/4 "2022-11-30T14:57:03Z")

</div>

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