Additional Nodes

20 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$69.99
List Price:  $99.99
You save:  $30
€67.28
List Price:  €96.12
You save:  €28.84
£55.93
List Price:  £79.91
You save:  £23.97
CA$98.01
List Price:  CA$140.02
You save:  CA$42.01
A$107.87
List Price:  A$154.11
You save:  A$46.23
S$94.42
List Price:  S$134.90
You save:  S$40.47
HK$544.78
List Price:  HK$778.29
You save:  HK$233.51
CHF 62.22
List Price:  CHF 88.89
You save:  CHF 26.67
NOK kr779.46
List Price:  NOK kr1,113.56
You save:  NOK kr334.10
DKK kr501.79
List Price:  DKK kr716.88
You save:  DKK kr215.08
NZ$119.98
List Price:  NZ$171.41
You save:  NZ$51.43
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.18
৳8,402.58
List Price:  ৳12,004.20
You save:  ৳3,601.62
₹5,911.93
List Price:  ₹8,445.97
You save:  ₹2,534.04
RM312.68
List Price:  RM446.70
You save:  RM134.02
₦118,358.68
List Price:  ₦169,091.08
You save:  ₦50,732.40
₨19,451.98
List Price:  ₨27,789.74
You save:  ₨8,337.75
฿2,421.30
List Price:  ฿3,459.15
You save:  ฿1,037.85
₺2,419.75
List Price:  ₺3,456.94
You save:  ₺1,037.18
B$406.81
List Price:  B$581.19
You save:  B$174.37
R1,266.21
List Price:  R1,808.95
You save:  R542.74
Лв131.43
List Price:  Лв187.77
You save:  Лв56.33
₩98,455.31
List Price:  ₩140,656.47
You save:  ₩42,201.16
₪260.61
List Price:  ₪372.31
You save:  ₪111.70
₱4,125.84
List Price:  ₱5,894.31
You save:  ₱1,768.47
¥10,813.84
List Price:  ¥15,449
You save:  ¥4,635.16
MX$1,432.62
List Price:  MX$2,046.69
You save:  MX$614.07
QR256.35
List Price:  QR366.23
You save:  QR109.88
P959.91
List Price:  P1,371.36
You save:  P411.45
KSh9,063.70
List Price:  KSh12,948.70
You save:  KSh3,885
E£3,476.67
List Price:  E£4,966.88
You save:  E£1,490.21
ብር8,762.26
List Price:  ብር12,518.05
You save:  ብር3,755.79
Kz63,877.12
List Price:  Kz91,256.94
You save:  Kz27,379.82
CLP$68,152.06
List Price:  CLP$97,364.26
You save:  CLP$29,212.20
CN¥507.37
List Price:  CN¥724.85
You save:  CN¥217.47
RD$4,236.71
List Price:  RD$6,052.70
You save:  RD$1,815.99
DA9,355.50
List Price:  DA13,365.57
You save:  DA4,010.07
FJ$159.32
List Price:  FJ$227.62
You save:  FJ$68.29
Q542.77
List Price:  Q775.43
You save:  Q232.65
GY$14,710.67
List Price:  GY$21,016.15
You save:  GY$6,305.47
ISK kr9,775.50
List Price:  ISK kr13,965.60
You save:  ISK kr4,190.10
DH703.21
List Price:  DH1,004.63
You save:  DH301.41
L1,276.61
List Price:  L1,823.81
You save:  L547.19
ден4,112.73
List Price:  ден5,875.58
You save:  ден1,762.85
MOP$563.70
List Price:  MOP$805.33
You save:  MOP$241.62
N$1,272.29
List Price:  N$1,817.64
You save:  N$545.34
C$2,573.53
List Price:  C$3,676.63
You save:  C$1,103.10
रु9,461.06
List Price:  रु13,516.38
You save:  रु4,055.32
S/267.08
List Price:  S/381.56
You save:  S/114.48
K283.05
List Price:  K404.37
You save:  K121.32
SAR262.80
List Price:  SAR375.44
You save:  SAR112.64
ZK1,938.90
List Price:  ZK2,769.98
You save:  ZK831.07
L334.76
List Price:  L478.25
You save:  L143.49
Kč1,707.89
List Price:  Kč2,439.96
You save:  Kč732.06
Ft27,663.65
List Price:  Ft39,521.19
You save:  Ft11,857.54
SEK kr779.03
List Price:  SEK kr1,112.95
You save:  SEK kr333.92
ARS$70,272.32
List Price:  ARS$100,393.34
You save:  ARS$30,121.01
Bs485.83
List Price:  Bs694.07
You save:  Bs208.24
COP$310,661.31
List Price:  COP$443,820.90
You save:  COP$133,159.58
₡35,743.76
List Price:  ₡51,064.70
You save:  ₡15,320.94
L1,776.85
List Price:  L2,538.46
You save:  L761.61
₲551,865.53
List Price:  ₲788,413.13
You save:  ₲236,547.59
$U2,996.30
List Price:  $U4,280.61
You save:  $U1,284.31
zł292.33
List Price:  zł417.63
You save:  zł125.30
Already have an account? Log In

Transcript

Video 3.4 additional nodes in this video, we will learn the other additional nodes included in the node red palette and the rest of the features of the function node. Okay, let's start. The first additional node we are going to see is the link node. Link node is super cool. You can break long flows without disrupting its functionality within and also between the workspaces. I'll show you how that works.

Actually, there are two linked nodes input and output. When you break a flow, one side will need an output node and the other side will need an input node right and the output and input nodes of these two flows will have a magical connection which can't be seen. This is what happens with link nodes. We can take the most simple flow possible We'll inject and debug nodes here. If you want to have your starting at one point in the workspace and the ending at another point in the workspace, connect the output link node here and the input link node here and configure one of the link nodes. Because if one gets configured, the other one gets configured magically.

Inside the properties, you have to choose the other link node to which you want to magically have a connection with and then there you go. Let's check it out. See, okay, let's try the same thing works between workspaces. Cut this and paste it there. But I have too many flows here already. To keep the flows organized.

You can have comment nodes where you can add comments. Let me add it here too. Okay, let's check it now. Wow, it works. So why would we be needing this magical property. If you have complex flows, then to avoid clutter, this will be useful.

Okay, now we can see how to use other additional nodes. For that, first we need a function node, I have added a flow file, which contains a function node alone in the resources section of this video. So import the function node to your workspace. But why we are going to use a math module from NPM. To check if a number is negative. When the condition has been checked, the status is shown and only when it is true, the message dot payload is passed to the rest of the flow.

If not, then an error is thrown. And the message dot payload is not past. It isn't like we don't have an instant map function. In fact, GS has a built in math object, which we saw earlier, I'm using a different one, just to enlighten you on the feature of function node. To understand what's happening fully, I need you to drag catch and status nodes to the workspace where the function node is present. The catch node catches error messages, and the status node catches status messages.

Both of these nodes can be configured to collect messages from all or separate nodes. Here, I'll configure them to collect logs only from the function node. Note that these nodes catch errors or status messages only from nodes within that workspace. To know more, read the node help connect both of these nodes to debug console, which outputs complete message objects. Now we can see what's inside the function node line by line. I have added comments for easy understanding.

Now, I have declared a new variable, which equals some global context variable, math, js. But we haven't defined anything like that, right? Even if we define it using the global dot sec method, how can we install an NPM module NPM module. Guess matches is an NPM module, which can't be loaded directly on the function node, because it is beyond the scope of the sandbox environment in the function node to add new modules, but we want to use that math variable to check whether the injected number is negative or not. How do we do that? Well, we can pre populate the global context with objects when the node rates down This can be done by defining an object attribute with name and require statement as the value in the function global context property inside the settings.js file.

Feeling like a deer in the headlights. Let me show you. Before that, don't forget to deploy the changes. Remember I told you about doing something in the settings.js file unnoted files are present in the GitHub repo under tool chains. This is how the repository looks. The repo name will be your app name.

Inside the repo, you can find all the files. Don't forget to look around the report later. First, we need to change the settings.js file. Since no dread is running in IBM Cloud, the settings.js file will be named as bloomix tests. settings.gs click Edit to edit the file inside the file search for function global context property here at this line math GS, colon require math js, okay. Looking at this, I can tell that inside this property, we are defining another property and the value of it is required matches.

What does this mean? The require keyword is not from jsapi it is a built in function of node j s, which is used to load the modules defined inside the brackets. So, that is how this works. Okay, now commit the changes. Once the changes have been committed, we can check out the delivery pipeline. As you can see, the build stage has already already been passed, but the deploy stage has failed.

Why? Because even though we included the module inside the function node, to bring the package into the application, we have to define it as a dependency in the package dot Jason file. As we know, package dot JSON file is the heart of the Node JS system. It is used to manage metadata of the node rate project. You can find a lot of data here, like name, version, and a lot of dependencies. The scripts property is a dictionary containing script commands that are run at various times in the lifecycle of your package.

The engines property is used to specify the version of Node JS running here. You will have to modify this property to eight dot exe to run the latest version. That is point two zero point x have no dread. I have included a link in the resources, which tells how to do it. Okay, here you have to define an object which maps the package name to its version, like this. Let's check the version of the module from the NPM website.

Now commit the changes and wait for the delivery chain to restart node red. Yes, it works uh hi fighter you. Loading additional modules is one of the properties of the function node. So this is how we can add external modules to the sandbox environment inside the function node and make it available to all functions referenced within a function using global dot get method. Remember the context data panel? We were talking about context variables all the while.

And guess what this one has, it will store all the context data. You have specific fields to show separate contexts, node flow and global. They can also be refreshed to observe the change in values after some action. You can see that we have the global variable matches here. Okay, now we can come back to the rest of the code inside the function node. In the first line, we have defined the math variable by accessing the global object math js.

To understand the next line will commend the rest of the lines below the program to understand what it does deploy and check it out. Once we inject the flow, there is a text and status appearing below the function node. And there is also a message object shown in the debug console. Let's see what it is. You can see that there is a status property, which contains the text we had input in the program. It also contains a source property, which tells where the status message comes from.

You can also see that the debug node connected with the status node is getting highlighted. This is all done by the command node dot status, which connects to the status node to output the status. Note that these commands which start like node dot status, node dot one node, dot log, etc, are asynchronous messages. That is, they don't go with the flow. They'll only be triggered when necessary. This is one of the important properties of the function node.

Okay, now the next set of lines, this time, we'll comment out the else part of the program, the set timeout function inside the set timeout function and also the node dot log part. Okay, let's see what it is about the if condition evaluates if the message dot payload had a negative value, you may have a question, Where did I find a function like that? Let me show you. We'll have to go to the map chairs NPM page and there is a link to the Getting Started part and there are the docs and there is the function. You can also try out with other functions in this module. Okay, but message dot payload right now outputs timestamp Right, yes, we have to change that.

I'm going to give minus one. We also need a positive number for the else part. So let's add that to. Okay. Now deploy and inject. This time, you can see two steps.

The first one was showing the status message started under the function node, and then outputting the status message in the debug console. The next step was showing the status message processing with a nice yellow ring icon and a status message similar to this in the debug console. If you noticed properly, the second step happened after one second after the first step. This was because of the set timeout function on which we had defined an interval 1000 milliseconds. Also note that these status icons can configured in many colors, like red, blue, green, yellow gray by changing the value in the field property, getting the hang of how this works. Okay.

Next, we'll uncomment the set timeout function present inside the one we saw, and also the node dot log function deploy Now, one other thing you need to note is when we deployed even before we injected anything, there was a status message in the debug console. This is output by the status node by default. Now inject this time, there are three steps. The first two are the same. The third one is the status message done with a nice green dot icon and similar message as object issue. In the debug window, there is also one other thing minus one.

Where does that come from the debug node from the other side of the flow. How did this happen? Remember this line? No dot send payload colon message dot payload. Yes, that was how it happened. Okay, now I want to show you one other thing.

So let's change the message dot payload to complete message object here and deploy again. Now you can see that since the message dot payload is sent asynchronously via the node dot send function, there is an additional property called underscore event attached with the payload. Wait, we have not yet seen what the log looks like the log From the node dot log, let's check it from the logs tab. In the app page. You can filter app logs alone to find what you want in an easy way. Sometimes you have to refresh.

See, there it is. Okay, now we'll do the same way as we did for the F loop, deploy and inject. You can see the first stage start. The next one is the warning icon status message with its corresponding object in the debug panel. Note that the warning message has yellow bars on its side to indicate it is a warning message. will also check out the log now.

See, there it is. Okay, now we can uncomment these lines to deploy inject, and one other step gets added the part where it shows the error message with red dot icon, and the other two are got from the node dot arrow function. How to remember we had given two node dot error functions, one with the message object and one without it. If we include the message object, then it gets outputted from the catch node. If you don't include then it gets outputted from the function node alone. Note that here the error message is displayed with red bars on its sides.

Okay, now let's come to the other additional nodes. There is this node called RB which will be very useful if you understand how to use it properly. We can drag it from the functions category, it is called the report by exception, which means that it will pass the payload or whatever property you define only when it has been changed. It also has another mode, where it will block the payload until it changes by a specified amount. That is called the dead band mode. You can see the different modes here.

I'm going to have it the same way for now. But wait. We also need to add one more negative number as an input to check if it works. I'm giving minus three. Now deploy and inject minus one times minus one again See, the RP node is blocking the payload, okay. Now check minus three minus three is coming as output.

Cool. Okay, now I have one more note to show you, it is a delay note. Here also, there are different actions. You can have a fixed delay, random delay, whatever you want. Then you can define the delay interval in seconds, minutes, hours and even days. If you want to know more, check out the node help doc for now, I'm going to leave it as it is and deploy minus one, inject 12345 and there it is.

Minus one again. blocked minus three inject 12345. And there it is. Now I want you to pause the video and try out blocking the message unless the value change is greater than 5% using the RB node and rate limit all messages at two messages per second using the delay node. So how did it go now explore the rest of the functionalities of the RB node and the delay node. Super enjoyed this video.

But like all good things, this must come to an end to In this video, we learn some additional nodes from the palette and also the other features of the function node. In the next video, we will be learning about API's.

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.