WEBVTT

00:00.880 --> 00:01.800
Welcome back.

00:01.840 --> 00:08.840
In this lesson, we are breaking down how Nathan handles data so you can build cleaner, more efficient

00:08.840 --> 00:09.600
workflows.

00:10.000 --> 00:18.480
By the end of this video, you will understand how Nathan structures data with JSON and lists how nodes

00:18.600 --> 00:24.640
process and parse data, and how to use expressions to modify and work with that data.

00:25.120 --> 00:27.040
So let's get straight into it.

00:33.480 --> 00:33.960
All right.

00:33.960 --> 00:35.560
So let's start with the basics.

00:36.160 --> 00:44.920
Nathan processes everything in JSON, which is just a fancy way of saying data is stored in key value

00:45.400 --> 00:46.040
pairs.

00:47.160 --> 00:51.080
So for example a JSON object might look like this.

00:52.720 --> 00:56.880
You have a key and value key and corresponding value.

00:58.960 --> 01:00.000
Easy enough right.

01:00.400 --> 01:03.640
So now what if you have multiple records.

01:04.690 --> 01:06.450
That's where lists come in.

01:07.370 --> 01:11.970
Because a list is just a collection of multiple JSON objects.

01:13.170 --> 01:16.730
So this is one list of two JSON objects.

01:18.610 --> 01:22.250
So think of it like rows in a spreadsheet.

01:22.890 --> 01:25.650
Each JSON object is a row of data.

01:26.290 --> 01:29.490
This is how an A-10 handles multiple items at once.

01:33.410 --> 01:36.730
So how do nodes actually handle this data?

01:37.090 --> 01:43.410
Each JSON object is called an item, and nodes process one item at a time.

01:43.890 --> 01:49.010
So let's say we have three dates to format a date and time.

01:49.050 --> 01:54.730
Node will process each item separately so it runs three times once per item.

01:56.570 --> 02:04.610
So if an if node checks for customer with a Gmail email, it will process each email individually and

02:04.610 --> 02:07.090
only pass through the ones that match.

02:08.990 --> 02:15.190
And the best practice is to always keep in mind how many items your note is processing.

02:15.430 --> 02:18.550
So this is super important when building workflows.

02:20.230 --> 02:24.590
Now fix fields versus expression fields.

02:25.430 --> 02:32.550
So when filling out fields in return you might notice some fields behave differently because there are

02:32.830 --> 02:35.230
fixed fields which always stay the same.

02:35.510 --> 02:40.350
And expression fields which dynamically change based on input data.

02:40.870 --> 02:47.590
So let's say you are sending an email and you could set the subject to welcome to our service.

02:48.750 --> 02:59.990
So this is this will always be the same while expression subject welcome and then JSON object.

03:00.990 --> 03:03.070
This adapts based on user data.

03:03.630 --> 03:09.390
So if a field allows expressions you will see the little f button.

03:11.150 --> 03:15.720
And you need to click to switch between fixed and dynamic values.

03:17.840 --> 03:23.600
Best practice is always to use expressions if the data is different for each item.

03:24.280 --> 03:33.840
So you can dynamically input data so you don't need to hard code your data like provide the actual name

03:33.840 --> 03:34.800
of the user.

03:34.960 --> 03:41.280
You can just use JSON object and the correct name will be passed into field.

03:41.880 --> 03:47.480
We will explore this topic on practical examples in N810, so don't worry.

03:49.840 --> 03:51.640
Now let's talk about expressions.

03:53.880 --> 03:57.160
So we use expressions to access and modify data.

03:59.320 --> 04:03.800
This is how you access, modify and format data dynamically.

04:06.560 --> 04:09.640
So for example you want to grab a customer's email.

04:10.520 --> 04:12.240
You need to use this expression.

04:13.640 --> 04:19.370
But if you need to combine a first and last name, you can easily do it using expression.

04:20.930 --> 04:27.130
Now the best practice is to use expressions to reference and format data dynamically.

04:29.210 --> 04:35.410
So instead of hard coding values, your workflow always works with real time data.

04:37.810 --> 04:43.570
Now next we have data transformation with set function and code nodes.

04:44.970 --> 04:50.010
Now what if you need to modify data before passing it to another node?

04:50.490 --> 04:52.850
In N810 you have three main tools.

04:53.810 --> 05:00.210
Head node which is great for renaming, removing or adding simple fields.

05:00.850 --> 05:06.410
Function node lets you write small JavaScript snippets and code.

05:06.450 --> 05:09.090
Node when you need to.

05:10.010 --> 05:15.770
When you need more advanced transformations to handle complex logic, which is not possible in expressions.

05:16.450 --> 05:19.950
For example, you want to convert a name to uppercase.

05:20.870 --> 05:23.950
So you use expression the function node alternative.

05:24.150 --> 05:27.670
Looks like that which is written in JavaScript language.

05:31.870 --> 05:38.110
And the best practice is always use the simplest method first and only use code when it's necessary.

05:38.750 --> 05:45.630
And there is no many use cases where you have to use code to build powerful automations and agents.

05:48.910 --> 05:49.350
All right.

05:49.350 --> 05:52.190
So now let's talk about nested JSON data.

05:52.750 --> 05:56.990
This comes up a lot when working with APIs and databases.

05:57.270 --> 06:03.710
So sometimes instead of simple key value pairs you will get objects inside objects.

06:04.670 --> 06:13.430
As you can see we have object name inside user object which you can notice thanks to indentation.

06:14.790 --> 06:23.560
If you try JSON email, it won't work because the email is inside user contact object.

06:24.920 --> 06:28.000
So instead you need to reference it properly.

06:28.560 --> 06:32.160
So JSON dot user dot contact dot email.

06:33.040 --> 06:36.960
Best practice is if you are dealing with deeply nested data.

06:37.200 --> 06:40.800
Use a set node to restructure it first.

06:41.600 --> 06:44.600
So how does this all work together in real workflow?

06:47.320 --> 06:51.880
Pulling the trigger like a webhook or manual trigger to start the workflow.

06:52.520 --> 06:55.600
Then data retrieval.

06:56.320 --> 07:02.480
So to fetch the data you need, you need data retrieval node like Google Sheets.

07:03.360 --> 07:04.520
Then processing.

07:05.560 --> 07:12.440
So the data gets modified, filtered or formatted and finally output.

07:12.720 --> 07:17.960
So the processed data gets sent to another tool or system like slack.

07:19.440 --> 07:27.770
Let's say you pull data from Google Sheets and if it returns three rows and if not, filter out one

07:27.770 --> 07:31.090
row, leaving only two rows for the next step.

07:31.890 --> 07:36.010
To pass this data to pass these two rows to slack.

07:37.250 --> 07:44.170
So this is why understanding how naa10 processes items is is key, because each step transforms the

07:44.170 --> 07:49.250
data before it moves, before it moves to the next node.

07:52.490 --> 07:55.490
Now understanding input and output of nodes.

07:55.970 --> 08:02.930
So if a node is not working the way you expect, the issue is usually the input format.

08:03.370 --> 08:06.810
So every node expects data in a specific structure.

08:07.090 --> 08:12.410
So if it doesn't match you might get errors or unexpected results.

08:12.930 --> 08:19.090
So for example you call an API and it returns this JSON.

08:22.050 --> 08:30.730
But your next node is looking for JSON email which doesn't exist at this level because your email.

08:32.150 --> 08:34.550
is in data JSON object.

08:35.910 --> 08:40.550
So to fix it you need to add the reference.

08:40.990 --> 08:44.310
So body dot data dot email.

08:45.470 --> 08:48.470
The best practice is if something is not working.

08:48.470 --> 08:51.830
Always check the execution data of the previous node.

08:52.270 --> 08:56.190
So that will show you exactly what's being passed.

09:00.910 --> 09:02.470
Now why this matters.

09:02.830 --> 09:12.030
So understanding how attend processes data helps you avoid workflow errors when handling multiple items.

09:14.390 --> 09:18.230
It makes your automations faster and more efficient.

09:18.630 --> 09:25.670
And once you get comfortable with expressions and data handling, you can build way more powerful workflows.

09:26.070 --> 09:31.430
So if you ever get stuck with inputs, outputs, or expressions, come back to this lesson.

09:31.950 --> 09:34.590
I hope this was helpful and see you in the next one.
