Illustrative — the six steps in this module, in the order they come together into a single workflow.
⚡ Trigger
O trigger determines the nature of the automation. A Webhook makes it reactive (someone sends data and it responds); a Schedule makes it proactive (runs on its own at set times).
✓ Webhook (reactive)
- ✓Form submitted, payment approved, message received.
- ✓Real-time response to the event.
- ✓You receive a payload that’s ready to use.
✓ Schedule (proactive)
- ✓Daily report, email scan every 15 min.
- ✓Doesn’t depend on anyone triggering it.
- ✓Scheduled by cron: 0 9 * * 1-5 (9 a.m. on business days).
POST /webhook/novo-lead
{ "nome": "Ana", "email": "ana@x.com", "mensagem": "Quero um orçamento" }
// disponível no fluxo como: ={{ $json.body.email }}
📥 Collect input data
Before calling the AI, extract and normalize the fields that matter. The quality of the model's response is proportional to the context you provide — garbage in, garbage out.
{
"nome": "={{ $json.body.nome }}",
"email": "={{ $json.body.email.toLowerCase() }}",
"mensagem": "={{ $json.body.mensagem.trim() }}"
}
📊 Why normalize at the input
- Consistency - lowercase email prevents duplicates when saving.
- Token savings - sending only the useful fields reduces the cost of the AI call.
- Early validation - blocking empty input here avoids wasting a call.
Access the payload
Build context
Expressions
Reject junk early
🤖 Call the AI
The heart of AI automation. Use the native node (OpenAI/Anthropic) when available; otherwise, the HTTP Request call the API directly. Ask for output in JSON to avoid parsing problems later.
{
"model": "gpt-4o-mini",
"response_format": { "type": "json_object" },
"messages": [
{ "role": "system", "content": "Classifique o lead. Responda JSON: {intencao, prioridade}." },
{ "role": "user", "content": "={{ $json.mensagem }}" }
]
}
💡 Practical tip
Add the exact JSON structure that you expect in the system prompt and connect the json_object mode. This dramatically reduces malformed outputs — and temperature: 0 makes classification more stable.
Defines the role/format
Structured output
0 = stable
More context = more $
🔍 Parse the output
The response arrives as text (even in JSON mode, it comes as a string inside a field). You need to turn it into actual fields for the next nodes to use—with a fallback in case it comes back broken.
const raw = $json.choices[0].message.content; let parsed; try { parsed = JSON.parse(raw); } catch (e) { parsed = { intencao: "indefinida", prioridade: "baixa" }; } return [{ json: parsed }];
⚠️ Attention
Models sometimes wrap the JSON in ```json ... ``` or add text before it. Always handle parse failures—never trust the output to be perfect.
🎯 Execute the action
A action is what the client notices and pays for: sending the email, writing the row, inserting the record. It’s the only visible step — everything before it was preparation.
Para: ={{ $json.email }}
Assunto: Recebemos seu pedido — prioridade ={{ $json.prioridade }}
Corpo: Olá ={{ $json.nome }}, classificamos como "={{ $json.intencao }}".
🎯 Choose the action based on the recipient
- •Email — when a person needs to be notified.
- •Spreadsheet — when the team is following along visually.
- •Database — when another system will consume the data.
▶️ Run and observe
Run the actual workflow and inspect item by item. In automation, you don't use breakpoints: you read each node's input and output in the execution panel. The bug is almost always in the data format between two nodes.
Test the workflow with real data
Fire once with a sample payload. Watch the flow "light up" node by node.
Open each node and read its I/O
Compare what went in with what came out. Where the data "disappeared" is where the error is.
Pin data to iterate quickly
Pin the trigger output and rerun only the subsequent nodes without making another AI call.
💡 Practical tip
Use pin data in the trigger during development. You freeze a sample input and iterate through the following nodes in seconds, without triggering real webhooks or burning tokens on every test.
📌 Module Summary
Next Module:
4.3 - Integrations and data (REST APIs, authentication, database, spreadsheets, pagination)