Latest / AI Fire Daily / #209 Max: Build Your First AI Email Assistant in n8n (Part 1: The "Brain")
Transcript
- 0:00You know, the average person, I think, spends
- 0:01hours, literally hours, every single week just
- 0:04sorting, filing, reading emails, so much stuff
- 0:08that probably didn't need their immediate human
- 0:11attention. It's this constant drain. It really
- 0:14is. It's like the silent killer of real productive
- 0:16work. But imagine flipping that. Imagine having,
- 0:19like, a personal AI assistant doing that heavy
- 0:22lifting for you, making those little decisions,
- 0:24processing new messages in, what, under 15 seconds?
- 0:27Yeah. And the best part, you build it. No code
- 0:30required. None. Welcome back to the Deep Dive.
- 0:33Today, we are really getting into the foundations.
- 0:35We're extracting the core ideas from this really
- 0:39detailed no code guide. Our mission is pretty
- 0:41clear. Build the core intelligence, the AI brain,
- 0:45if you will, for an automated email agent that
- 0:47reads, classifies, and basically organizes your
- 0:50messages. even while you sleep and this isn't
- 0:53just theory right we're diving deep into the
- 0:55actual blueprint yeah the tools you need we're
- 0:57talking nan gmail open router yeah and the four
- 1:00big steps to get this intelligent core up and
- 1:02running okay let's unpack that so this time we're
- 1:05focusing just on that decision making engine
- 1:07the intelligence and the filing system call it
- 1:10part one Building the brain. Exactly. Part two,
- 1:13that's later. That's going to be all about the
- 1:16automated actions, the doing part. Right. So
- 1:18the core problem we're tackling today, it's pretty
- 1:20universal, isn't it? Information overload, just
- 1:23drowning in emails, constantly pulled away from
- 1:27the work that actually matters. Totally. We all
- 1:29feel it. And the whole system, once it's all
- 1:31built out, it follows this really neat kind of
- 1:34simple four -stage loop. Stage one, the trigger.
- 1:37Okay. That's just a new email landing in your
- 1:40inbox. Think of it like the doorbell ringing.
- 1:42Okay, the doorbell. Then stage two, that's the
- 1:44intelligence part we're building today, right?
- 1:46The AI collectification. Yep. The system reads
- 1:49the subject, reads the body, the whole body,
- 1:51and decides instantly, which bucket does this
- 1:54go in? We're starting with four main ones, customer
- 1:56support, finance billing, high priority, and
- 1:59promotion. And once it knows the bucket. Stage
- 2:03three, labeling. Simple as that. The agent slaps
- 2:06the right. Gmail label on it automatically. That's
- 2:09your filing system right there in the inbox.
- 2:11Okay. And stage four, that's for next time. Stage
- 2:12four is the automated actions. That's where it
- 2:15gets really cool, like sending an AI generated
- 2:17reply or maybe pinging your team on Slack, stuff
- 2:20like that. The shift here feels significant.
- 2:23You're taking this repetitive cognitive sorting
- 2:26task and just handing it off to a system that
- 2:29doesn't get tired, doesn't get distracted. And
- 2:32the source mentioned this test result. processing
- 2:35and even responding in about 15 seconds total.
- 2:3815 seconds. Whoa. Think about that. Seriously.
- 2:41Imagine scaling that. If you get, say, 50 emails
- 2:44a day that need sorting, that's real time you
- 2:47get back. It just handles the grunt work immediately.
- 2:49So if something is genuinely urgent. It's flagged,
- 2:52labeled, sitting there waiting for your actual
- 2:54human expertise, not buried under newsletters.
- 2:57So thinking about that, how does automating the
- 2:59sorting fundamentally change how you even define
- 3:02what's urgent work? Well, it just cuts through
- 3:04the noise, doesn't it? Yeah. It ensures that
- 3:06only the stuff that really needs your eyes and
- 3:08brain gets through that filter. Everything else
- 3:11is neatly filed. Okay. Makes sense. So let's
- 3:15talk tools. The blueprint. Right. So to actually
- 3:18connect all this and build the brain, you only
- 3:20need three main tools. That's the beauty of this
- 3:23whole no -code thing. The infrastructure is mostly
- 3:25there. First up is N -A -A -N. If you haven't
- 3:28used it, think of it like a visual workflow builder.
- 3:31You drag, you drop, you connect apps. No traditional
- 3:33coding needed. It's where we map out the logic.
- 3:36Then, obviously, Gmail. That's our inbox for
- 3:38this example, our trigger point. Yeah. But the
- 3:40logic works for Outlook, too, pretty much anything
- 3:42similar. Okay. And number three, OpenRouter.
- 3:44This thing is great. It's basically a gateway
- 3:46to lots of different AI models. Instead of juggling
- 3:50API keys for GPT, Claude, whatever, OpenRouter
- 3:53gives you one key. Simple access to powerful
- 3:56models like, say, GPT 4 .1 Mini, or even the
- 4:00really cutting -edge ones if you need them. And
- 4:01it's usually cheaper. Now, the guide really hammers
- 4:04this point home. Wireframing. Mapping it out
- 4:06visually before you even open any. You know,
- 4:08measure twice, cut once. Yeah. But honestly,
- 4:12for a workflow that seems like just four main
- 4:14steps, is wireframing really necessary? Doesn't
- 4:18it feel a bit like overkill? That's a fair question.
- 4:21But yes, absolutely. It matters even for small
- 4:24stuff. Yeah. Because automation complexity, it
- 4:29doesn't scale linearly. It gets messy fast. Think
- 4:33of that blueprint trigger classifier, the four
- 4:34branches, the actions. That's your map. It's
- 4:37like. Disaster prevention. When something breaks
- 4:39later, and it might, you look at the map, you're
- 4:41not just clicking around blindly in NANA trying
- 4:43to figure out where the logic went wrong. It
- 4:45forces you to think through the flow first. So,
- 4:47bottom line, why is mapping it out first so critical
- 4:50even before touching the tools? It just prevents
- 4:53that initial overwhelm. Yeah. You define the
- 4:55logic clearly before you get tangled up in the
- 4:57connections and settings. Saves a lot of headaches.
- 4:59Got it. Okay. Blueprint's ready. Step one, the
- 5:01trigger. Setting up that doorbell. Right. So,
- 5:04new N8n workflow. You grab the Gmail node and
- 5:08you pick the on message received trigger. Simple.
- 5:11Then you just connect your Gmail account, right?
- 5:13Give a credential. Yep. And Annie Dan will start
- 5:15checking usually about every minute for new mail.
- 5:18Pretty quick. And for testing, you just send
- 5:20yourself an email, something basic? Exactly.
- 5:22Like subject, help, and body. My account isn't
- 5:25working. Fire that off. Then in Annie Dan, you
- 5:28hit fetch test event. That pulls in the data
- 5:31from your test email. Okay. And here comes the
- 5:33key part you mentioned. Ah, yeah. This is the
- 5:34crucial bit. The secret sauce, maybe. By default,
- 5:37N8N tries to be helpful. It simplifies the data
- 5:41it pulls from Gmail. Right. You absolutely must
- 5:43turn the simplify toggle OFF on that Gmail trigger
- 5:47node. Okay. That's the expert move. I remember
- 5:49wasting, I don't know, probably an hour once
- 5:51on a different automation because I only had
- 5:53partial data coming through. Turning off simplify
- 5:55gets you everything. Everything. The full email
- 5:58body, sender info, attachments, and crucially,
- 6:01the unique message ID for that specific email.
- 6:04And that full context matters for the AI. Vitally
- 6:07important. If the AI only sees subject, H -E
- 6:11-L -P, I think it's spam. But if it sees the
- 6:14body says H -E -L -P, the main server is down,
- 6:18that's different. Full text equals accurate classification.
- 6:21Right. So fetch that full data, then pin it in
- 6:24N8N. That means you can test all the next steps
- 6:27using that same data without sending more emails.
- 6:29Super handy. Okay, quick recap then. What's the
- 6:32absolute essential data the AI needs from that
- 6:35trigger for top accuracy? It needs the whole
- 6:37picture, the complete unsimplified email body,
- 6:40and the subject line for maximum context. Perfect.
- 6:43All right. Data stream is flowing. Step two,
- 6:45building the actual intelligence, the sorting
- 6:48hat. Yep. Add the text classifier node right
- 6:50after your Gmail trigger. Now we need to tell
- 6:52it what text to analyze. How do you feed it the
- 6:54right stuff? You switch the input field to expression
- 6:56mode. Yeah. Then you use this specific structure,
- 6:59subject .headers .body .text. It looks a bit
- 7:03technical, but all it's doing is grabbing the
- 7:05subject from the incoming data, grabbing the
- 7:07body text, and sticking them together for the
- 7:09AI. So it sees both at the same time. Makes sense.
- 7:11Exactly. Then comes the really important part,
- 7:14defining your categories. This is pure prompt
- 7:17engineering. This is the brain, basically. The
- 7:20AI only knows what you tell it. Fuzzy instructions
- 7:23mean fuzzy results. So those four buckets we
- 7:25mentioned, customer support, finance, high priority,
- 7:28promotion, we need clear descriptions. Crystal
- 7:31clear. Precision is key. For customer support,
- 7:35think keywords. Error, issue, help, troubleshoot.
- 7:38For finance billing, obviously, invoice, payment,
- 7:41refund, subscription. Promotion is easy. Sale,
- 7:44offer, discount. And high priority needs words
- 7:47like urgent, ASA, critical, outage, emergency.
- 7:51And you have to be careful they don't overlap
- 7:53too much, right? Like what if an email says urgent
- 7:56invoice payment failed? Is that finance or high
- 7:58priority? Good point. That's exactly where the
- 8:01description part of the prompt becomes critical.
- 8:02You need to guide the AI. Maybe you say high
- 8:05priority is only for system outages or critical
- 8:07deadlines and payment issues go to finance unless
- 8:10they use specific emergency language. You have
- 8:13to define that nuance. And this is where things
- 8:14can go sideways if you're not careful. Oh, yeah.
- 8:17Clarity is your debugging tool here. And honestly.
- 8:21I still wrestle with prompt drift myself sometimes.
- 8:24You know, where the AI kind of slowly misunderstands
- 8:28your original intent over time. Yeah, I've seen
- 8:30that. Keeping those category descriptions tight
- 8:32and precise is your best defense. If classifications
- 8:35start going weird, the first place you check
- 8:38is that description text. Did I make it ambiguous?
- 8:41So why is getting that nuance right, like between
- 8:43finance and high priority, so absolutely essential?
- 8:46Because explicitly telling the AI how to handle
- 8:49those edge cases, those overlapping keywords,
- 8:52prevents it from guessing wrong when it sees
- 8:55ambiguous emails later on. Clarity prevents errors.
- 8:58Okay. Brain structure defined. Now it needs power.
- 9:01Step three. Connecting the engine. The text classifier
- 9:05node has the instructions, but it needs a large
- 9:07language model and LLM to actually do the thinking.
- 9:10And that's where OpenRouter comes in. Exactly.
- 9:12Set up an account, you'll need to add billing
- 9:14info, even just for the free credits they usually
- 9:16give you, then generate an API key. Good practice
- 9:19to name it something specific like inbox agent
- 9:21key. And you just paste that key into N8N. Yep.
- 9:24Right into the text classifier node settings
- 9:25where it asks for your chat model credentials
- 9:27or API key. Connects it right up. What about
- 9:30choosing the actual AI model? There are so many
- 9:33options. For this kind of classification, the
- 9:35guide suggests GPT 4 .1 mini. It's a really good
- 9:40balance. It's cheap. It's fast. And it's plenty
- 9:43smart enough for sorting emails accurately. But
- 9:45the benefit of open routers, you're not stuck
- 9:47with that. Precisely. That's the key advantage.
- 9:50Agility. If you find GPT 4 .1 Mini isn't quite
- 9:54getting the nuance you need, you literally just
- 9:56select, say, Claude 4 .5 Sonnet from the dropdown
- 9:59in NN. Done. No new accounts, no new keys. Test
- 10:03away. That flexibility is huge. It means your
- 10:06AI brain isn't locked into one vendor. You can
- 10:08experiment, find the best speed, cost, accuracy
- 10:11balance for your specific emails. Totally. So
- 10:13you set that up, you run the step with your pin
- 10:15test data, make sure it correctly outputs customer
- 10:18support, and pin that output too for the next
- 10:20step. Okay, beyond just maybe saving some money,
- 10:22what's the core operational win from using something
- 10:25like OpenRouter here? It's really about the speed
- 10:27and flexibility. You can easily swap between
- 10:30different powerful AI models using just that
- 10:32one connection point. Experimentation becomes
- 10:35cheap and fast. Gotcha. Intelligence built, powered
- 10:38up, tested. Now for step four. The filing cabinet.
- 10:43Making it organized. Setting up the labels. Well,
- 10:45wait. Crucial pre -step here. Create those labels
- 10:49in Gmail first. Go into your Gmail settings and
- 10:52actually make the labels. Customer support, finance
- 10:54billing, high priority promotion. Right. NEN
- 10:56can't create them. It can only apply existing
- 10:58ones. Exactly. And a pro tip from the guide.
- 11:01Use colors. Make high priority bright red or
- 11:05something. Makes it super easy to spot those
- 11:07urgent emails visually in your inbox later. Nice
- 11:09tip. Okay. Labels exist in Gmail. Back to NAN.
- 11:13Add the Gmail. Add label to message action node.
- 11:16Put it on the first branch coming off your classifier.
- 11:18Let's say the customer support path. And the
- 11:20key setting here is telling it which email to
- 11:23label. Bingo. This is critical. You need the
- 11:25unique identifier for the email that started
- 11:28the whole process. Remember that aid in variable
- 11:30from the very first Gmail trigger step? The one
- 11:33we got by turning simplify off. That's the one.
- 11:35You drag that ID variable from the trigger node's
- 11:38output data and drop it into the message ID field
- 11:41of the add label node. Think of it like the email's
- 11:44unique address or, I don't know, social security
- 11:46number. It guarantees the label goes on the exact
- 11:48right message. No mix -ups. Makes sense. And
- 11:51then you just repeat that for the other three
- 11:53branches. You could. Or use the don't repeat
- 11:56yourself principle. Configure that first add
- 11:58label node perfectly. Test it. Then just copy
- 12:00and paste it onto the other three branches. All
- 12:03you have to change in the copies is which label
- 12:04to apply from the dropdown menu. Saves a ton
- 12:07of clicking. Ah, nice efficiency move. So, final
- 12:11check on this step. Why is grabbing that specific
- 12:15message ID so non -negotiable for the ad label
- 12:18part? Because that unique ID is the only way
- 12:21to guarantee the labeling action connects back
- 12:23correctly to the specific email that triggered
- 12:25the whole workflow right at the start. Keeps
- 12:28everything linked properly. Okay. Wow. We actually
- 12:30did it. Mission accomplished for part one. We
- 12:32did. We built the brain, the classifier, and
- 12:34the filing system, the labeling part. Yeah. Your
- 12:37agent can now trigger on a new email, read it
- 12:40with full context, make an intelligent decision
- 12:42based on your rules, and automatically file it
- 12:45with the right label. The system is thinking.
- 12:47It's making decisions. It's organizing your inbox
- 12:50all automatically. That's a big one. Using just
- 12:53no -code tools and some clever AI prompting.
- 12:56The heavy lifting, the conceptual part, is basically
- 12:59done now. And that sets us up perfectly for part
- 13:01two. That's where the agent gets his arms and
- 13:03legs, right? Exactly. Next time, we'll build
- 13:05out the actions for each of those branches. Things
- 13:07like sending automated AI replies, maybe drafting
- 13:10responses for you to approve first, pushing those
- 13:13high priority alerts to your phone or Slack.
- 13:16That's where the real time saving magic happens.
- 13:18I'm looking forward to that. But before we wrap
- 13:20for today, here's something to think about. A
- 13:21final thought for you, the listener. Since we
- 13:23saw how critical those category descriptions
- 13:25are for accuracy, take a minute later today and
- 13:28think. Which emails in your inbox are the trickiest
- 13:32for you to categorize quickly? Those weird edge
- 13:35cases. How would you explain the difference simply
- 13:38to an AI? Ah, interesting exercise. Doing that
- 13:42kind of self -reflection, thinking about your
- 13:44own sorting logic, can seriously level up your
- 13:46prompt engineering game for stuff like this.
- 13:48Great point. Well, thank you for sharing the
- 13:51source material for this deep dive. It's been
- 13:52fascinating to unpack the infrastructure of building
- 13:55an AI brain like this. My pleasure. Keep learning.
- 13:58Keep building. We'll catch you on the next one
- 14:00for part two.