KEEP LEARNING
Build the bigger picture.
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
Tips > Data, APIs & Webhooks
Before calling an expensive API (LLM, image processing, translation), check if the input data has actually changed since the last run.
Before calling an expensive API (LLM, image processing, translation), check whether the input actually changed since the last run. Store a hash of the relevant input fields alongside the previous result; if the hash matches, return the cached result and skip the call. This avoids regenerating output when only irrelevant fields changed.
Before calling an expensive API (LLM, image processing, translation), check if the input data has actually changed since the last run. Store a hash of the input alongside the previous result. If the hash matches, return the cached result without calling the API.
Real-world example: A workflow generates AI product descriptions whenever product data is updated. But the CRM sends webhook events for every field change -- including irrelevant fields like last_viewed_at. Only regenerate descriptions when the relevant fields change.
// Code node: "Check If Description Needs Regeneration"
const crypto = require('crypto');
const product = $input.first().json;
// Only hash the fields that affect the description
const relevantData = {
name: product.name,
category: product.category,
features: product.features,
price: product.price
};
const currentHash = crypto
.createHash('md5')
.update(JSON.stringify(relevantData))
.digest('hex');
// previousHash comes from a DB/Sheet lookup node upstream
const previousHash = $input.first().json._previous_hash || null;
return [{
json: {
...product,
currentHash,
needsRegeneration: currentHash !== previousHash
}
}];Then branch with an IF node:
IF node condition:
{{ $json.needsRegeneration }} equals true
True branch: [OpenAI: Generate Description] --> [Save to DB with new hash]
False branch: [Return Cached Description] --> [Done]Cost impact:
Product catalog: 1000 products
CRM events/day: ~5000 (most are irrelevant field changes)
Actual description-relevant changes: ~50/day
Without check: 5000 OpenAI calls/day x $0.03 = $150/day
With check: 50 OpenAI calls/day x $0.03 = $1.50/day
Savings: 99%This is especially impactful for LLM calls, where each invocation costs 10-100x more than a simple database lookup.
Related: Use Structured Output (JSON Mode) for Parseable Responses · Configure Payload Size and Binary Data Mode for Large Files
KEEP LEARNING
The Workflow Engineer connects individual n8n concepts to testing, deployment and running a complete workflow.
APPLY IT TO YOUR SYSTEM
Bring the process, the tools involved and an example of where the current workflow gets stuck.