1
00:00:00,690 --> 00:00:05,400
In this lecture, I will show you how to use a switch note, and as you'll see, it's very simple.

2
00:00:05,730 --> 00:00:08,210
You can find a switch note under function.

3
00:00:08,760 --> 00:00:11,810
So the way that this switch note works is very simple.

4
00:00:11,820 --> 00:00:14,560
It's like an if statement in a regular programming language.

5
00:00:14,940 --> 00:00:22,860
So in the switch node properties window, you can set any number of properties and for each property

6
00:00:22,860 --> 00:00:28,530
you set a condition and then depending on which condition is true, appropriate output will be sent

7
00:00:28,530 --> 00:00:28,860
out.

8
00:00:29,250 --> 00:00:31,050
So in this case, I've got two conditions.

9
00:00:31,290 --> 00:00:36,840
The first one is for any number that comes in through the payload, a message payload that is larger

10
00:00:36,840 --> 00:00:37,460
than five.

11
00:00:37,740 --> 00:00:39,230
And the second condition is true.

12
00:00:39,510 --> 00:00:45,070
If the number that comes through the message payload is less than or equal to five.

13
00:00:45,480 --> 00:00:51,780
And of course, you have all sorts of other conditions or rules that you can you can use in your properties.

14
00:00:52,290 --> 00:00:58,550
It can also set the switch node to continue checking all rules.

15
00:00:58,590 --> 00:01:04,770
Or if you set it to all rules, then output will be triggered for any rule that is true, or you can

16
00:01:04,770 --> 00:01:08,170
get it to stop after the first match is found.

17
00:01:09,000 --> 00:01:19,020
So then I'll be just typing in a different number in my message payload to see how the switch node behaves.

18
00:01:19,710 --> 00:01:23,370
So let's deploy that and have a look at the debug window.

19
00:01:23,370 --> 00:01:25,890
And I'm looking at the current flow only.

20
00:01:26,310 --> 00:01:33,420
And right now the the trigger will send out a payload with the number six to the switch node.

21
00:01:33,510 --> 00:01:34,380
So it's trigger that.

22
00:01:35,700 --> 00:01:44,070
And you can see that this node was activated, this debug node diagnosed with name larger than five

23
00:01:44,070 --> 00:01:45,330
or greater than five.

24
00:01:45,660 --> 00:01:48,090
And the number that came through is six.

25
00:01:48,810 --> 00:01:52,800
OK, this did Pagnol just just print out the payload and this is its name.

26
00:01:53,530 --> 00:01:58,170
I'm going to change the payload to three.

27
00:02:01,030 --> 00:02:06,730
Redeploy to make the change effective, trigger it, and you could say now that we've got a threat coming

28
00:02:06,730 --> 00:02:13,230
through because of this debug node was activated, which is less than or equal to five.

29
00:02:13,780 --> 00:02:21,130
So you can use this switch node to implement conditional logic in your in your flows, as you would

30
00:02:21,130 --> 00:02:26,440
using an if statement or a switch structure in a regular programming language.
