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
€65.39
List Price:  €93.41
You save:  €28.02
£55.92
List Price:  £79.90
You save:  £23.97
CA$96.01
List Price:  CA$137.16
You save:  CA$41.15
A$107.15
List Price:  A$153.08
You save:  A$45.93
S$95.13
List Price:  S$135.90
You save:  S$40.77
HK$547.14
List Price:  HK$781.66
You save:  HK$234.52
CHF 63.86
List Price:  CHF 91.23
You save:  CHF 27.37
NOK kr775.40
List Price:  NOK kr1,107.76
You save:  NOK kr332.36
DKK kr487.78
List Price:  DKK kr696.86
You save:  DKK kr209.07
NZ$118.01
List Price:  NZ$168.60
You save:  NZ$50.58
د.إ257.06
List Price:  د.إ367.24
You save:  د.إ110.18
৳7,680.49
List Price:  ৳10,972.60
You save:  ৳3,292.11
₹5,842.03
List Price:  ₹8,346.11
You save:  ₹2,504.08
RM332.86
List Price:  RM475.54
You save:  RM142.67
₦86,437.65
List Price:  ₦123,487.65
You save:  ₦37,050
₨19,491.96
List Price:  ₨27,846.85
You save:  ₨8,354.89
฿2,586.09
List Price:  ฿3,694.58
You save:  ฿1,108.48
₺2,265.39
List Price:  ₺3,236.41
You save:  ₺971.02
B$363.53
List Price:  B$519.35
You save:  B$155.82
R1,302.64
List Price:  R1,861
You save:  R558.35
Лв127.90
List Price:  Лв182.73
You save:  Лв54.82
₩96,270.48
List Price:  ₩137,535.16
You save:  ₩41,264.67
₪262.29
List Price:  ₪374.71
You save:  ₪112.42
₱4,033.94
List Price:  ₱5,763.02
You save:  ₱1,729.07
¥10,867.12
List Price:  ¥15,525.12
You save:  ¥4,658
MX$1,187.12
List Price:  MX$1,695.96
You save:  MX$508.84
QR254.93
List Price:  QR364.20
You save:  QR109.27
P994.08
List Price:  P1,420.18
You save:  P426.09
KSh9,360.69
List Price:  KSh13,372.99
You save:  KSh4,012.30
E£3,358.63
List Price:  E£4,798.26
You save:  E£1,439.62
ብር4,003.77
List Price:  ብር5,719.92
You save:  ብር1,716.15
Kz58,546.63
List Price:  Kz83,641.63
You save:  Kz25,095
CLP$67,216.99
List Price:  CLP$96,028.39
You save:  CLP$28,811.40
CN¥506.70
List Price:  CN¥723.89
You save:  CN¥217.19
RD$4,073.53
List Price:  RD$5,819.58
You save:  RD$1,746.04
DA9,418.34
List Price:  DA13,455.35
You save:  DA4,037.01
FJ$158.31
List Price:  FJ$226.17
You save:  FJ$67.86
Q543.96
List Price:  Q777.12
You save:  Q233.16
GY$14,650.29
List Price:  GY$20,929.88
You save:  GY$6,279.59
ISK kr9,815.39
List Price:  ISK kr14,022.59
You save:  ISK kr4,207.20
DH707.71
List Price:  DH1,011.06
You save:  DH303.35
L1,237.78
List Price:  L1,768.33
You save:  L530.55
ден4,025.24
List Price:  ден5,750.59
You save:  ден1,725.35
MOP$563.96
List Price:  MOP$805.69
You save:  MOP$241.73
N$1,304.33
List Price:  N$1,863.42
You save:  N$559.08
C$2,570.38
List Price:  C$3,672.13
You save:  C$1,101.75
रु9,397.27
List Price:  रु13,425.24
You save:  रु4,027.97
S/263.43
List Price:  S/376.35
You save:  S/112.91
K270.11
List Price:  K385.89
You save:  K115.77
SAR262.49
List Price:  SAR375.01
You save:  SAR112.51
ZK1,873.89
List Price:  ZK2,677.10
You save:  ZK803.21
L325.37
List Price:  L464.84
You save:  L139.46
Kč1,643.47
List Price:  Kč2,347.91
You save:  Kč704.44
Ft25,458.03
List Price:  Ft36,370.18
You save:  Ft10,912.14
SEK kr764.90
List Price:  SEK kr1,092.76
You save:  SEK kr327.86
ARS$61,327.27
List Price:  ARS$87,614.14
You save:  ARS$26,286.87
Bs483.57
List Price:  Bs690.85
You save:  Bs207.27
COP$273,218.78
List Price:  COP$390,329.27
You save:  COP$117,110.49
₡35,710.66
List Price:  ₡51,017.42
You save:  ₡15,306.75
L1,733.65
List Price:  L2,476.75
You save:  L743.09
₲524,442.73
List Price:  ₲749,236.02
You save:  ₲224,793.28
$U2,683.09
List Price:  $U3,833.15
You save:  $U1,150.06
zł283.24
List Price:  zł404.64
You save:  zł121.40
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.