1
00:00:00,720 --> 00:00:07,800
Hey, in this in the next lecture, I will talk about messages and viable messages and various other

2
00:00:07,800 --> 00:00:13,980
ways by which Newt can communicate with each other and pass data to each other.

3
00:00:14,430 --> 00:00:16,310
So here will start with messages.

4
00:00:16,320 --> 00:00:22,620
And I've already said a couple of examples here to walk you through and present some of the features

5
00:00:22,860 --> 00:00:26,070
that you should know about with messages and how to use them.

6
00:00:26,430 --> 00:00:31,700
Of course, there is documentation that you should really look at to get all of the details.

7
00:00:31,710 --> 00:00:34,560
And I encourage you to do that.

8
00:00:34,560 --> 00:00:43,620
Messaging as well as Flo's is a powerful way for data interchange within Flo's or across actually multiple

9
00:00:43,620 --> 00:00:47,960
flows in your note read installation here.

10
00:00:48,030 --> 00:00:54,480
I just want to keep things very, very practical and applicable to the project that you are about to

11
00:00:54,480 --> 00:00:54,900
begin.

12
00:00:55,380 --> 00:01:00,350
I've also used the documentation feature via the comment note.

13
00:01:00,370 --> 00:01:06,480
She can see right here of a couple of common codes been doing that as well throughout this course where

14
00:01:06,480 --> 00:01:11,890
I provide information that you should be aware of for each particular flow and to each particular tab.

15
00:01:12,150 --> 00:01:19,290
So here, for example, I'll be using a bit of Jason, I'm giving you the origin of the Jason object

16
00:01:19,290 --> 00:01:24,810
that I'm using as a test and also the link to the documentation that I've shown you here.

17
00:01:25,770 --> 00:01:29,830
So look around for these bubbles that contain further information.

18
00:01:30,510 --> 00:01:37,170
So let's have a look at messages that are said, the primary way of communication between notes.

19
00:01:37,620 --> 00:01:45,360
I've got a bunch of inject notes here and actually to show you how these work, what I do is I will

20
00:01:45,360 --> 00:01:47,520
disable them.

21
00:01:47,520 --> 00:01:54,450
So you can see I have selected a bunch of notes and I can go here and enable or disable them.

22
00:01:54,460 --> 00:01:59,460
So let's say that I want to disable these notes so they're not really it.

23
00:02:01,370 --> 00:02:09,320
And available for execution, and that leaves me with just these two, I'm going to drill inside the

24
00:02:09,320 --> 00:02:19,070
time stamp payload note and you can see that the payload of this node is actually a message.

25
00:02:19,070 --> 00:02:20,840
Amstutz, the only thing that it can be.

26
00:02:21,290 --> 00:02:24,140
And I've given it a particular value.

27
00:02:24,140 --> 00:02:25,820
I've just taken a timestamp.

28
00:02:26,060 --> 00:02:29,300
I'm going to show you how to do the same thing with the string in a moment.

29
00:02:29,690 --> 00:02:35,180
Now, what happens is that this timestamp or whatever it is that you want to pass on to the next node

30
00:02:35,570 --> 00:02:40,190
will be stored as payload of the message object.

31
00:02:41,030 --> 00:02:44,420
So let's see what that means inside the debug node.

32
00:02:44,720 --> 00:02:51,590
Just taking whatever I've got inside the payload attribute of the message object and I'm printing it

33
00:02:51,590 --> 00:02:51,970
out.

34
00:02:52,460 --> 00:03:00,530
So let's deploy the flow and I'm going to manually trigger the timestamp, inject mode and actually

35
00:03:00,530 --> 00:03:05,440
switch to the debug messages view and see what we get on the other side.

36
00:03:05,930 --> 00:03:07,010
So that's what we get.

37
00:03:07,040 --> 00:03:09,440
So this is the message payload.

38
00:03:09,540 --> 00:03:12,470
So just one component out of the message object.

39
00:03:12,710 --> 00:03:14,720
And I think I've shown you this before.

40
00:03:14,720 --> 00:03:25,430
This is a date, but you can scroll through a variety of representations for this same value right now.

41
00:03:25,700 --> 00:03:28,640
Going to make a small change to my debug node.

42
00:03:29,000 --> 00:03:36,460
So go in the node and then change the output from message dot payload to the complete message object.

43
00:03:36,470 --> 00:03:44,070
And that will show us exactly what is being passed from one note to the other through messaging.

44
00:03:44,660 --> 00:03:51,470
So clear debug window and then trigger the inject note in here is the complete message.

45
00:03:51,970 --> 00:03:53,270
So instead the complete message.

46
00:03:53,270 --> 00:04:01,130
We've got the payload which contains the data we already seen, plus this attribute here, a message

47
00:04:01,130 --> 00:04:08,930
ID and depending on what else the message is, it may contain other types of attributes in here.

48
00:04:10,070 --> 00:04:18,260
So now that we know that the message object contains other attributes, what it can do is copy that,

49
00:04:18,620 --> 00:04:27,500
go into my debug mode, back into message and just replace the payload with the message ID and you can

50
00:04:27,500 --> 00:04:29,270
probably guess what this is going to do.

51
00:04:31,110 --> 00:04:33,420
It just gives us the message ID.

52
00:04:36,370 --> 00:04:41,640
That may be useful in some circumstances, but in this case, it's more useful if we have the payload.

53
00:04:43,030 --> 00:04:47,530
So I'm going to get this back into the payload configuration for the output.

54
00:04:50,180 --> 00:04:54,950
And always deploy your flu when you make a change for the change to be effective.

55
00:04:55,070 --> 00:04:55,590
OK.

56
00:04:55,610 --> 00:04:58,790
It's back to normal now.

57
00:04:58,850 --> 00:05:03,230
Want to take you back to a previous example, the DHC 22 example.

58
00:05:03,230 --> 00:05:08,000
And I'm going to enable this flu so I can show you.

59
00:05:08,360 --> 00:05:10,730
So here we've got a sequence of notes.

60
00:05:10,730 --> 00:05:17,330
And of course, each note is connected to the next one and passes a data via a message.

61
00:05:17,780 --> 00:05:23,780
Now, I want to have a closer look to what those messages look like and see the differences between

62
00:05:23,780 --> 00:05:27,810
messages that are passed on and created by different notes.

63
00:05:28,370 --> 00:05:34,760
So, again, I'm going to use a series of debug notes.

64
00:05:34,760 --> 00:05:37,410
And just to keep this short, I'm just going to give them numbers.

65
00:05:37,420 --> 00:05:39,110
So this is going to be the first one.

66
00:05:39,110 --> 00:05:48,280
And I want to see the complete message object going to take out another one and connected to the trigger

67
00:05:48,290 --> 00:05:48,800
load.

68
00:05:48,800 --> 00:05:54,770
And I'm going to make that a two and complete message and another debug.

69
00:05:56,020 --> 00:06:01,930
You know, for the DHT 22 Noad, and it's going to be number three, and again, I want to see the complete

70
00:06:01,930 --> 00:06:05,020
message and I need to do that for the last one.

71
00:06:05,170 --> 00:06:06,880
Actually, no, I don't need to.

72
00:06:07,240 --> 00:06:16,120
So I will deploy this through and I will switch to debug clean it up and trigger this flow.

73
00:06:16,720 --> 00:06:18,850
And I can see what is happening.

74
00:06:19,430 --> 00:06:26,290
You've got the first debug node and here is its payload, the complete payload.

75
00:06:26,380 --> 00:06:29,370
The second one looks like this as well.

76
00:06:30,430 --> 00:06:35,660
Nothing fancy in it, but the third one, which is coming out of the twenty two node, you can see that

77
00:06:35,660 --> 00:06:38,800
it contains more attributes.

78
00:06:39,400 --> 00:06:48,730
So there is the message out there, like the other two messages, but then the rest contains information

79
00:06:48,730 --> 00:06:51,970
that is specific to the twenty two node.

80
00:06:51,980 --> 00:06:58,450
So there's a payload with a temperature and there's the humidity, whether it's valid and a few other

81
00:06:58,450 --> 00:07:03,700
things such as that topic, location and sensory data that we have configured in the sensor node.

82
00:07:04,210 --> 00:07:13,060
So just to show you that the actual message configuration depends on the node that creates the message,

83
00:07:13,060 --> 00:07:20,680
but they all have a few shared attributes, such as the message ID and they all do have the payload

84
00:07:20,680 --> 00:07:21,370
attribute.

85
00:07:23,340 --> 00:07:32,610
OK, I'm going to disable the DHT 22 example flow so that it does not continue to produce output and

86
00:07:32,610 --> 00:07:34,980
go back into my messages tab.

87
00:07:39,690 --> 00:07:47,880
Let's continue with the example, so I'm going to disable the timestamp and the timestamp payload and

88
00:07:47,880 --> 00:07:56,490
then enable these to so on and on, this is similar to the first example, except that I don't now have

89
00:07:56,490 --> 00:08:06,750
a string payload so I can actually create payloads of different kinds, like string numbers, booleans,

90
00:08:06,750 --> 00:08:07,200
et cetera.

91
00:08:07,230 --> 00:08:10,460
I'm going to show you an adjacent example in a moment as well.

92
00:08:11,010 --> 00:08:17,940
And whatever it is, it will just pass through to the next node, which should be able to do something

93
00:08:17,940 --> 00:08:18,490
with it.

94
00:08:18,870 --> 00:08:23,700
So the next node here is just the debug printing out the complete message.

95
00:08:23,700 --> 00:08:28,290
Object to the monitor here and it looks like this.

96
00:08:29,750 --> 00:08:35,940
I need to deploy Aikau and clean up and now trigger the InterCloud.

97
00:08:37,310 --> 00:08:45,910
So there's the payload, the full payload object, I can switch back to the message payload only, you

98
00:08:45,910 --> 00:08:47,810
know what this is about to do.

99
00:08:48,920 --> 00:08:50,410
And it looks like this.

100
00:08:50,570 --> 00:08:56,030
We just have the string coming through the debug window.

101
00:08:57,170 --> 00:08:59,450
I just have a look at something more interesting.

102
00:08:59,810 --> 00:09:10,340
And to do that, I will disable these two nodes and then enable the payload node, adjacent payload

103
00:09:10,340 --> 00:09:10,610
node.

104
00:09:11,030 --> 00:09:21,010
So what I've got in this inject node is a valid Jason document, which looks like this.

105
00:09:21,020 --> 00:09:27,350
You can actually use a visual aid, which is very handy if you want to do some more detailed work or

106
00:09:27,350 --> 00:09:33,830
of course, you can use an external adjacent editor there isn't that Jason is very important in node

107
00:09:33,830 --> 00:09:37,640
red is because no direct, as you know, is built on node.

108
00:09:37,850 --> 00:09:38,360
Yes.

109
00:09:38,720 --> 00:09:40,660
Which is a JavaScript framework.

110
00:09:40,670 --> 00:09:45,230
And Jason is fundamental in the JavaScript world.

111
00:09:45,500 --> 00:09:50,410
It is an important standard for data interchange and for data storage.

112
00:09:50,780 --> 00:09:55,490
So in particular, for example, you work with Iot services.

113
00:09:55,490 --> 00:10:01,890
It is likely that those Iot services will be using Jason to receive and sent data.

114
00:10:02,360 --> 00:10:07,670
So it is good to have basic working understanding of Jason.

115
00:10:08,210 --> 00:10:15,530
So to demonstrate how to play around with Jason in notes, starting with this example Jason document.

116
00:10:16,190 --> 00:10:17,630
So from here.

117
00:10:19,280 --> 00:10:20,330
You can.

118
00:10:22,500 --> 00:10:26,070
Send it off to the bug window to see what it looks like.

119
00:10:26,130 --> 00:10:28,310
I'm going to enable this note here.

120
00:10:29,420 --> 00:10:39,410
And deploy my new flu or my updated flu and then trigger to inject note, and this is the simplest thing

121
00:10:39,600 --> 00:10:40,220
you can do.

122
00:10:41,150 --> 00:10:46,280
You can see now that the Jason document is part of the payload.

123
00:10:46,430 --> 00:10:47,900
It is inside payload.

124
00:10:48,200 --> 00:10:53,120
And you can actually see its various notes here.

125
00:10:53,840 --> 00:10:57,680
You can see the data in the Jason document.

126
00:10:58,970 --> 00:11:04,940
From inside the debug window, you can not just see the chasten document that is part of the payload,

127
00:11:04,940 --> 00:11:10,680
but also copy, it's part of any part of the document that you want to work with.

128
00:11:10,700 --> 00:11:16,690
For example, I can use this copy path function.

129
00:11:17,060 --> 00:11:23,920
Now, the path is in a clipboard and I can paste that in a text editor or it can see that later.

130
00:11:23,930 --> 00:11:31,220
You can also use this path if you want to process the data and document itself and give you an example

131
00:11:31,220 --> 00:11:31,820
in a moment.

132
00:11:32,480 --> 00:11:35,170
So this kind of browser is very useful.

133
00:11:36,220 --> 00:11:37,540
Let's move on to the next.

134
00:11:39,120 --> 00:11:46,480
Example, I'm going to disable the adjacent payload node and enable the next one here, which is the

135
00:11:46,480 --> 00:11:55,540
adjacent payload right now I'm using the message payload output, but the Jason expression output and

136
00:11:55,540 --> 00:12:01,240
let's see what this does can clean up and deploy and trigger.

137
00:12:02,140 --> 00:12:08,590
So now we have the actual object printed out into the.

138
00:12:11,510 --> 00:12:12,620
Dipak Winter.

139
00:12:14,860 --> 00:12:19,810
So this is not the full payload object, but just the Jason object itself.

140
00:12:21,660 --> 00:12:26,730
Now, this is good, but still not very useful, let's say, for example, that you wanted to extract

141
00:12:26,730 --> 00:12:35,130
a particular value, it could be the added value for this lost entry object or it could be the abbreviated

142
00:12:35,520 --> 00:12:38,440
attribute or brief attribute that you see here.

143
00:12:38,850 --> 00:12:40,110
How do you do that?

144
00:12:40,500 --> 00:12:42,470
Well, there's a few ways to do that.

145
00:12:43,110 --> 00:12:48,720
Probably the easiest, in my opinion, is to use a little bit of JavaScript, because remember that

146
00:12:48,720 --> 00:12:52,430
Jason and JavaScript were very closely related.

147
00:12:52,890 --> 00:12:54,710
So let's try this out.

148
00:12:54,720 --> 00:13:05,550
I will disable this node and then enable these two nodes go to the information window and enable these

149
00:13:05,550 --> 00:13:05,920
two.

150
00:13:06,180 --> 00:13:06,730
All right.

151
00:13:07,290 --> 00:13:12,350
So what I've got here is a Jason node.

152
00:13:12,370 --> 00:13:17,790
You can find a Jason node in your toolbox on the side and it looks like this.

153
00:13:19,440 --> 00:13:21,300
Now, what I've shown you so far is interesting.

154
00:13:21,630 --> 00:13:27,120
It does give us an idea of how the message object and its payload works.

155
00:13:27,600 --> 00:13:33,480
But if we want to focus specifically on Jason, we'd like to be able to do something more useful with

156
00:13:33,480 --> 00:13:33,670
it.

157
00:13:33,870 --> 00:13:40,800
For example, we'd like to be able to extract a specific item out of the Jason or a specific value out

158
00:13:40,800 --> 00:13:42,360
of the Jason document and show it.

159
00:13:42,960 --> 00:13:51,690
So I'm going to show you the last example that I've prepared for you here, which is composed by these

160
00:13:51,690 --> 00:13:53,310
three nodes.

161
00:13:53,880 --> 00:13:59,090
Remember that Jason and JavaScript are very closely related.

162
00:13:59,100 --> 00:14:05,970
So the easiest way to extract data out of a Jason document is to use a bit of JavaScript.

163
00:14:06,330 --> 00:14:11,110
And of course, there are other ways to do this that you can learn about in the documentation.

164
00:14:11,790 --> 00:14:13,140
So here's an example.

165
00:14:13,770 --> 00:14:25,080
I've got a function node and he can access a function node through the site toolbar and there is a function

166
00:14:25,080 --> 00:14:27,570
or it can just drop it on to your flow.

167
00:14:27,990 --> 00:14:31,800
So inside the function node, you can write a bit of JavaScript.

168
00:14:31,860 --> 00:14:42,360
I remember that the function receives a message that could paint a payload just like any other node

169
00:14:42,360 --> 00:14:49,050
does, and you can access the payload using the images DOD payload notation.

170
00:14:49,650 --> 00:14:57,420
But because this payload contains Jason adjacent document, we can then use further dot notation to

171
00:14:57,420 --> 00:15:02,790
access the individual values and attributes of the Jason document.

172
00:15:03,330 --> 00:15:08,630
So let's say I'm just going to cancel that for a second.

173
00:15:08,640 --> 00:15:13,650
I'm going to show you my chasten document and you can see that down here we've got access to the documentation,

174
00:15:13,650 --> 00:15:17,610
which I have copied in the chasten document itself.

175
00:15:17,610 --> 00:15:18,420
Looks like this.

176
00:15:19,050 --> 00:15:24,570
So let's say that I would like to get the value of the title attribute.

177
00:15:24,880 --> 00:15:33,480
Then what we do is to say Jason document, Daudt Glossary DOT title, and that will return, for example,

178
00:15:33,480 --> 00:15:34,080
glossary.

179
00:15:34,290 --> 00:15:35,930
It can do the same thing elsewhere.

180
00:15:36,630 --> 00:15:44,550
And I also remind you let me show you, I'm going to enable this document here.

181
00:15:44,940 --> 00:15:46,590
This note here should say.

182
00:15:49,320 --> 00:15:52,480
I could also have enabled the other one down the bottom, but it's OK.

183
00:15:52,770 --> 00:16:04,260
So going to the Dipak window and I'm going to trigger this and look at the adjacent payload debug node

184
00:16:04,260 --> 00:16:05,520
output, which is this one.

185
00:16:05,520 --> 00:16:09,240
Here we have the adjacent object.

186
00:16:11,620 --> 00:16:17,470
We can drill down to it, but I just wanted to remind you that you can copy the path of the tribute

187
00:16:18,100 --> 00:16:24,820
that we want to extract the value of by clicking on this copy path button or whichever one it is.

188
00:16:25,480 --> 00:16:37,840
And then we can paste that into our Jason right here to complete the the expression for the attribute

189
00:16:37,840 --> 00:16:40,510
that we want to extract from the chase and document.

190
00:16:41,080 --> 00:16:50,410
So in this case, I have configured my function node to have two outputs and that allows it to have

191
00:16:50,410 --> 00:16:54,700
two outputs visually produced in the note itself.

192
00:16:54,700 --> 00:17:03,120
And then I can connect each of those outputs to a different debug node for those outputs.

193
00:17:03,130 --> 00:17:07,750
I want to pass on to data items.

194
00:17:07,780 --> 00:17:14,380
The first one is a title which I can retrieve with a notation like this, and the second one is the

195
00:17:14,380 --> 00:17:18,490
acronym which again I can retrieve from the Jackson document like this.

196
00:17:19,000 --> 00:17:22,150
And then in my return statement, I've got an array.

197
00:17:23,560 --> 00:17:32,200
And in the array of two tiny Jason documents, both have got a payload and then whatever it is that

198
00:17:32,200 --> 00:17:36,820
I want to pass, which is the title, and for the second one is the acronym.

199
00:17:38,490 --> 00:17:41,260
So with that done, I can then just go.

200
00:17:42,510 --> 00:17:46,900
Pass that information to a debug mode like this.

201
00:17:46,920 --> 00:17:52,320
This one is for the title because this it's the first one and this one is the acronym because it's the

202
00:17:52,320 --> 00:17:52,980
second one.

203
00:17:53,960 --> 00:17:55,400
All right, deploy.

204
00:17:57,150 --> 00:18:05,550
Just to disable the first pilot, just to keep my output clean and deploy, clean the back window and

205
00:18:05,580 --> 00:18:13,800
trigger, and that is your example glossary and then the general values printed out, that's a simple

206
00:18:13,800 --> 00:18:17,640
way to extract the values I want out of adjacent document.

207
00:18:18,480 --> 00:18:23,370
That's actually enough to allow us to continue with the project.

208
00:18:23,490 --> 00:18:26,760
But as I said, there's a lot more that you can do with messages.

209
00:18:27,180 --> 00:18:33,930
And I encourage you to have our at least our quick look at this documentation page to learn more about

210
00:18:33,930 --> 00:18:34,110
it.

211
00:18:34,620 --> 00:18:43,050
Now, in the next lecture, I'm going to talk about firewalls and how you can use variables to also

212
00:18:43,050 --> 00:18:44,280
pass information between.
