1 00:00:00,06 --> 00:00:03,02 - [Instructor] So our agent has come a really long way. 2 00:00:03,02 --> 00:00:06,00 We have already added three tools to our agent, 3 00:00:06,00 --> 00:00:06,08 the knowledge tool 4 00:00:06,08 --> 00:00:09,04 to gather information about the exhibition, 5 00:00:09,04 --> 00:00:11,07 the calculator tool to calculate a price 6 00:00:11,07 --> 00:00:13,01 for a given booth type, 7 00:00:13,01 --> 00:00:14,04 and a quote generator tool 8 00:00:14,04 --> 00:00:17,05 to actually create a quote in an HTML file. 9 00:00:17,05 --> 00:00:19,02 The only missing piece now is a connection 10 00:00:19,02 --> 00:00:20,04 to an email account 11 00:00:20,04 --> 00:00:23,07 so the agent can actually also send out an email, 12 00:00:23,07 --> 00:00:27,01 either directly through the client or store it as a draft 13 00:00:27,01 --> 00:00:30,00 or send the client to our internal sales team 14 00:00:30,00 --> 00:00:32,06 so they can actually follow up with that person. 15 00:00:32,06 --> 00:00:34,02 Now, that's what we're gonna do now. 16 00:00:34,02 --> 00:00:35,00 The good news is 17 00:00:35,00 --> 00:00:37,09 we don't have to build this email integration from scratch. 18 00:00:37,09 --> 00:00:39,04 In n8n, there are plenty 19 00:00:39,04 --> 00:00:42,00 of pre-built email connectors available. 20 00:00:42,00 --> 00:00:45,06 If you click Tools, you will see that under Other Tools, 21 00:00:45,06 --> 00:00:47,03 there are lots of different integrations 22 00:00:47,03 --> 00:00:50,00 to different email service providers. 23 00:00:50,00 --> 00:00:52,08 If you want to connect it to a custom email integration, 24 00:00:52,08 --> 00:00:54,09 you can use this Send Email tool, 25 00:00:54,09 --> 00:00:59,00 which sends an email using a simple SMTP protocol. 26 00:00:59,00 --> 00:01:02,05 For our purpose now, we will rely on a pre-built connector 27 00:01:02,05 --> 00:01:04,09 that is using Gmail to send out the email. 28 00:01:04,09 --> 00:01:08,05 So just look for Gmail at this tool, 29 00:01:08,05 --> 00:01:10,08 and now you have the possibility to connect n8n 30 00:01:10,08 --> 00:01:12,06 with your Gmail account. 31 00:01:12,06 --> 00:01:16,01 Just select this dropdown and click Create New Credential. 32 00:01:16,01 --> 00:01:18,06 For demo purposes, I highly recommend setting up 33 00:01:18,06 --> 00:01:20,03 a new email account for this, 34 00:01:20,03 --> 00:01:23,02 just for demonstration and learning purposes. 35 00:01:23,02 --> 00:01:24,04 Once you have done that, 36 00:01:24,04 --> 00:01:27,06 as I did it in my case here, you are connected to Gmail 37 00:01:27,06 --> 00:01:31,07 and you can now automatically define which field should be 38 00:01:31,07 --> 00:01:33,05 filled out by the AI. 39 00:01:33,05 --> 00:01:35,01 We can leave the tool description 40 00:01:35,01 --> 00:01:37,05 to be set automatically as a resource. 41 00:01:37,05 --> 00:01:40,05 We don't select message, but we change it to draft 42 00:01:40,05 --> 00:01:43,06 because we don't want n8n to send out emails right away. 43 00:01:43,06 --> 00:01:46,01 For now, we just wanna see if everything is working. 44 00:01:46,01 --> 00:01:48,03 And also at this point, it's quite a good idea 45 00:01:48,03 --> 00:01:50,03 to have a human at least look over the emails 46 00:01:50,03 --> 00:01:52,06 before they are being sent out to clients. 47 00:01:52,06 --> 00:01:55,06 So as an operation, let's create a draft 48 00:01:55,06 --> 00:01:57,09 and then define the different fields. 49 00:01:57,09 --> 00:01:59,06 For example, the subject line, 50 00:01:59,06 --> 00:02:02,02 we could either have AI generate that automatically, 51 00:02:02,02 --> 00:02:05,05 or we could pre-fill it with a custom line 52 00:02:05,05 --> 00:02:08,03 that is always being used as the subject line, 53 00:02:08,03 --> 00:02:11,06 as for example, "Here is your quote." 54 00:02:11,06 --> 00:02:14,08 This can be useful if you want to have more consistency 55 00:02:14,08 --> 00:02:17,02 on especially things like a subject line. 56 00:02:17,02 --> 00:02:19,09 You could of course, also specify a subject line 57 00:02:19,09 --> 00:02:21,09 in the instructions of the prompt. 58 00:02:21,09 --> 00:02:24,00 This will give you a higher probability 59 00:02:24,00 --> 00:02:26,02 that the agent is actually using a subject line 60 00:02:26,02 --> 00:02:27,07 as you define there. 61 00:02:27,07 --> 00:02:29,01 So for now, I don't really care 62 00:02:29,01 --> 00:02:30,04 about the subject line too much. 63 00:02:30,04 --> 00:02:32,07 So I say that the model should define 64 00:02:32,07 --> 00:02:34,06 this subject line parameter. 65 00:02:34,06 --> 00:02:36,02 Next is the email type. 66 00:02:36,02 --> 00:02:38,04 We can select between text and HTML. 67 00:02:38,04 --> 00:02:40,01 In this case, I'm using HTML, 68 00:02:40,01 --> 00:02:42,09 and I'm also letting the agent define the message for me. 69 00:02:42,09 --> 00:02:45,03 If you check again the system prompt, you will see 70 00:02:45,03 --> 00:02:48,01 that the system prompt contains some light instructions 71 00:02:48,01 --> 00:02:51,03 on how the agent should formulate this email. 72 00:02:51,03 --> 00:02:53,02 Of course, you could add your own templates here, 73 00:02:53,02 --> 00:02:54,02 either in the instructions 74 00:02:54,02 --> 00:02:57,08 or customize this message here according to your needs. 75 00:02:57,08 --> 00:02:59,02 Now, there's one more thing we need to add, 76 00:02:59,02 --> 00:03:01,03 which is the two email address. 77 00:03:01,03 --> 00:03:03,04 So this is the email address that should be used, 78 00:03:03,04 --> 00:03:06,04 and this is also something we want the AI agent to control. 79 00:03:06,04 --> 00:03:09,07 So the AI agent should either add the email address 80 00:03:09,07 --> 00:03:11,07 of the client here or the email address 81 00:03:11,07 --> 00:03:14,01 of our internal sales department if the email should be 82 00:03:14,01 --> 00:03:17,03 forwarded because maybe it's a very high-prospect leader, 83 00:03:17,03 --> 00:03:20,00 they inquired for a really large booth size. 84 00:03:20,00 --> 00:03:21,03 Now, let's close this for now 85 00:03:21,03 --> 00:03:22,06 because this is everything we need 86 00:03:22,06 --> 00:03:24,04 to set up the email integration. 87 00:03:24,04 --> 00:03:25,06 And there you have it. 88 00:03:25,06 --> 00:03:28,08 We have now four tools integrated into our agent. 89 00:03:28,08 --> 00:03:31,05 We have the knowledge tool, the calculator tool, 90 00:03:31,05 --> 00:03:34,00 the quote generator tool, and the Gmail tool. 91 00:03:34,00 --> 00:03:36,04 And one quick heads up, of course, now we need 92 00:03:36,04 --> 00:03:39,03 to at least have the email field defined 93 00:03:39,03 --> 00:03:41,01 before we can actually send out an email 94 00:03:41,01 --> 00:03:43,02 or the agent can use that. 95 00:03:43,02 --> 00:03:45,05 So as I mentioned before, at some point we need 96 00:03:45,05 --> 00:03:48,05 to tell the agent that this is a required field. 97 00:03:48,05 --> 00:03:51,00 I added it here in the quote generator tool 98 00:03:51,00 --> 00:03:53,04 where I added few more information about 99 00:03:53,04 --> 00:03:55,04 what is the required information. 100 00:03:55,04 --> 00:03:58,05 Since we need a quote before we can send out an email 101 00:03:58,05 --> 00:03:59,08 and we now need an email 102 00:03:59,08 --> 00:04:02,08 before we can generate a quote, everything is intact. 103 00:04:02,08 --> 00:04:04,09 Just double-check that whatever you need in order 104 00:04:04,09 --> 00:04:07,03 to call these tools is actually available 105 00:04:07,03 --> 00:04:08,08 and you also let the agent know 106 00:04:08,08 --> 00:04:11,05 that these fields are required at some point, 107 00:04:11,05 --> 00:04:14,05 as I did here, for example, in the quote generator tool. 108 00:04:14,05 --> 00:04:18,00 So let's close this and actually see the agent in action.