# Display output message

**URL:** <https://discourse.nodered.org/t/display-output-message/8529>\
**Category:** General\
**Created:** [2 March 2019 14:09 UTC](https://discourse.nodered.org/t/display-output-message/8529 "2019-03-02T14:09:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 14:09 UTC](https://discourse.nodered.org/t/display-output-message/8529/1 "2019-03-02T14:09:59Z")

</div>

Hi everyone. I'm trying to show the output from two inputs (facial expressions). These two inputs will have different values from 0-100. Thus, I use the **switch node** to differentiate if it is larger than 80 or not and then use the **change node** to display the message. The **two** change nodes will be joined together using the **join node**. I'm trying to write a function to have a more specific output message because I'll get the two messages displayed at the same time and this is not the result that I wish to be.

```auto
[{"id":"46664e94.9cfaa","type":"function","z":"73f9235a.d2b04c","name":"Yes - Threshold 1","func":"var spoken = context.get('spoken') || false;\nvar threshold = 1;\nvar outString = \"yes\";\nvar outMsg = {payload: \"\", text : outString};\n\nif (!spoken) {\n if (msg.payload >= threshold) {\n outMsg.payload = outString;\n spoken = true;\n }\n}\n\nif (msg.payload < threshold) {\n spoken = false;\n outMsg.text = \"\";\n}\n\nconsole.log(outMsg);\n\ncontext.set('spoken', spoken);\nreturn outMsg;","outputs":1,"noerr":0,"x":1110,"y":320,"wires":[["415b7191.b59c7","90c71e.1b52b8e"]]}]

```

However, nothing is displayed in the debug message. Can anyone tell me where is my error? Thank you.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 14:44 UTC](https://discourse.nodered.org/t/display-output-message/8529/2 "2019-03-02T14:44:27Z")

</div>

> [@Sin](#):
>
> nothing is displayed in the debug message.

Do you mean no debug message is displayed, or the debug message is displayed but the contents are not as you expect?

If the latter then you can use `node.warn()` to show what is happening in your function. For example you can put code like

```auto
node.warn("spoken is " + spoken);

```

after your context.get line in order to check what it is. The warn message will be displayed in the debug pane. Similarly you can put warns inside the if statements to show where it is going. That way you should be able to home in on what is going wrong.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 14:51 UTC](https://discourse.nodered.org/t/display-output-message/8529/3 "2019-03-02T14:51:46Z")

</div>

> [@Colin](#):
>
> Do you mean no debug message is displayed, or the debug message is displayed but the contents are not as you expect?

Sorry, is my fault. What my mean is no any debug message is display.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 15:09 UTC](https://discourse.nodered.org/t/display-output-message/8529/4 "2019-03-02T15:09:41Z")

</div>

> [@Sin](#):
>
> What my mean is no any debug message is display.

In that case I think you are not triggering it with anything. Check that you are actually sending it a message.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 15:30 UTC](https://discourse.nodered.org/t/display-output-message/8529/5 "2019-03-02T15:30:57Z")

</div>

> [@Colin](#):
>
> In that case I think you are not triggering it with anything. Check that you are actually sending it a message.

I've tried to connect the outputs of the facial expressions to two debug outputs separately. It displayed something so I think it should not be a problem.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/9/951a52bc0bedcc9e7fef1832a3bfc286e1ef24f1.png)  
Is my coding looks fine?

```auto
if (msg.payload.clench = 0) {
    msg.payload = "clench signal";
}
else if (msg.payload.frown = 0) {
    msg.payload = "frown signal";
}
else {
    return null;
}
return msg;

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 15:38 UTC](https://discourse.nodered.org/t/display-output-message/8529/6 "2019-03-02T15:38:54Z")

</div>

Put a debug showing the input to the function node and check that.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 15:59 UTC](https://discourse.nodered.org/t/display-output-message/8529/7 "2019-03-02T15:59:29Z")

</div>

I've put a debug in front of the function node and there are no displayed message for the two debugs.  
Or should I add a change node after the switch node?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 16:12 UTC](https://discourse.nodered.org/t/display-output-message/8529/8 "2019-03-02T16:12:37Z")

</div>

Post the flow of the join node so we can see how it is configured.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 16:15 UTC](https://discourse.nodered.org/t/display-output-message/8529/9 "2019-03-02T16:15:34Z")

</div>

```auto
[{"id":"dca53734.67db58","type":"join","z":"8c77fcbd.3d439","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1370,"y":360,"wires":[["2bc7253e.f0811a","fa81abe6.1c95d8"]]}]

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 16:20 UTC](https://discourse.nodered.org/t/display-output-message/8529/10 "2019-03-02T16:20:13Z")

</div>

Have you checked what the nodes before the join are passing on?  
Also have you set different topics on the two input messages?  
I don't know whether you mean it but as you have it the join node will not pass on anything until it has messages from both paths (assuming you have set topics) and then will not send another till it gets another message from each path. If you want it to wait till one from each has been received but then send whenever either of them comes in then select the box 'and every subsequent message'.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 16:43 UTC](https://discourse.nodered.org/t/display-output-message/8529/11 "2019-03-02T16:43:00Z")

</div>

Still trying to fully understand what you are trying to do. I don't understand why you need the Join node at all. The purpose of the Join node is to combine messages on different paths into one message containing the data from both paths at the same time. If you only care about the last message from either path then you don't need the Join node at all.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 16:52 UTC](https://discourse.nodered.org/t/display-output-message/8529/12 "2019-03-02T16:52:38Z")

</div>

> [@Colin](#):
>
> I don't understand why you need the Join node at all.

This is because someone suggest me to use the join node before and I thought it can used for the separate message. Another reason is I realised when there is two paths in the flow, it will only run the second path when I run the flow, the first path is always be ignored. The two paths will be run when I put the join node. (I need to run the both paths so I know which facial expressions is being made)

Then can I just directly connect the change node with the function node?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 17:06 UTC](https://discourse.nodered.org/t/display-output-message/8529/13 "2019-03-02T17:06:46Z")

</div>

If you need the data from both paths combined then you need the Join node, but you have to give the messages topics (if they don't already) so you can distinguish the data from the two paths.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 17:18 UTC](https://discourse.nodered.org/t/display-output-message/8529/14 "2019-03-02T17:18:09Z")

</div>

I don't need the data from both paths combined. I just want to know which path is running and the message in the respective path will be displayed in the debug. i just afraid the first path of the flow will not be run when I didn't use the join node.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 17:20 UTC](https://discourse.nodered.org/t/display-output-message/8529/15 "2019-03-02T17:20:10Z")

</div>

Do you just need the latest message to come out of either path? If so then just feed them both into a function node.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 17:23 UTC](https://discourse.nodered.org/t/display-output-message/8529/16 "2019-03-02T17:23:44Z")

</div>

> [@Colin](#):
>
> Do you just need the latest message to come out of either path? If so then just feed them both into a function node.

Just connect the change node with the function node right?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 17:28 UTC](https://discourse.nodered.org/t/display-output-message/8529/17 "2019-03-02T17:28:00Z")

</div>

Yes. I don't know whether you need the Change nodes, I don't think you have posted them.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 17:28 UTC](https://discourse.nodered.org/t/display-output-message/8529/18 "2019-03-02T17:28:35Z")

</div>

Okay, I'll try it and see whether I need the change node or not.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [2 March 2019 17:29 UTC](https://discourse.nodered.org/t/display-output-message/8529/19 "2019-03-02T17:29:35Z")

</div>

I assume you are doing something to identify the different paths, in which case yes you do need them.

---

<div class="post-metadata">

**Author:** ![Sin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/sin/32/6104_2.png) [@Sin](https://discourse.nodered.org/u/Sin)\
**Post date:** [2 March 2019 17:38 UTC](https://discourse.nodered.org/t/display-output-message/8529/20 "2019-03-02T17:38:53Z")

</div>

Yes, i need to identify the path and display the message.

```auto
[{"id":"8c77fcbd.3d439","type":"tab","label":"Flow 6","disabled":false,"info":""},{"id":"b4f62510.3688e8","type":"EMOTIV","z":"8c77fcbd.3d439","name":"EMOTIV","x":400,"y":340,"wires":[["78519482.28511c"]]},{"id":"78519482.28511c","type":"Profile-Name","z":"8c77fcbd.3d439","name":"Profile Name","profileName":"new","x":590,"y":340,"wires":[["686c6c7e.3f1bc4","2eeb385e.ad4418"]]},{"id":"7854bb6a.6e8494","type":"debug","z":"8c77fcbd.3d439","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":1730,"y":320,"wires":[]},{"id":"2eeb385e.ad4418","type":"Facial-Expression","z":"8c77fcbd.3d439","name":"Facial Expressions","action":"clench","sens":"800","x":900,"y":280,"wires":[["f5cafe90.b61bf"]]},{"id":"686c6c7e.3f1bc4","type":"Facial-Expression","z":"8c77fcbd.3d439","name":"Facial Expressions","action":"frown","sens":"800","x":890,"y":460,"wires":[["e9fe3385.89298"]]},{"id":"2bc7253e.f0811a","type":"function","z":"8c77fcbd.3d439","name":"","func":"if (msg.payload.clench = 0 ) {\n msg.payload = \"clench signal\";\n}\nelse if (msg.payload.frown = 0) {\n msg.payload = \"frown signal\";\n}\nelse {\n return null;\n}\nreturn msg;","outputs":1,"noerr":0,"x":1490,"y":380,"wires":[["7854bb6a.6e8494"]]},{"id":"f5cafe90.b61bf","type":"switch","z":"8c77fcbd.3d439","name":"clench","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"80","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1090,"y":260,"wires":[["38ae06c3.245fda"]]},{"id":"e9fe3385.89298","type":"switch","z":"8c77fcbd.3d439","name":"frown","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"80","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1070,"y":460,"wires":[["f8a80587.a04d38"]]},{"id":"f8a80587.a04d38","type":"change","z":"8c77fcbd.3d439","name":">80 (frown)","rules":[{"t":"set","p":"topic","pt":"msg","to":"frown signal","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":460,"wires":[["2bc7253e.f0811a"]]},{"id":"38ae06c3.245fda","type":"change","z":"8c77fcbd.3d439","name":">80 (clench)","rules":[{"t":"set","p":"topic","pt":"msg","to":"clench signal","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1250,"y":260,"wires":[["2bc7253e.f0811a"]]}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/8/8b4e73f267adaada6babd5edd5945b65f73ede42.png)  
I've added the change node. Is the change needed to be added like this? I'm not sure whether it is correct or not and there is still no any message displayed.

[Next page](https://discourse.nodered.org/t/display-output-message/8529.md?page=2)
