Professional Documents
Culture Documents
• Event-driven, asynchronous
io; it’s all about the events
• Single-threaded event-
queue; built for fairness
• Inject node
• Allows manual triggering of flows
• Can inject events at scheduled intervals
• Debug node
• Show message content; either payload or
entire object
• Template Node
• Modifies the output based on a Mustache
Template
Node-RED Hello World
• When you click on the Inject Node, it sends and event through the
flow – triggering the template node and sending the result to the
Debug node
Other Input Nodes
• Function node
• Run user-defined node.js code on the
messages going by
• Uses vm.createScript under the covers to
sandbox execution
• Console, util, Buffer included for convenience
• Switch
• Change flow to different options based on a
comparison
Creating your own nodes
http://nodered.org/docs/creating-nodes/first-node.html
Works anywhere you have node.js and npm (Raspberry Pi, Galileo, etc.)
Node-RED on Bluemix
Temperature Sensor Example
Manage
Assemble Collect
Connect
Setting up Node-RED in Bluemix
•To gain access to device data coming from the IBM IOT
Foundation, you need to connect your Node-RED runtime to an
IBM IOT Service
• register for the IOT Foundation Trial
from within Bluemix
Registering your device
• The Data Web Service GET is an HTTP input endpoint responding to a GET
on /data
• Update Payload is a function node that changes the format of the payload to
the MongoDB query format (avoiding Mongo injection attacks)
• MongoDB Query simply returns the result of evaluating what was in the
payload (in Mongo DB query form, e.g. "payload.d.time": {$gt: x, $lt: y})
• DataOutput is an HTTP Response node returning the payload as its result to
the caller
Making actions happen – sending events