|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +toc: user-guide-toc.html |
| 4 | +title: The Core Nodes |
| 5 | +--- |
| 6 | + |
| 7 | +The Node-RED palette includes a default set of nodes that are the basic building |
| 8 | +blocks for creating flows. This page highlights the core set you should know about. |
| 9 | + |
| 10 | +All nodes include documentation you can see in the Info sidebar tab when you select a node. |
| 11 | + |
| 12 | +- [Inject](#inject) |
| 13 | +- [Debug](#debug) |
| 14 | +- [Function](#function) |
| 15 | +- [Change](#change) |
| 16 | +- [Switch](#switch) |
| 17 | + |
| 18 | +*** |
| 19 | + |
| 20 | +<h3 id="inject"><img alt="Inject node" style="vertical-align: middle" src="/docs/user-guide/images/node_inject.png" width="169px"></h3> |
| 21 | + |
| 22 | +The Inject node can be used to manual trigger a flow by clicking the node's button |
| 23 | +within the editor. It can also be used to automatically trigger flows at regular |
| 24 | +intervals. |
| 25 | + |
| 26 | +The message sent by the Inject node can have its `payload` and `topic` properties |
| 27 | +set. |
| 28 | + |
| 29 | +The `payload` can be set to a variety of different types: |
| 30 | + |
| 31 | + - a flow or global context property value |
| 32 | + - a String, number, boolean, Buffer or Object |
| 33 | + - a Timestamp in milliseconds since January 1st, 1970 |
| 34 | + |
| 35 | +*** |
| 36 | + |
| 37 | +<h3 id="debug"><img alt="Debug node" style="vertical-align: middle" src="/docs/user-guide/images/node_debug.png" width="169px"></h3> |
| 38 | + |
| 39 | +The Debug node can be used to display messages in the Debug sidebar within the editor. |
| 40 | + |
| 41 | +The sidebar provides a structured view of the messages it is sent, making it easier |
| 42 | +to explore the message. |
| 43 | + |
| 44 | +Alongside each message, the debug sidebar includes information about the time the message |
| 45 | +was received and which Debug node sent it. Clicking on the source node id will reveal |
| 46 | +that node within the workspace. |
| 47 | + |
| 48 | +The button on the node can be used to enable or disable its output. It is recommended |
| 49 | +to disable or remove any Debug nodes that are not being used. |
| 50 | + |
| 51 | +The node can also be configured to send all messages to the runtime log, or to |
| 52 | +send short (32 characters) to the status text under the debug node. |
| 53 | + |
| 54 | +The page on [Working with messages](/docs/user-guide/messages) gives more |
| 55 | +information about using the Debug sidebar. |
| 56 | + |
| 57 | +*** |
| 58 | + |
| 59 | +<h3 id="function"><img alt="Function node" style="vertical-align: middle" src="/docs/user-guide/images/node_function.png" width="169px"></h3> |
| 60 | + |
| 61 | +The Function node allows JavaScript code to be run against the messages that are |
| 62 | +passed through it. |
| 63 | + |
| 64 | +A complete guide for using the Function node is available [here](/docs/writing-functions). |
| 65 | + |
| 66 | +*** |
| 67 | + |
| 68 | +<h3 id="change"><img alt="Change node" style="vertical-align: middle" src="/docs/user-guide/images/node_change.png" width="169px"></h3> |
| 69 | + |
| 70 | +The Change node can be used to modify a message's properties and set context properties |
| 71 | +without having to resort to a Function node. |
| 72 | + |
| 73 | +Each node can be configured with multiple operations that are applied in order. The |
| 74 | +available operations are: |
| 75 | + |
| 76 | + - **Set** - set a property. The value can be a variety of different types, or |
| 77 | + can be taken from an existing message or context property. |
| 78 | + - **Change** - search and replace parts of a message property. |
| 79 | + - **Move** - move or rename a property. |
| 80 | + - **Delete** - delete a property. |
| 81 | + |
| 82 | +When setting a property, the value can also be the result of a [JSONata expression](https://jsonata.org). |
| 83 | +JSONata is a declarative query and transformation language for JSON data. |
| 84 | + |
| 85 | +*** |
| 86 | + |
| 87 | +<h3 id="switch"><img alt="Switch node" style="vertical-align: middle" src="/docs/user-guide/images/node_switch.png" width="169px"></h3> |
| 88 | + |
| 89 | +The Switch node allows messages to be routed to different branches of a flow by |
| 90 | +evaluating a set of rules against each message. |
| 91 | + |
| 92 | +The node is configured with the property to test - which can be either a message |
| 93 | +property or a context property. |
| 94 | + |
| 95 | +There are four types of rule: |
| 96 | + |
| 97 | + - **Value** rules are evaluated against the configured property |
| 98 | + - **Sequence** rules can be used on message sequences, such as those generated |
| 99 | + by the Split node |
| 100 | + - A JSONata **Expression** can be provided that will be evaluated against the |
| 101 | + whole message and will match if the expression returns a `true` value. |
| 102 | + - An **Otherwise** rule can be used to match if none of the preceding rules have |
| 103 | + matched. |
| 104 | + |
| 105 | +The node will route a message to all outputs corresponding to matching rules. But |
| 106 | +it can also be configured to stop evaluating rules when it finds one that matches. |
0 commit comments