# Send string from dashboard to msg.payload

**URL:** <https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555>\
**Category:** Dashboard\
**Created:** [3 March 2020 12:06 UTC](https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555 "2020-03-03T12:06:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cedric](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Cedric](https://discourse.nodered.org/u/Cedric)\
**Post date:** [3 March 2020 12:06 UTC](https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555/1 "2020-03-03T12:06:02Z")

</div>

Hi

I want to write a string on the dashboard, which is normaly hardcoded in a msg.payload.  
I'm a beginner and I don't know how to configure it.

Thank you very much for your help.

BR  
Cedric

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/c/ac020da69433e59fd452a7a79232a268662ff005.png)`[{"id":"80f5f851.9c4388","type":"tab","label":"dashboard send PhoneNumber to ws","disabled":false,"info":""},{"id":"32c1cdd5.7d44e2","type":"function","z":"80f5f851.9c4388","name":"","func":"var Data = msg.payload.Data;\nmsg.payload.Data = Data;\n//var Sms = msg.payload.Sms;\n//msg.payload.Sms = Sms;\nvar Sms = msg.payload.Data.Sms;\nmsg.payload.Data.Sms = Sms;\nvar PhoneNumber = msg.payload.Data.Sms.PhoneNumber;\nmsg.payload.Data.Sms.PhoneNumber = PhoneNumber;\n\nmsg.payload = {\n \"RequestType\": \"SmsSend\",\n \"Data\": {\n \"Sms\": {\n \"PhoneNumber\" : PhoneNumber,\n \"Text\": \"Test content\"\n }\n }\n};\nreturn msg;\n","outputs":1,"noerr":0,"x":690,"y":320,"wires":[["dd3a2b88.5b37e8"]]},{"id":"2be7d3ca.a5da3c","type":"ui_text_input","z":"80f5f851.9c4388","name":"PhoneNumber","label":"","tooltip":"","group":"3c07d2a4.79ebbe","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":"0","topic":"sms","x":280,"y":320,"wires":[["cea19871.299538"]]},{"id":"dd3a2b88.5b37e8","type":"debug","z":"80f5f851.9c4388","name":"PhoneNumber","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":860,"y":320,"wires":[]},{"id":"cea19871.299538","type":"change","z":"80f5f851.9c4388","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.PhoneNumber","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":320,"wires":[["32c1cdd5.7d44e2"]]},{"id":"3c07d2a4.79ebbe","type":"ui_group","z":"","name":"Ultrasonic Sensor Voltage","tab":"5912d7e1.fb9f28","order":1,"disp":true,"width":"7","collapse":false},{"id":"5912d7e1.fb9f28","type":"ui_tab","z":"","name":"Device Ultrasonic sensor","icon":"dashboard","order":8}]`

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [3 March 2020 12:20 UTC](https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555/2 "2020-03-03T12:20:31Z")

</div>

Hi Cedric,

First of, I have a couple links of recommended reading for you to get started with:  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)  
[https://nodered.org/docs/user-guide/nodes](https://nodered.org/docs/user-guide/nodes)

After reading those, do you have an idea to continue?  
For future messages, it often helps if you include the (relevant part of the) flow you've made to a post. You can get it by going to the hamburger menu in Node-RED (3 horizontal lines) -\> export -\> copy the flow (double check if you're only copying the currently selected node or the part that you were actually trying to send), then add it to a post following the following instructions: [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

That way users helping you can import the exact code and look at it.

---

<div class="post-metadata">

**Author:** ![Cedric](https://avatars.discourse-cdn.com/v4/letter/c/ecd19e/32.png) [@Cedric](https://discourse.nodered.org/u/Cedric)\
**Post date:** [5 March 2020 13:54 UTC](https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555/3 "2020-03-05T13:54:26Z")

</div>

Hi

thank you Lena for your support.

I follow the instruction and I get "my solution"

Now I want to add a switch on the dashboard. The switch should trigger different strings.  
When the switch is on the Text "switch on" should be add in my function.

When the switch is offthe Text "switch off" should be add in my function.

How can I add these msg.payload to the Text in the funtion?  
With batch or join?  
For join there can I configure the msg.part?

But at first the request for the status of the switch is not working.

Thank you for your help.

```auto
[{"id":"8f4069de.4584f8","type":"tab","label":"dashboard send PhoneNumber to ws","disabled":false,"info":""},{"id":"54b3c884.9694f8","type":"function","z":"8f4069de.4584f8","name":"","func":"var Data = msg.payload;\n//var Text = msg.payload.Data.Sms.Text;\n\nmsg.payload = {\n \"RequestType\": \"SmsSend\",\n \"Data\": {\n \"Sms\": {\n \"PhoneNumber\" : Data,\n \"Text\": \"Text\",\n }\n }\n};\nreturn msg;\n\n//\"Guid\": \"69c6ee52-7bae-4000-b19f-88153d926a77\",\n// \"MessageId\": \"string\",","outputs":1,"noerr":0,"x":1254.0001125335696,"y":285.99986362457287,"wires":[["9b3190ac.67b77"]]},{"id":"25f8e3b0.5faf0c","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.PhoneNumber","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":714.0000762939455,"y":285.99986362457287,"wires":[["54b3c884.9694f8"]]},{"id":"567b584f.0a1c38","type":"ui_text_input","z":"8f4069de.4584f8","name":"PhoneNumber","label":"PhoneNumber","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":true,"mode":"text","delay":"0","topic":"sms","x":480.00009918212913,"y":285.99992108345043,"wires":[["25f8e3b0.5faf0c"]]},{"id":"1230280f.44dd48","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.Text","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":762.0001029968262,"y":739.9999685287476,"wires":[["e13c0031.31609"]]},{"id":"a83631f3.25643","type":"ui_text_input","z":"8f4069de.4584f8","name":"Switch on","label":"Switch on","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"sms","x":556.000072479248,"y":739.9999685287476,"wires":[["1230280f.44dd48"]]},{"id":"bff63c0c.20fb7","type":"status","z":"8f4069de.4584f8","name":"","scope":["43e62a7.a391ed4"],"x":336.00007247924805,"y":739.9999685287476,"wires":[["a83631f3.25643","25be9964.e5fdd6"]]},{"id":"43e62a7.a391ed4","type":"ui_switch","z":"8f4069de.4584f8","name":"","label":"switch","tooltip":"","group":"f990197b.29b4b8","order":0,"width":0,"height":0,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":325.5682144165039,"y":610.7783451080322,"wires":[[]]},{"id":"e13c0031.31609","type":"join","z":"8f4069de.4584f8","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1053.5681724548338,"y":688.5624608993529,"wires":[["54b3c884.9694f8"]]},{"id":"2104a001.4d812","type":"change","z":"8f4069de.4584f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.Data.Sms.Text","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":764.0285301208496,"y":894.0113592147827,"wires":[["e13c0031.31609"]]},{"id":"a05e3eb9.9b60c","type":"ui_text_input","z":"8f4069de.4584f8","name":"Switch off","label":"Switch off","tooltip":"","group":"f990197b.29b4b8","order":10,"width":0,"height":0,"passthru":false,"mode":"text","delay":"0","topic":"sms","x":558.0284996032715,"y":894.0113592147827,"wires":[["2104a001.4d812"]]},{"id":"8c7e7c64.d7639","type":"batch","z":"8f4069de.4584f8","name":"","mode":"count","count":10,"overlap":0,"interval":10,"allowEmptySequence":false,"topics":[{"topic":""}],"x":1045.5852813720703,"y":594.8692598342896,"wires":[[]]},{"id":"86676a24.827b08","type":"status","z":"8f4069de.4584f8","name":"","scope":["43e62a7.a391ed4"],"x":346.0284996032715,"y":898.0113592147827,"wires":[[]]},{"id":"9b3190ac.67b77","type":"debug","z":"8f4069de.4584f8","name":"function","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":1501.5625457763672,"y":287.65901374816895,"wires":[]},{"id":"a8de3082.db296","type":"comment","z":"8f4069de.4584f8","name":"or ","info":"","x":1025.5624694824219,"y":640.9259996414185,"wires":[]},{"id":"7f0e167.340ece8","type":"comment","z":"8f4069de.4584f8","name":"I want to add","info":"","x":325.57948303222656,"y":558.9488410949707,"wires":[]},{"id":"6462ef47.0f8b","type":"comment","z":"8f4069de.4584f8","name":"My solution","info":"","x":429.57948303222656,"y":232.94886875152588,"wires":[]},{"id":"25be9964.e5fdd6","type":"debug","z":"8f4069de.4584f8","name":"status","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":551.5738220214843,"y":821.3181304931638,"wires":[]},{"id":"f990197b.29b4b8","type":"ui_group","z":"","name":"test switch","tab":"50f5f1b7.91df7","order":1,"disp":true,"width":"7","collapse":false},{"id":"50f5f1b7.91df7","type":"ui_tab","z":"","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/7/378b98c4b330bf72a284461a8133d3fc1d14569b.png)

---

<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:** [4 April 2020 14:06 UTC](https://discourse.nodered.org/t/send-string-from-dashboard-to-msg-payload/22555/4 "2020-04-04T14:06:42Z")

</div>

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