Node-RED_Creating your First Flow
Node-RED_Creating your First Flow
Node-RED
home
about
blog
documentation
forum
flows
github
docs • tutorials • first flow
Overview
1. Access the editor
2. Add an Inject node
3. Add a Debug node
4. Wire the two together
5. Deploy
6. Inject
7. Add a Function node
Summary
Source
Next Steps
Related reading
This tutorial introduces the Node-RED editor and creates a flow that demonstrates the Inject, Debug and Function nodes.
If you are using a browser on the same computer that is running Node-RED, you can access it with the url: http://localhost:1880.
If you are using a browser on another computer, you will need to use the ip address of the computer running Node-RED: http://<ip-address>:1880.
Select the newly added Inject node to see information about its properties and a description of what it does in the Information sidebar pane.
The Debug node causes any message to be displayed in the Debug sidebar. By default, it just displays the payload of the message, but it is possible to display the
entire message object.
5. Deploy
At this point, the nodes only exist in the editor and must be deployed to the server.
6. Inject
With the Debug sidebar tab selected, click the Inject button (the small square button next to your inject node). You should see numbers appear in the sidebar. By
default, the Inject node uses the number of milliseconds since January 1st, 1970 as its payload.
The Function node allows you to pass each message though a JavaScript function.
Delete the existing wire (select it and press delete on the keyboard).
Double-click on the Function node to bring up the edit dialog. Copy the following code into the function field:
Click Done to close the edit dialog and then click the deploy button.
Now when you click the Inject button, the messages in the sidebar will now be formatted is readable timestamps.
Summary
This flow demonstrates the basic concept of creating a flow. It shows how the Inject node can be used to manually trigger a flow, and how the Debug node displays
messages in the sidebar. It also shows how the Function node can be used to write custom JavaScript to run against messages.
Source
The flow created in this tutorial is represented by the following json. To import it into the editor, copy it to your clipboard and then paste it into the Import dialog.
[{"id":"58ffae9d.a7005","type":"debug","name":"","active":true,"complete":false,"x":640,"y":200,"wires":[]},{"id":"17626462.e89d9c","type":"inject","n
Next Steps
Create your second flow
Related reading
GitHub
npm
Documentation
APIs
Flow Library
About
Code of Conduct
Community
Blog
Twitter
Forum
Slack
Mastodon
Copyright OpenJS Foundation and Node-RED contributors. All rights reserved. The OpenJS Foundation has registered trademarks and uses trademarks. For a list of
trademarks of the OpenJS Foundation, please see our Trademark Policy and Trademark List. Trademarks and logos not indicated on the list of OpenJS Foundation
trademarks are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
The OpenJS Foundation | Terms of Use | Privacy Policy | OpenJS Foundation Bylaws | Trademark Policy | Trademark List | Cookie Policy
https://nodered.org/docs/tutorials/first-flow 2/2