Most engineering teams bolt LLM calls onto cron jobs and hope the provider stays up. These AI workflow automation templates n8n users can import today replace fragile scripts with versioned workflows that surface retries, branching, and audit logs. Each pattern below is built from native n8n nodes and standard HTTP calls—no custom containers required.
1. Slack sentiment triage and auto-respond
A shared support channel turns into noise fast. This template uses the Slack Trigger node (event: message.channels) to capture inbound posts, then routes them through a Function node that strips boilerplate and builds a classification prompt.
The LLM call hits a chat completions endpoint with a strict JSON schema response. A Switch node reads sentiment and urgency fields: high-urgency negative messages get auto-responded with a templated acknowledgement, everything else is forwarded to #support-triage with a summary attachment.
// Function node: shape prompt
const text = $json.event.text.replace(/<@\w+>/g, '').trim();
return [{
json: {
model: 'gpt-4o-mini',
messages: [{
role: 'system',
content: 'Classify as JSON: {sentiment: "pos|neg|neu", urgency: 1-5, topic: string}'
}, { role: 'user', content: text }],
response_format: { type: 'json_object' }
}
}];
Set a 30-second timeout on the HTTP Request node and enable “Retry On Fail” with exponential backoff. That alone removes 90% of silent failures we see in hand-rolled scripts.
2. RAG ingestion pipeline from Google Drive
Knowledge rot is real—your vector store is stale the day after you build it. This workflow triggers on Google Drive file.updated events, downloads changed docs, splits them into 1,500-character chunks with 200-character overlap, and embeds each chunk via a batch HTTP call.
The embedding response is upserted into a Pinecone or Qdrant index using the respective n8n node or a generic HTTP Request. Critically, the workflow tags each vector with drive_file_id and sha256 so subsequent runs can skip unchanged content.
{
"nodes": [{
"name": "Embed Chunks",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"url": "https://api.openai.com/v1/embeddings",
"method": "POST",
"body": {
"input": "={{ $json.chunks }}",
"model": "text-embedding-3-small"
}
}
}]
}
Run this as a scheduled catch-up job weekly to backfill, but rely on the webhook for incremental updates. That hybrid pattern keeps latency low and cost predictable.
3. LLM-powered SQL analyst with read-only DB
Give non-technical teammates a Slack command /askdb <question> and get back a table. The workflow parses the command, sends the question to an LLM with a live schema description fetched from information_schema, and returns generated SQL.
A Function node validates the SQL with a regex deny-list (DROP, DELETE, UPDATE, ;) before passing to the Postgres node in read-only mode. The result set is fed back to the LLM for natural-language summarization.
// Reject writes
if (/\\b(drop|delete|update|insert|alter)\\b/i.test($json.sql)) {
throw new Error('Write statement blocked');
}
return $items;
We enforce read-only at the database user level too—defense in depth beats prompt instructions alone.
4. Automated PR code review bot
GitHub pull_request webhook fires on opened and synchronize. The workflow fetches the diff via the GitHub node, filters out lockfiles and generated code, and sends the unified diff to an LLM with a reviewer persona.
Output is posted as a PR comment using the GitHub node’s create comment operation. To avoid spam, a Switch node checks if the model returned any severity: high findings; only then does it request changes via the review API.
Keep the diff under 8k tokens by truncating large files and asking the model to flag missing tests specifically. That scope control matters more than model choice for signal-to-noise.
5. Email draft generator with provider fallback
Support inboxes benefit from suggested replies. An IMAP Trigger pulls unread messages, a Function node extracts thread context, and an HTTP Request node calls a chat completions endpoint to draft a response in your brand voice.
For production reliability, point the HTTP Request node at a single OpenAI-compatible endpoint like n4n.ai to get automatic fallback across 240+ models and per-token metering when a provider is rate-limited. The node config stays identical; you just change the url and apiKey.
{
"url": "https://api.n4n.ai/v1/chat/completions",
"method": "POST",
"headers": { "Authorization": "Bearer {{ $env.N4N_KEY }}" },
"body": {
"model": "auto",
"messages": "={{ $json.messages }}",
"route": { "fallback": ["anthropic/claude-3.5-sonnet", "openai/gpt-4o"] }
}
}
If the draft scores below a confidence threshold, the workflow routes to a human queue instead of auto-sending. That threshold is the difference between helpful and embarrassing.
6. Multi-model content moderation queue
User-generated content needs a second opinion. This template accepts text via Webhook, then fans out to two different models in parallel (e.g., a small fast classifier and a larger reasoning model) using two HTTP Request nodes.
A Merge node collects both verdicts; a Function node applies a policy: if either model flags unsafe, reject; if they disagree, escalate to human review. This costs more than single-call moderation but cuts false positives on borderline posts.
// Merge logic
const [a, b] = $items;
if (a.json.flagged || b.json.flagged) {
return [{ json: { action: a.json.flagged && b.json.flagged ? 'reject' : 'review' } }];
}
return [{ json: { action: 'approve' } }];
Store the disagreement cases as labeled training data. After a month you can often retire the second model.
7. Voice memo to structured CRM record
Sales reps leave voice notes; nobody enters them. A Twilio or upload webhook receives the audio, an HTTP Request node transcribes via Whisper, and a Function node extracts entities (company, next_step, amount) using a structured LLM call.
The extracted record is upserted into HubSpot or Salesforce via the native n8n node. If confidence on any field is low, the workflow creates a task for the rep rather than overwriting existing data.
Transcription is the expensive step—downsample audio to 16kHz mono before upload. That halves payload size with no measurable accuracy loss for speech.
8. Periodic knowledge base sync with embeddings
Documentation sites drift. A Cron node runs nightly, fetches your docs via sitemap, compares lastmod against a SQLite cache table, and only embeds new or changed pages.
Embeddings are written to your vector store with metadata source_url and indexed_at. A final Function node prunes vectors whose source_url no longer appears in the sitemap—keeping the index honest without a full rebuild.
// Prune stale
const live = $json.liveUrls;
const stale = $json.storedUrls.filter(u => !live.includes(u));
return stale.map(u => ({ json: { delete_url: u } }));
This pattern scales to tens of thousands of pages because it never re-processes the unchanged long tail.
9. Agentic error monitor for CI logs
When a CI pipeline fails, the webhook payload includes the job log URL. The workflow downloads the log, strips ANSI codes, and asks an LLM to identify the root cause and suggest a fix based on your repo’s CONTRIBUTING guide fetched from GitHub.
If the model returns a patch block, the workflow opens a Draft PR with the change. Human engineers review; we never auto-merge from this agent because context truncation in long logs is a real failure mode.
Limit the log sent to the last 2,000 lines and prepend a stack-trace extractor. The model reasons better on the signal than the noise.
10. Invoice PDF extraction to accounting ledger
Finance automation breaks on messy scans. This template uses the n8n PDF node to extract raw text, then a chat completion with a JSON schema forces fields: vendor, invoice_date, line_items[], total.
The structured output is validated against a minimum-confidence rule and POSTed to your ledger API (QuickBooks, Xero, or internal). Failed extractions land in a Slack #ap-exceptions channel with the source PDF attached.
Always reconcile total against the sum of line_items. LLMs hallucinate rounding; a ten-line check in a Function node saves audit pain.
Synthesis
These AI workflow automation templates n8n users adopt most often share three traits: they constrain LLM output with schemas, they branch on model confidence instead of trusting it blindly, and they keep the human in the loop for any write action. Below is a quick reference.
| # | Template | Primary trigger | Key risk control |
|---|---|---|---|
| 1 | Slack sentiment triage | Slack event | Auto-reply only on high confidence |
| 2 | RAG Drive ingestion | Drive webhook | Content hash skip |
| 3 | SQL analyst | Slack command | DB user read-only + regex |
| 4 | PR review bot | GitHub webhook | Severity gate |
| 5 | Email draft | IMAP | Provider fallback + threshold |
| 6 | Moderation queue | Webhook | Multi-model disagree → human |
| 7 | Voice to CRM | Upload webhook | Field confidence → task |
| 8 | KB sync | Cron | Sitemap diff |
| 9 | CI error agent | CI webhook | Draft PR only |
| 10 | Invoice extract | Folder watch | Total reconciliation |
Copy the node patterns, swap your own endpoints, and version the workflows in git. That’s how you keep LLM features operable instead of heroic.