1 00:00:00,06 --> 00:00:01,04 - [Instructor] Okay. 2 00:00:01,04 --> 00:00:04,02 So let's give our agent access to a third tool, 3 00:00:04,02 --> 00:00:07,02 in this case the tool to generate a quotation. 4 00:00:07,02 --> 00:00:08,05 Now in this workflow, 5 00:00:08,05 --> 00:00:09,09 there's a lot of things going on, 6 00:00:09,09 --> 00:00:11,03 so we won't be building 7 00:00:11,03 --> 00:00:12,04 this workflow from scratch, 8 00:00:12,04 --> 00:00:14,06 but instead import it from a workflow 9 00:00:14,06 --> 00:00:16,05 that I built before for you. 10 00:00:16,05 --> 00:00:18,08 So for that, go to our repository, 11 00:00:18,08 --> 00:00:21,07 and navigate to the N8N workflows folder. 12 00:00:21,07 --> 00:00:22,09 And in here you will find 13 00:00:22,09 --> 00:00:26,08 a presales agent quote tool.JSON file. 14 00:00:26,08 --> 00:00:28,02 Select this one, 15 00:00:28,02 --> 00:00:31,02 and make sure to download the raw file, 16 00:00:31,02 --> 00:00:34,06 and go back to N8N. 17 00:00:34,06 --> 00:00:38,07 In here, create a new workflow, 18 00:00:38,07 --> 00:00:42,09 and select import from file. 19 00:00:42,09 --> 00:00:45,04 Select the JSON that we just downloaded. 20 00:00:45,04 --> 00:00:46,02 And there you go. 21 00:00:46,02 --> 00:00:48,04 You should see the entire quote generation 22 00:00:48,04 --> 00:00:51,03 process in front of you. 23 00:00:51,03 --> 00:00:52,04 Now let's see how this workflow 24 00:00:52,04 --> 00:00:53,08 is actually working. 25 00:00:53,08 --> 00:00:55,09 Open the when executed by another workflow 26 00:00:55,09 --> 00:00:57,02 trigger node here, 27 00:00:57,02 --> 00:00:59,07 and you can see that this is the data 28 00:00:59,07 --> 00:01:02,01 that this workflow is essentially expecting. 29 00:01:02,01 --> 00:01:03,02 These are two things. 30 00:01:03,02 --> 00:01:05,07 The first thing here is the data object 31 00:01:05,07 --> 00:01:07,04 that we got as a response 32 00:01:07,04 --> 00:01:08,07 from our calculator tool. 33 00:01:08,07 --> 00:01:10,05 Information about the boost type 34 00:01:10,05 --> 00:01:11,06 that should be quoted. 35 00:01:11,06 --> 00:01:14,07 And second, the information about the client. 36 00:01:14,07 --> 00:01:17,06 This is something that the bot has to find out 37 00:01:17,06 --> 00:01:19,01 by asking the client 38 00:01:19,01 --> 00:01:23,06 for their contact information and their company. 39 00:01:23,06 --> 00:01:26,00 When you import this into your N8N instance, 40 00:01:26,00 --> 00:01:28,01 you will probably see some warning signs 41 00:01:28,01 --> 00:01:30,00 on the GitHub icon here. 42 00:01:30,00 --> 00:01:31,08 This is because this is by default 43 00:01:31,08 --> 00:01:33,00 set up to be connected 44 00:01:33,00 --> 00:01:34,04 with my personal GitHub account. 45 00:01:34,04 --> 00:01:36,04 And of course, you have to replace that 46 00:01:36,04 --> 00:01:37,07 with your own username. 47 00:01:37,07 --> 00:01:40,02 So in this case, just update the repository owner 48 00:01:40,02 --> 00:01:41,05 with your own GitHub username, 49 00:01:41,05 --> 00:01:43,07 and make sure that our course repository 50 00:01:43,07 --> 00:01:44,09 is listed from here. 51 00:01:44,09 --> 00:01:46,00 And you would need to do this 52 00:01:46,00 --> 00:01:47,05 for all the three GitHub notes 53 00:01:47,05 --> 00:01:49,02 here in this workflow. 54 00:01:49,02 --> 00:01:51,06 So to demonstrate what this workflow is doing, 55 00:01:51,06 --> 00:01:53,09 let's execute it one time, 56 00:01:53,09 --> 00:01:56,05 and then I can walk you through this. 57 00:01:56,05 --> 00:01:57,04 So at the beginning you can see 58 00:01:57,04 --> 00:02:00,00 there are essentially two path going on. 59 00:02:00,00 --> 00:02:02,07 The first path is to get a template from GitHub. 60 00:02:02,07 --> 00:02:04,05 So this HTML template 61 00:02:04,05 --> 00:02:06,07 will be used to create our quotes. 62 00:02:06,07 --> 00:02:08,07 Let me show you how that template looks. 63 00:02:08,07 --> 00:02:11,00 If you go to our repository, 64 00:02:11,00 --> 00:02:14,07 and then navigate two tools, 65 00:02:14,07 --> 00:02:16,05 quotes, 66 00:02:16,05 --> 00:02:17,06 and template, 67 00:02:17,06 --> 00:02:20,04 you will find this HTML file here. 68 00:02:20,04 --> 00:02:22,05 Now, feel free to download this HTML file. 69 00:02:22,05 --> 00:02:26,01 And then let's take a look. 70 00:02:26,01 --> 00:02:29,00 So this is a simple dummy document, 71 00:02:29,00 --> 00:02:30,09 but you can see what's going on here. 72 00:02:30,09 --> 00:02:32,06 There's some placeholders for variables 73 00:02:32,06 --> 00:02:33,05 that are coming in, 74 00:02:33,05 --> 00:02:36,00 like the client name, our organization's name, 75 00:02:36,00 --> 00:02:37,00 the quote ID, 76 00:02:37,00 --> 00:02:38,05 the date, and of course 77 00:02:38,05 --> 00:02:40,08 the actual thing that should be quoted. 78 00:02:40,08 --> 00:02:42,00 And what the N8N flow 79 00:02:42,00 --> 00:02:44,00 is essentially doing is just replace 80 00:02:44,00 --> 00:02:46,02 those variables with the variables 81 00:02:46,02 --> 00:02:48,03 that are coming in in our workflow. 82 00:02:48,03 --> 00:02:49,09 So let's see how that works. 83 00:02:49,09 --> 00:02:51,01 So we need two things. 84 00:02:51,01 --> 00:02:53,02 The first thing is the HTML document, 85 00:02:53,02 --> 00:02:55,06 which we get from this simple HTTP request. 86 00:02:55,06 --> 00:02:58,02 This is just downloading the HTML source code 87 00:02:58,02 --> 00:02:59,04 from GitHub. 88 00:02:59,04 --> 00:03:00,04 And then second, 89 00:03:00,04 --> 00:03:02,00 the variables that came in 90 00:03:02,00 --> 00:03:04,08 from our workflow execution. 91 00:03:04,08 --> 00:03:05,07 In this code sale, 92 00:03:05,07 --> 00:03:07,08 we're actually modifying them a little bit 93 00:03:07,08 --> 00:03:09,01 to for example, 94 00:03:09,01 --> 00:03:11,01 generate a quote ID automatically 95 00:03:11,01 --> 00:03:12,08 based on the current date, 96 00:03:12,08 --> 00:03:14,03 and also calculate the date 97 00:03:14,03 --> 00:03:16,05 until which the quote should be valid. 98 00:03:16,05 --> 00:03:17,07 All the other information 99 00:03:17,07 --> 00:03:20,00 are pulled in from the incoming documents 100 00:03:20,00 --> 00:03:21,09 or they are defined with standard values 101 00:03:21,09 --> 00:03:22,08 like for example, 102 00:03:22,08 --> 00:03:25,05 our own sales email address here. 103 00:03:25,05 --> 00:03:26,09 So let's close this for now. 104 00:03:26,09 --> 00:03:27,08 This merge node 105 00:03:27,08 --> 00:03:29,07 is then bringing everything together, 106 00:03:29,07 --> 00:03:31,07 the data from the HTML document 107 00:03:31,07 --> 00:03:33,04 plus our variables. 108 00:03:33,04 --> 00:03:35,05 And then in the next code node, 109 00:03:35,05 --> 00:03:38,04 this is simply a regular expression 110 00:03:38,04 --> 00:03:40,03 that is replacing the variables 111 00:03:40,03 --> 00:03:42,01 with the variable placeholders 112 00:03:42,01 --> 00:03:44,03 in our HTML document. 113 00:03:44,03 --> 00:03:46,03 And it returns an HTML document 114 00:03:46,03 --> 00:03:49,03 that now contains the replaced variables. 115 00:03:49,03 --> 00:03:52,01 So you can see how that looks here 116 00:03:52,01 --> 00:03:53,04 because on GitHub, 117 00:03:53,04 --> 00:03:55,06 it will automatically create a file 118 00:03:55,06 --> 00:03:57,03 with the updated quote, 119 00:03:57,03 --> 00:03:59,05 and we can take a look how that quote looks. 120 00:03:59,05 --> 00:04:03,03 So if we go to quotes and go to new, 121 00:04:03,03 --> 00:04:06,02 this is where these quotes have been stored, 122 00:04:06,02 --> 00:04:07,05 and let's take a look at the quote 123 00:04:07,05 --> 00:04:09,08 that we just generated. 124 00:04:09,08 --> 00:04:12,05 Let's download this one. 125 00:04:12,05 --> 00:04:14,02 And 126 00:04:14,02 --> 00:04:15,01 there you go. 127 00:04:15,01 --> 00:04:16,07 This is the quote that was just generated 128 00:04:16,07 --> 00:04:17,07 on the fly. 129 00:04:17,07 --> 00:04:18,06 Just to make sure, 130 00:04:18,06 --> 00:04:20,04 there is no large language model 131 00:04:20,04 --> 00:04:22,00 involved here at this stage. 132 00:04:22,00 --> 00:04:23,02 The large language model 133 00:04:23,02 --> 00:04:25,05 is really just giving the information 134 00:04:25,05 --> 00:04:26,04 to this workflow, 135 00:04:26,04 --> 00:04:28,04 and then this workflow is doing a simple search, 136 00:04:28,04 --> 00:04:29,08 and replace option. 137 00:04:29,08 --> 00:04:31,01 This is done by design. 138 00:04:31,01 --> 00:04:32,05 We don't want the LLM 139 00:04:32,05 --> 00:04:34,06 to generate the quote on the fly. 140 00:04:34,06 --> 00:04:36,05 There could be too many sources of error 141 00:04:36,05 --> 00:04:37,05 or manipulation. 142 00:04:37,05 --> 00:04:39,05 We want to leave this encapsulated 143 00:04:39,05 --> 00:04:41,07 into a deterministic workflow 144 00:04:41,07 --> 00:04:43,04 where no AI is involved. 145 00:04:43,04 --> 00:04:44,05 This is just really 146 00:04:44,05 --> 00:04:45,09 putting in all the information 147 00:04:45,09 --> 00:04:47,02 that we already collected 148 00:04:47,02 --> 00:04:49,02 into the quote process here. 149 00:04:49,02 --> 00:04:51,00 Now, what's actually coming out of the workflow 150 00:04:51,00 --> 00:04:52,07 that we have in N8N? 151 00:04:52,07 --> 00:04:55,01 Because we can't simply give a binary file 152 00:04:55,01 --> 00:04:56,00 back to the agent, 153 00:04:56,00 --> 00:04:57,08 it couldn't work with that binary file, 154 00:04:57,08 --> 00:04:59,06 or it would be really, really complicated 155 00:04:59,06 --> 00:05:00,09 for the agent to do this. 156 00:05:00,09 --> 00:05:04,09 So instead, what we return is just a URL. 157 00:05:04,09 --> 00:05:05,07 In this case, 158 00:05:05,07 --> 00:05:08,09 it's a URL to the HTML file hosted on GitHub 159 00:05:08,09 --> 00:05:12,04 with this little prefix here that is allowing us 160 00:05:12,04 --> 00:05:14,08 to render this file on the fly. 161 00:05:14,08 --> 00:05:16,06 So to show you how that works, 162 00:05:16,06 --> 00:05:18,06 let me just execute this workflow once more 163 00:05:18,06 --> 00:05:23,00 so we get a fresh URL that is being generated. 164 00:05:23,00 --> 00:05:24,06 And you can see this is the URL 165 00:05:24,06 --> 00:05:27,03 that would now be returned to the agent. 166 00:05:27,03 --> 00:05:29,00 If we copy this URL, 167 00:05:29,00 --> 00:05:31,02 and paste it into the browser, 168 00:05:31,02 --> 00:05:33,02 we will automatically get a rendered version 169 00:05:33,02 --> 00:05:34,05 of this quotation. 170 00:05:34,05 --> 00:05:36,02 And this is now something we can 171 00:05:36,02 --> 00:05:38,02 either give to the client directly 172 00:05:38,02 --> 00:05:39,05 inside the chat, 173 00:05:39,05 --> 00:05:41,07 or this is something we could plug into an email 174 00:05:41,07 --> 00:05:43,05 that we send out to that person, 175 00:05:43,05 --> 00:05:44,05 which is exactly 176 00:05:44,05 --> 00:05:46,05 what we're gonna do in the next steps. 177 00:05:46,05 --> 00:05:47,05 But before we get there, 178 00:05:47,05 --> 00:05:48,09 let's first go back, 179 00:05:48,09 --> 00:05:51,03 and see how we now bring this workflow 180 00:05:51,03 --> 00:05:54,00 back to N8N and give our agent 181 00:05:54,00 --> 00:05:56,01 access to this little quote tool 182 00:05:56,01 --> 00:05:57,03 that we have just built. 183 00:05:57,03 --> 00:06:00,00 And I'll see you on the next video for that.