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.10
List Price:  €95.86
You save:  €28.76
£55.67
List Price:  £79.54
You save:  £23.86
CA$100.49
List Price:  CA$143.56
You save:  CA$43.07
A$111.96
List Price:  A$159.95
You save:  A$47.99
S$94.87
List Price:  S$135.54
You save:  S$40.66
HK$544.16
List Price:  HK$777.41
You save:  HK$233.24
CHF 62.56
List Price:  CHF 89.37
You save:  CHF 26.81
NOK kr792.29
List Price:  NOK kr1,131.89
You save:  NOK kr339.60
DKK kr500.54
List Price:  DKK kr715.08
You save:  DKK kr214.54
NZ$123.74
List Price:  NZ$176.78
You save:  NZ$53.04
د.إ257.07
List Price:  د.إ367.26
You save:  د.إ110.19
৳8,330.24
List Price:  ৳11,900.85
You save:  ৳3,570.61
₹5,945.56
List Price:  ₹8,494.03
You save:  ₹2,548.46
RM315.51
List Price:  RM450.75
You save:  RM135.24
₦108,149.19
List Price:  ₦154,505.46
You save:  ₦46,356.27
₨19,403.53
List Price:  ₨27,720.51
You save:  ₨8,316.98
฿2,393.75
List Price:  ฿3,419.79
You save:  ฿1,026.04
₺2,454.67
List Price:  ₺3,506.82
You save:  ₺1,052.15
B$425.95
List Price:  B$608.53
You save:  B$182.58
R1,282.09
List Price:  R1,831.63
You save:  R549.54
Лв131.15
List Price:  Лв187.37
You save:  Лв56.21
₩101,234.93
List Price:  ₩144,627.53
You save:  ₩43,392.60
₪254.67
List Price:  ₪363.83
You save:  ₪109.16
₱4,117.86
List Price:  ₱5,882.91
You save:  ₱1,765.05
¥10,949.58
List Price:  ¥15,642.93
You save:  ¥4,693.35
MX$1,405.49
List Price:  MX$2,007.92
You save:  MX$602.43
QR254.12
List Price:  QR363.05
You save:  QR108.92
P963.49
List Price:  P1,376.48
You save:  P412.98
KSh8,999.72
List Price:  KSh12,857.29
You save:  KSh3,857.57
E£3,561.31
List Price:  E£5,087.81
You save:  E£1,526.49
ብር8,689.79
List Price:  ብር12,414.52
You save:  ብር3,724.72
Kz64,250.82
List Price:  Kz91,790.82
You save:  Kz27,540
CLP$69,143.42
List Price:  CLP$98,780.55
You save:  CLP$29,637.13
CN¥510.67
List Price:  CN¥729.56
You save:  CN¥218.89
RD$4,244.94
List Price:  RD$6,064.47
You save:  RD$1,819.52
DA9,440.04
List Price:  DA13,486.35
You save:  DA4,046.31
FJ$162.13
List Price:  FJ$231.62
You save:  FJ$69.49
Q537.12
List Price:  Q767.35
You save:  Q230.22
GY$14,584.29
List Price:  GY$20,835.60
You save:  GY$6,251.30
ISK kr9,693.35
List Price:  ISK kr13,848.23
You save:  ISK kr4,154.88
DH701.59
List Price:  DH1,002.31
You save:  DH300.72
L1,285.64
List Price:  L1,836.70
You save:  L551.06
ден4,127.89
List Price:  ден5,897.23
You save:  ден1,769.34
MOP$558.06
List Price:  MOP$797.27
You save:  MOP$239.20
N$1,283.39
List Price:  N$1,833.49
You save:  N$550.10
C$2,565.21
List Price:  C$3,664.75
You save:  C$1,099.53
रु9,482.30
List Price:  रु13,546.73
You save:  रु4,064.42
S/259.58
List Price:  S/370.84
You save:  S/111.26
K282.68
List Price:  K403.85
You save:  K121.16
SAR262.90
List Price:  SAR375.59
You save:  SAR112.68
ZK1,929.21
List Price:  ZK2,756.13
You save:  ZK826.92
L333.95
List Price:  L477.10
You save:  L143.14
Kč1,686.22
List Price:  Kč2,408.98
You save:  Kč722.76
Ft27,781.83
List Price:  Ft39,690.03
You save:  Ft11,908.20
SEK kr772.17
List Price:  SEK kr1,103.14
You save:  SEK kr330.97
ARS$71,242.69
List Price:  ARS$101,779.64
You save:  ARS$30,536.94
Bs481.71
List Price:  Bs688.19
You save:  Bs206.47
COP$305,135.87
List Price:  COP$435,927.07
You save:  COP$130,791.20
₡35,171.10
List Price:  ₡50,246.58
You save:  ₡15,075.48
L1,769.55
List Price:  L2,528.04
You save:  L758.48
₲543,563.42
List Price:  ₲776,552.46
You save:  ₲232,989.03
$U3,109.25
List Price:  $U4,441.97
You save:  $U1,332.72
zł286.15
List Price:  zł408.81
You save:  zł122.65
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.