Set a message property to a fixed value

Problem

You want to set a message property to a fixed value.

Solution

Use the Change node to set the property of the message.

Example

Discussion

The Change node can be used to set properties of a message.

The node supports setting various JavaScript types as well as some Node-RED specific types.

  • strings: "hello world"
  • numbers: 42
  • boolean: true/false
  • timestamp: the current time, in milliseconds, since epoch (January 1st, 1970)
  • JSON: a JSON string that will be parsed to its Object representation
  • Buffer: a Node.js Buffer object

It also supports setting a property to a value based on the value of context properties, other message properties or a JSONata expression.