Lección 3 · Módulo 2: Your First Working AI Automation
Adding an AI step: classifying and summarizing incoming messages
- Classify each message with a label
- Summarize it in one line
- Route it to the right step
Why this matters
A shared inbox mixes very different messages. A booking, a complaint, a quote request and an invoice question can all arrive in the same hour, and each needs a different reply. Reading every one by hand is slow, and an urgent message is easy to miss. An AI classifier step, one box in n8n (a no-code tool that links steps into a workflow), can read each message, attach a label and write a one-line summary, so the owner sees what needs attention in seconds.
Key ideas
- Fixed labels. The model must pick one label from a list you write, such as booking, complaint, quote, invoice or other. That list is the whole contract: a reply outside it is not a valid answer.
- Clean before you compare. Remove stray spaces and lower-case the reply, then check it against the list.
" Quote "becomesquoteand routes, whileBooking request.matches nothing and becomesneeds human. - One-word replies. Tell the From the lesson: Triggers, nodes and data flow: reading a no-code workflow in n8nOne box in an n8n workflow that does a single job, like reading a message or saving a row.Review that lesson, in its prompt, to answer with the label alone, in a From the lesson: Structured outputs: making agents return clean JSON every timeAsking the model to return a fixed shape of answer, so code can read it reliably every time.Review that lesson. A full sentence cannot match the list, so a correct booking could reach a person by mistake.
- Short summary beside the original. The model writes one line saying what the customer wants, in its own column next to the untouched message. Keeping the original means nothing is lost.
- Routing by label. A a workflow box that sends each item down the path matching its value sends each label to its own step. Other and needs human go to a person, a handoff called From the lesson: Guardrails in the prompt: refusals, escalation and staying on taskRules in the prompt that say when to refuse a request or pass it to a person.Review that lesson.
Try it before you watch
A model replies Invoice with a space after the word. After cleaning, which label does the check return, and which path does the message take?
Show answerHide answer
The check returns invoice, and the message goes down the invoice path to the accounts folder. Cleaning first is what stops a stray space from sending a correct message to a person.
Words to know
- label: a short name from your fixed list that the model attaches to a message, such as booking or complaint.
- classifier: a step that puts each piece of text into one bin from a list you choose.
- summary: a short version of a long message, here one line that says what the customer wants.
- route: send an item down the path that matches its label.
- fallback: the path for anything unclear or not on the list, which goes to a person.
- prompt: the written instructions you give the model, including its job, the labels and the reply format.
What to watch for
- The label list in the AI node's prompt and the list in the check must match exactly, spelling included, or valid messages end up with a person.
- How the full-sentence reply
Booking request.is handled, and which path it finally takes. - The summary column and the Other pile on the chart, which together show how much the owner still has to read.
Apréndelo con tu tutor en la pizarra en vivo
Puntos clave del video
Forty messages by morning
- Forty messages waiting
- Bookings mixed with complaints
- Each one opened and read by hand
layout: wide
parts:
inbox: {chip: Inbox, sub: "Overnight messages"}
steps:
- at: "all in one pile"
vortex: {into: inbox, words: [booking, complaint, quote, invoice]}
- at: "there are forty"
count: {to: 40, label: messages}
- at: "some are urgent"
note: "Some are urgent"
- at: "An AI step can do that"
highlight: inbox
note: "An AI step sorts it" What you will learn
- Classify each message with a label
- Summarize it in one line
- Route it to the right step
layout: wide
parts:
ai: {chip: AI step, sub: "Language model"}
steps:
- at: "three things"
spokes: {of: ai, items: [Classify, Summarize, Route]}
- at: "classify each incoming message"
note: "1. Classify"
- at: "summarize it"
note: "2. Summarize"
- at: "route it"
note: "3. Route"
- at: "a small clinic"
note: "Example: a small clinic"
- at: "no code required"
highlight: ai What a classifier is
- A model takes text in
- You decide the bins
- The reply follows a format
layout: wide
parts:
llm: {chip: AI model, sub: "Language model"}
prompt: {box: PROMPT, holds: [llm], icon: file-text}
steps:
- at: "takes a piece of text"
spokes: {of: llm, items: [Reads, Picks one, Replies]}
- at: "reads the message"
highlight: llm
- at: "you decide the bins"
note: "You decide the bins"
- at: "called the prompt"
zoom_out: prompt
- at: "tells the model the job"
spokes: {of: prompt, items: [Job, Labels, Format]}
- at: "can only choose"
highlight: prompt Fixed labels in code
- A fixed list of labels
- Clean the reply first
- Unknown replies go to a person
labels = ["booking", "complaint", "quote", "invoice", "other"]
def check(reply):
word = reply.strip().lower()
if word in labels:
return word
return "needs human"
print(check("Booking"))
print(check(" Quote "))
print(check("Maybe a refund?")) Writing the summary
- The summary is one short line
- Written beside the original
- Read in two seconds
cells:
A1: Message
B1: Label
C1: Summary
D1: Urgent
steps:
- at: "Take a long message"
type: {A2: "Hi, sorry for the delay, could I move my Friday slot to Saturday?"}
- at: "one short line that tells you what they want"
type: {C2: "Wants Friday moved to Saturday"}
- at: "The AI reads the message"
note: "The AI writes the summary"
- at: "keep the original"
highlight: A2
- at: "The label says booking"
type: {B2: booking}
- at: "The AI also marks urgency"
type: {D2: low}
- at: "know what to do"
highlight: C2 Where the AI step sits
- Webhook catches each message
- AI model adds a label and summary
- Sheet row and owner note
layout: wide
direction: LR
components:
msg: {kind: user, label: Customer}
hook: {kind: api, label: Webhook}
n8n: {kind: service, label: n8n workflow}
ai: {kind: llm, label: AI model}
sheet: {kind: database, label: Google Sheets}
mail: {kind: email, label: Owner email}
links: [msg->hook, hook->n8n, n8n->ai, n8n->sheet, n8n->mail]
steps:
- at: "A customer sends"
show: [msg]
- at: "webhook"
show: [hook]
- at: "wired together"
show: [n8n]
- at: "reads the message"
show: [ai]
- at: "saves a row"
show: [sheet]
- at: "the owner gets"
show: [mail]
- at: "Each arrow is a handoff"
flow: ["msg>hook: form", "hook>n8n", "n8n>ai: message", "ai>n8n: label", "n8n>sheet", "n8n>mail"] Routing each label
- Booking goes to the calendar
- Quotes go to a lead sheet
- Complaints alert the owner
- Invoices go to the accounts folder
- Other and unclear go to a person
tree:
Message:
Booking: [Calendar, Confirm reply]
Quote: [Lead sheet]
Complaint: [Owner alert]
Invoice: [Accounts folder]
Other: [Person reviews]
direction: down
steps:
- at: "down the matching path"
grow: Message
- at: "a confirmation reply is drafted"
grow: Booking
- at: "A quote request goes"
grow: Quote
- at: "A complaint goes straight"
grow: Complaint
- at: "Invoices go to the accounts folder"
grow: Invoice
- at: "Other and unclear go to a person"
grow: Other
- at: "the one most people forget"
path: Other A busy Monday
- A busy Monday sample
- The chart counts each label
- Other needs a check
- Sorted from largest first
kind: bar
title: Monday's messages
data: {Booking: 14, Quote: 9, Invoice: 5, Complaint: 3, Other: 4}
steps:
- at: "thirty-five messages"
show: all
- at: "Booking is the biggest pile"
highlight: Booking
- at: "Quotes come next"
highlight: Quote
- at: "Invoices come to five"
highlight: Invoice
- at: "complaints to three"
highlight: Complaint
- at: "went to other"
highlight: Other
- at: "sorted from largest"
sort: desc Setting up the AI node
- Add an AI node after the webhook
- Paste the labels into its instructions
- Point the node at the text
- A single label is easy to route
layout: wide
parts:
node: {window: classify.txt, code: ["Label one of: booking, complaint, quote,", "invoice, other. Reply with the label only.", "Message: {{ $json.message }}"]}
steps:
- at: "Add an AI node"
note: "AI node after the webhook"
- at: "exactly as we wrote them"
type: node
- at: "text your webhook received"
highlight: node
- at: "ask for the label only"
note: "Label only"
- at: "saves hours of fixing"
note: "Fewer fixes later" Common mistake: free-text replies
- A full sentence breaks routing
- Always build a fallback path
- Test with ten real messages
labels = ["booking", "complaint", "quote", "invoice", "other"]
def check(reply):
word = reply.strip().lower()
if word in labels:
return word
return "needs human"
print(check("Booking"))
print(check("Booking request.")) Recap
- Fixed labels, one word back
- A short summary column
- A person for anything unclear
layout: wide
parts:
ai: {chip: AI step, sub: "One node in n8n"}
steps:
- at: "Three ideas to keep"
spokes: {of: ai, items: [Fixed labels, Short summary, Human fallback]}
- at: "fixed list of labels"
note: "1. Fixed labels"
- at: "short summary"
note: "2. Short summary"
- at: "path for anything unclear"
note: "3. Human fallback"
- at: "Every one of these"
highlight: ai
note: "One node, a few boxes" Exercise: sort ten messages
- Pick ten real messages
- Write a label for each
- Note if a person was needed
cells:
A1: Message
B1: Label
C1: Summary
D1: Needs person
steps:
- at: "Open your inbox"
type: {A2: "Do you have Sunday hours?"}
- at: "you would choose"
type: {B2: other}
- at: "then a one line summary"
type: {C2: "Asks for Sunday opening hours"}
- at: "needed to step in"
type: {D2: "Yes"}
- at: "The sheet on screen"
note: "One row done"
- at: "would my list of labels"
highlight: B2
- at: "Bring your finished sheet"
note: "Bring it to the next lesson" Transcripción
Forty messages by morning. Picture this. The shop has been open all day, and the messages kept coming after you closed. Bookings and complaints, plus invoices and quotes, all in one pile. By the time you check, there are forty messages waiting. Bookings mixed with complaints is exactly the problem: each one needs a different reply, and some are urgent. Right now, each one is opened and read by hand, and that is the only way to sort the pile. That takes time, and it is easy to miss the one that matters. An AI step can do that sorting for you in seconds, and this lesson shows you how.
What you will learn. By the end of this lesson you will be able to do three things. First, you will classify each incoming message, which means sorting it into a label you choose, such as booking, complaint, quote or invoice question. Second, you will summarize it, turning a long message into one short line you can read in two seconds. Third, you will route it, so the right message reaches the right next step. We will use one example throughout, a small clinic that gets messages all day. Everything we build works in n8n, with no code required.
What a classifier is. So what is a classifier? It is a step that takes a piece of text and puts it into one bin from a list you choose. The AI model is the engine that does the reading. It reads the message the way you would, understanding that a question about moving a Friday slot is about booking, even though the word booking never appears. But you decide the bins. The instructions you wrap around the list are called the prompt. Your prompt tells the model the job, the labels and the format of the reply. The model can only choose from what you gave it.
Fixed labels in code. Let's see the idea in code, so nothing is hidden. You will not type this; in n8n a Switch or IF node does the same check. First, the list. Our labels are booking, complaint, quote, invoice and other. That fixed list is the whole contract with the model. Next comes the check. Before we compare anything, we clean up the reply by removing the spaces and making it lowercase. Then we ask one question. Is the word in the list? If it is, we keep it. Anything unknown goes to a person. If you run the code, you get booking for a plain match, quote even with extra spaces, and needs human for a reply that is not on the list.
Writing the summary. Now let's make the summary. Take a long message from a customer, one that rambles through three paragraphs and a story about the weekend. The summary is one short line that tells you what they want. The AI reads the message and writes that summary in its own column, beside the original. You keep the original, so nothing is lost. Look at this row. The label says booking. The AI also marks urgency. The urgent column says low, because nothing is on fire. A busy owner can read that in two seconds and know what to do.
Where the AI step sits. Let's zoom out and see where the AI step sits. A customer sends a message through your form or your chat inbox. A webhook catches it, which is simply a web address that n8n listens on. The message then flows into the workflow, the one place where every step is wired together. The AI model reads the message, returns a label and writes the summary. Finally, the workflow saves a row to Google Sheets, and the owner gets a note. Each arrow is a handoff, and the AI step is only one box in that chain.
Routing each label. So the label is in hand. What happens next? In n8n, a Switch node looks at that label and sends the message down the matching path. Booking goes to the calendar, where a time can be held, and a confirmation reply is drafted. A quote request goes into a lead sheet, so you can follow up. A complaint goes straight to the owner as an alert. Invoices go to the accounts folder. Other and unclear go to a person for review. That includes any reply that is not on the list, which the code marks as needs human. That last path is the safety net, and it is the one most people forget to build.
A busy Monday. Let's see what this looks like on a real day. Imagine thirty-five messages arrived on a busy Monday. Each one got a label, and the chart counts them. Booking is the biggest pile, with fourteen messages. Quotes come next with nine. Invoices come to five, and complaints to three. The last four went to other, which is where you check by hand. Now the pile is sorted from largest to smallest, and you can see at a glance where your attention belongs.
Setting up the AI node. Here is the setup that makes this work in n8n. Add an AI node after the webhook. Paste the labels into its instructions, exactly as we wrote them, so the model has no room to guess. Next, point the node at the text your webhook received. The curly-brace part tells n8n to drop in the message text from the webhook. Last, ask for the label only. A single label is far easier to route than a paragraph, and that one choice saves hours of fixing later.
Common mistake: free-text replies. Here is the mistake I see most often. The model is asked to classify, but nobody tells it to reply with the label alone. So it answers with a full sentence, like booking request with a full stop at the end. Look at what the check does with that. The code sees booking request, does not find it in the list, and sends a perfectly good booking to a person. Your automation now looks broken, when the real fault is a loose prompt. The fix has two parts. Ask for the label only, and always build a fallback path for anything that does not match. Then test with ten real messages before you trust it.
Recap. Let's pull it together. Three ideas to keep. First, give the model a fixed list of labels, and ask for one word back, so the reply is easy to route. Second, write a short summary in its own column, beside the original message, so a busy owner can take it in quickly. Third, always build a path for anything unclear, because a person catching the odd message is far better than a wrong answer going out. Every one of these is a single AI node plus a few boxes in your n8n workflow.
Exercise: sort ten messages. Now it is your turn, and it takes about thirty minutes. Open your inbox, or your message history from last week, and pick ten real messages. Do not clean them up. For each one, write the label you would choose from our list, then a one line summary, then a note on whether a person needed to step in. The sheet on screen shows one row done, so you can see the pattern. Ask yourself one question as you work: would my list of labels have caught every message? Bring your finished sheet to the next lesson, where we connect it to real n8n actions.
Explora las animaciones
Las animaciones del video, exactas y en vivo: reprodúcelas, pausa, arrastra el control deslizante o salta a un paso a tu propio ritmo.
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Loading the animation...
Responde todas las preguntas y luego comprueba. Apruebas con 70%; puedes intentarlo las veces que quieras.
Resumen de la lección
- Lectura
- Video visto
- Cuestionario aprobado (70%)
- The summary is one short line
- Written beside the original
- Read in two seconds