# Need help for my first function

**URL:** <https://discourse.nodered.org/t/need-help-for-my-first-function/5612>\
**Category:** General\
**Created:** [9 December 2018 17:51 UTC](https://discourse.nodered.org/t/need-help-for-my-first-function/5612 "2018-12-09T17:51:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marsab](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@marsab](https://discourse.nodered.org/u/marsab)\
**Post date:** [9 December 2018 17:51 UTC](https://discourse.nodered.org/t/need-help-for-my-first-function/5612/1 "2018-12-09T17:51:52Z")

</div>

Hi,

I'm struggling with a very basic principle.

I would like to trigger a custom message payload based on a time trigger.

For example, if it's 9:00 AM I'd like to send this payload "colorTemp":153 to another node.

Right now I'm experimenting with a timestamp chained with a series of "time range" nodes.  
Each time range node has a time frame, if my message doesn't match node's timeframe then it goes one node further etc until it triggers a function.

```
My function contains this code

    msg.payload="colorTemp\"\:153"
    return msg;

```

I'm confused because returning the function above doesn't create the same effect as this code from my inject node

{`"colorTemp":153}`

Here is what I get from the debugging window:

```
msg.payload : string[14]
"colorTemp":153"

```

Thanks for your help

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [9 December 2018 18:04 UTC](https://discourse.nodered.org/t/need-help-for-my-first-function/5612/2 "2018-12-09T18:04:18Z")

</div>

you are creating it as a string but you need/want to create it as a javascript object.

The w3schools web pages on javascript objects will give you all the information you need and will also help you understand what you need to do in a Node-RED function node
