Node RED is a wonderful tool which makes prototyping a lot faster and easier! Node Red is very easy to get started with and is a great tool for beginners who want to write and understand programming flow.
It provides lot of tools and plugins which supports almost everything related to programming. It can be used for APIs, DataBase, IOTIntro to IBM's Node-RED, WebSockets, Emails, Scripting, Image Processing, Cloud computing, edge computing, creating websites and lot more one can think of doing it based on NodeJS. In this workshop we will go over the basics of Node Red to help you all get started with the prototyping process!
- Creating a IBM Cloud Account
- IBM Cloud Overview
- Node-RED Overview
- Concept of flows and nodes
- Input & Outputs
- Debug & ingect nodes
- More Node Red Resources
Presenter: Pooja Mistry
Click HERE to get started
- Drag an Inject node from the palette
- Drag a Debug node from the palette and wire the two nodes together
- Double click on the Inject node and change it to inject an A-Z String "Hello World"
- Press the Red Deploy button in the top Right corner. Press the blue Inject. The Hello World string will appear in the Debug area.
Import flow from here : HelloWorld
- Drag the function node from the palette and connect it between the inject node and debug node
- Double click on the function node and add code in the function input, e.g:
var newString = msg.payload.replace("World","Everyone , I hope you enjoy Node Red ");
return {payload : newString};
This example replaces World with Everyone, I hope you enjoy Node Red
Import flow from here : HelloWorldReplace
- Drag a Language Translation node from the palette.
- Double click on the Language Translation node and select German (Language Translation Set up can be found in : How to request Access to Services )
- Connect the Language Translation node in between the Inject node and the debug node
- Press the Red Deploy button in the top Right corner. Press the blue Inject. The string from the inject node will appear in the Debug area along with the translated text.
Import flow from here : HelloWorldGerman
Import flow from here : HelloWorldSpeech
This flow speaks the Berlin weather forecast in German
- Call the Weather Insights for the forecast in Berlin.
- Builds a sentence
- Call language translation to convert to German
- Call Text to Speech to generate a WAV file
- Plays the weather forecast in a German voice
Import flow from here : Weather
This is a simple webpage
Template Code :
<html>
<head>
<title>Hello World</title>
</head>
<body>
<div><h1>This is a simple Webpage in Node-RED</h1></div>
<div id="id_hello">
<span>Hello</span>
<span id="id_nameout"></span>
</div>
<form id="id_form">
<div>
<span>
<h2>What is your name:</h2>
</span>
<span>
<input type="text" name="name"
id="id_name"/>
</span>
</div>
<div>
<input type="submit" value="Enter"
id="id_enter"/>
</div>
</form>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function(){
setupPage();
});
function setupPage(){
$('#id_hello').hide();
$('#id_form').submit(onSubmitClicked);
enterbutton();
}
function onSubmitClicked(event){
$('#id_nameout').text($('#id_name').val());
$('#id_hello').show();
$('#id_form').hide();
event.preventDefault();
}
function enterbutton(){
$(function() {
$("form input").keypress(function (e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$('#id_enter').click();
return false;
} else {
return true;
}
});
});
}
</script>
<style> body {background-color: pink;}</style>
</body>
</html>
Import flow from here : Basic Webpage
- Drag the http node and create a Get Request
Set Method to GET
Set URL to /chat
-
Drag the template node and insert chat source code. Connect with Get Request souce code can be found at Chat Service Source Code
-
Drag http response node and connect with template node
-
Drag Websocket node to listen to http request node
-
Drag Funtion node and connect to websocket node
delete msg._session;
return msg;
- Drag websocket out node and listen on /ws/chat
Import flow from here : ChatService
This flow describes how to build a UI with the use of node-red-dashboard
nodes
We will need to install node-red-dashboard
from manage pallet
Import flow from here : Dashboard
This flow describes how we can measure the sentiment of incoming text
Import flow from here : Sentiment Dashboard
- Drag the twitter input node from the palette and connect it with the debug message node
- Double click on the twitter node and set up twitter authentication
- Steps to set up Twitter
- Click on the little pencil button next to Twitter ID field
- Add Twitter ID
- Create your own application at
developer.twitter.com/en/apps
- Submit your API Keys and Access Tokens
- Once Twitter set up is complete you can receive tweets from hashtags, ids and any strings
- Press red Deploy button and see :
Import flow from here : Twitter Example
- Injects worldmap into dashboard template node
- Uses ISS Location Now API to get live location of International Space Station over Earth
- Maps ISS location tracks on World Map
Import flow from here : Space Station Example