<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alec Asgari</title>
    <description>The latest articles on DEV Community by Alec Asgari (@alecasgari).</description>
    <link>https://dev.to/alecasgari</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4208566%2Ff18c141f-26b7-478a-a63f-917620372482.png</url>
      <title>DEV Community: Alec Asgari</title>
      <link>https://dev.to/alecasgari</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alecasgari"/>
    <language>en</language>
    <item>
      <title>Securing a Telegram bot webhook in n8n: secret tokens, allow-lists and safe replies</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Sat, 05 Dec 2026 09:21:35 +0000</pubDate>
      <link>https://dev.to/alecasgari/securing-a-telegram-bot-webhook-in-n8n-secret-tokens-allow-lists-and-safe-replies-d5f</link>
      <guid>https://dev.to/alecasgari/securing-a-telegram-bot-webhook-in-n8n-secret-tokens-allow-lists-and-safe-replies-d5f</guid>
      <description>&lt;p&gt;A Telegram bot built in n8n usually starts with a Telegram Trigger or a plain Webhook node, a few IF nodes and a reply. It works in an afternoon. What often gets skipped is the question of who else can call that webhook URL, and what happens when they do.&lt;/p&gt;

&lt;p&gt;A webhook is just a public HTTPS endpoint. If someone finds or guesses the URL, they can post fake updates to it, and your workflow will happily process them: create leads, send messages, or call an AI model you pay for. This post walks through the small set of protections I add to every Telegram bot workflow before it goes live.&lt;/p&gt;

&lt;h2&gt;
  
  
  Webhook or polling?
&lt;/h2&gt;

&lt;p&gt;Telegram offers two ways to receive updates: long polling (&lt;code&gt;getUpdates&lt;/code&gt;) and webhooks (&lt;code&gt;setWebhook&lt;/code&gt;). n8n's Telegram Trigger uses a webhook, which is the right choice for most self-hosted setups because updates arrive instantly and you don't need a process looping all day.&lt;/p&gt;

&lt;p&gt;The trade-off is exposure. With polling, your server calls Telegram and nothing needs to be reachable from outside. With a webhook, Telegram calls you, so the endpoint must be public. That is fine, as long as you verify that each request really came from Telegram.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: set a secret token when registering the webhook
&lt;/h2&gt;

&lt;p&gt;When you call &lt;code&gt;setWebhook&lt;/code&gt;, Telegram lets you pass a &lt;code&gt;secret_token&lt;/code&gt; parameter. Telegram then sends that value in the &lt;code&gt;X-Telegram-Bot-Api-Secret-Token&lt;/code&gt; header with every update. Anyone who doesn't know the secret can't produce a valid request.&lt;/p&gt;

&lt;p&gt;If you register the webhook yourself (for example when using a generic Webhook node instead of the Telegram Trigger), the call looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl -s &lt;span class="s2"&gt;"https://api.telegram.org/bot&amp;lt;BOT_TOKEN&amp;gt;/setWebhook"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"url=https://n8n.example.com/webhook/telegram-support"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"secret_token=&amp;lt;LONG_RANDOM_STRING&amp;gt;"&lt;/span&gt; \
  -d &lt;span class="s2"&gt;"allowed_updates=[\"message\",\"callback_query\"]"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the secret with something like &lt;code&gt;openssl rand -hex 32&lt;/code&gt; and store it as an n8n credential or environment variable, not in a Set node where it ends up in every export.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;allowed_updates&lt;/code&gt; matters too: if your bot only handles messages and button presses, don't subscribe to everything. Fewer update types means fewer surprises.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: check the header as the very first node
&lt;/h2&gt;

&lt;p&gt;Right after the Webhook node, add an IF node that compares the incoming header with your stored secret:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Value 1: &lt;code&gt;{{ $json.headers["x-telegram-bot-api-secret-token"] }}&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Operation: equals&lt;/li&gt;
&lt;li&gt;Value 2: &lt;code&gt;{{ $env.TELEGRAM_WEBHOOK_SECRET }}&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On the false branch, respond with a 200 and stop. Don't return an error message that explains what failed, and don't run anything else. On the true branch, continue with the real logic.&lt;/p&gt;

&lt;p&gt;If you use the built-in Telegram Trigger node, check how your n8n version registers the webhook and whether it sets a secret for you. If you can't confirm it, a generic Webhook node with your own &lt;code&gt;setWebhook&lt;/code&gt; call gives you full control.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: allow-list chats for internal bots
&lt;/h2&gt;

&lt;p&gt;Many business bots are not meant for the public. An internal bot that posts new orders to a sales group, or lets staff look up stock, should only respond to known chat IDs.&lt;/p&gt;

&lt;p&gt;Keep a small list of allowed &lt;code&gt;chat.id&lt;/code&gt; values (a Data Table, a Google Sheet or an environment variable all work) and check &lt;code&gt;{{ $json.body.message.chat.id }}&lt;/code&gt; against it before doing anything. Unknown chats get a polite fixed reply, or nothing at all. Log the attempt with the chat ID and timestamp so you can see if someone is probing the bot.&lt;/p&gt;

&lt;p&gt;For public bots, such as a customer support bot, an allow-list doesn't fit, but you can still rate-limit per chat ID: store the time of the last few requests and stop answering if one chat sends dozens of messages a minute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: treat message text as untrusted input
&lt;/h2&gt;

&lt;p&gt;Everything a user types is untrusted. That sounds obvious, but in n8n it is easy to drop &lt;code&gt;{{ $json.body.message.text }}&lt;/code&gt; straight into a SQL query, an HTTP request URL or an AI prompt.&lt;/p&gt;

&lt;p&gt;A few habits help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use parameterised queries in database nodes instead of building SQL strings.&lt;/li&gt;
&lt;li&gt;URL-encode user input before putting it in a query string.&lt;/li&gt;
&lt;li&gt;If the bot passes text to an AI model, keep your instructions in the system message and the user's text clearly separated, and never let the model's output trigger actions (refunds, deletions, outgoing emails) without a deterministic check.&lt;/li&gt;
&lt;li&gt;Truncate very long messages before processing them.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: keep replies and secrets out of execution logs
&lt;/h2&gt;

&lt;p&gt;n8n stores execution data by default. For a Telegram bot that can mean customer names, phone numbers and message history sitting in your database indefinitely.&lt;/p&gt;

&lt;p&gt;Set execution data pruning to a sensible retention period, and consider saving only failed executions for high-volume bot workflows. Never echo the bot token or the webhook secret into a message, a Set node or an error notification.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 6: answer fast, work later
&lt;/h2&gt;

&lt;p&gt;Telegram expects a quick response from your webhook. If your workflow calls a slow API or an AI model before replying, Telegram may retry the update, and you end up processing the same message twice.&lt;/p&gt;

&lt;p&gt;Respond to the webhook immediately (Respond to Webhook node, or the "respond immediately" option), then do the slow work and send the reply with a separate Telegram node. Store the &lt;code&gt;update_id&lt;/code&gt; of processed updates for a short time and skip duplicates. That one check prevents double replies and double records.&lt;/p&gt;

&lt;h2&gt;
  
  
  A short pre-launch checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Webhook registered with a &lt;code&gt;secret_token&lt;/code&gt;, and the header checked first.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;allowed_updates&lt;/code&gt; limited to what the bot uses.&lt;/li&gt;
&lt;li&gt;Chat allow-list (internal bots) or per-chat rate limit (public bots).&lt;/li&gt;
&lt;li&gt;User text never concatenated into SQL, URLs or privileged prompts.&lt;/li&gt;
&lt;li&gt;Execution data retention set; no secrets in logs.&lt;/li&gt;
&lt;li&gt;Immediate webhook response and &lt;code&gt;update_id&lt;/code&gt; de-duplication.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this takes long, and it turns a bot that "works" into one you can leave running for months.&lt;/p&gt;

&lt;p&gt;I build Telegram bots on n8n for small businesses, from order notifications to AI-assisted support with human handoff. If you want to see how I approach them, there's an overview on my &lt;a href="https://alecasgari.com/services/ai-telegram-bots" rel="noopener noreferrer"&gt;AI and Telegram bot services page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alec Asgari has spent 16 years in IT, the last five in Dubai, building automations, bots, websites and ERP setups for small businesses. More at &lt;a href="https://alecasgari.com" rel="noopener noreferrer"&gt;alecasgari.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>telegram</category>
      <category>security</category>
      <category>automation</category>
    </item>
    <item>
      <title>Versioning n8n workflows with Git: a lightweight setup for small teams</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Wed, 02 Dec 2026 09:08:05 +0000</pubDate>
      <link>https://dev.to/alecasgari/versioning-n8n-workflows-with-git-a-lightweight-setup-for-small-teams-dh3</link>
      <guid>https://dev.to/alecasgari/versioning-n8n-workflows-with-git-a-lightweight-setup-for-small-teams-dh3</guid>
      <description>&lt;p&gt;Most small teams start with n8n the same way: someone builds a workflow in the editor, it works, and it becomes part of how the business runs. A few months later there are thirty workflows, two people editing them, and no reliable answer to simple questions like "what changed last Tuesday?" or "can we go back to the version that worked?"&lt;/p&gt;

&lt;p&gt;n8n's built-in source control is a good answer if your plan includes it. If it doesn't, or you want something you fully understand, a plain Git repository and a small export routine get you most of the benefit. Here is the setup I use for small teams.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you actually want from versioning
&lt;/h2&gt;

&lt;p&gt;Before choosing tools, be clear about the goal. For a small team it usually comes down to four things:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;History.&lt;/strong&gt; See what changed in a workflow, and when.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Rollback.&lt;/strong&gt; Restore a known-good version quickly when an edit breaks something.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review.&lt;/strong&gt; Let a second person look at a change before it matters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Disaster recovery.&lt;/strong&gt; Rebuild workflows on a new server if the old one disappears.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You don't need a full CI/CD pipeline for any of this.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Export workflows as separate files
&lt;/h2&gt;

&lt;p&gt;The n8n CLI can export every workflow to its own JSON file. On a Docker install it looks roughly like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; -u node n8n \
  n8n export:workflow --all --separate --output=/home/node/backup/workflows/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mount that folder to the host so the files land somewhere a Git repository can see them. One file per workflow matters: it keeps diffs readable and lets you restore a single workflow without touching the others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Keep secrets out of the repository
&lt;/h2&gt;

&lt;p&gt;Exported workflow JSON references credentials by ID and name, not by the secret values themselves. That makes workflow exports reasonably safe to commit to a &lt;strong&gt;private&lt;/strong&gt; repository. Credentials are a different story. If you export them, keep them encrypted (the default) and store them outside the workflow repository, with access limited to the people who already administer the server.&lt;/p&gt;

&lt;p&gt;Also check your workflows for secrets typed directly into nodes: API keys pasted into HTTP Request headers, tokens in Code nodes, passwords in Set nodes. Move those into proper credentials before you start committing. Git remembers everything, including the key you removed in a later commit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Make diffs readable
&lt;/h2&gt;

&lt;p&gt;Raw exports change in noisy ways: node positions move when someone tidies the canvas, and some metadata changes on every save. Two habits help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Format consistently.&lt;/strong&gt; Run the files through a JSON formatter with sorted keys (for example &lt;code&gt;jq -S .&lt;/code&gt;) before committing, so key order never shows up as a change.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write real commit messages.&lt;/strong&gt; "Added retry on CRM node" is useful in six months. "update" is not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to go further, a small script can strip fields you never care about, such as canvas positions, but don't overdo it. The goal is that a human can read the diff, not that it's perfect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: Automate the export
&lt;/h2&gt;

&lt;p&gt;A versioning system only works if it runs without anyone remembering it. A scheduled job on the host (cron or a systemd timer) that exports, formats, commits and pushes once a day is enough for most small teams. Keep the script short:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Export all workflows to the mounted folder.&lt;/li&gt;
&lt;li&gt;Format each file.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;git add&lt;/code&gt; and commit only if something changed.&lt;/li&gt;
&lt;li&gt;Push to a private remote.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You could also run this from n8n itself with a Schedule Trigger and an Execute Command node, but I prefer the host job: if n8n is down, the backup still runs and still tells you something is wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Practise the restore
&lt;/h2&gt;

&lt;p&gt;A history you have never restored from is a hope, not a backup. Once a quarter, take one workflow from Git and import it into a test instance:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;n8n import:workflow --input=workflow.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check that it opens, that credentials map correctly, and that a test execution runs. Write down anything that surprised you. That note is what saves you an afternoon when you need it for real.&lt;/p&gt;

&lt;h2&gt;
  
  
  House rules that make Git useful
&lt;/h2&gt;

&lt;p&gt;Tools matter less than a few agreements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;One owner per workflow.&lt;/strong&gt; The owner reviews changes and decides when they go live.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name workflows predictably&lt;/strong&gt;, for example &lt;code&gt;[Sales] Lead intake - webhook&lt;/code&gt;, so file names and history make sense.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Duplicate before big edits.&lt;/strong&gt; Work on a copy, test it, then switch over. The export captures both, and the history shows what changed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tag releases for critical workflows.&lt;/strong&gt; A Git tag like &lt;code&gt;invoice-reminders-v3&lt;/code&gt; turns "the version that worked" into something you can name.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;You don't need an enterprise setup to stop losing work in n8n. Export one file per workflow, keep secrets out, format for readable diffs, automate the commit, and test a restore regularly. It takes an afternoon to set up and saves a lot of guessing later.&lt;/p&gt;

&lt;p&gt;If you'd like help designing or tidying up a set of n8n workflows for your business, I describe how I work on my &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;n8n automation services&lt;/a&gt; page.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alec Asgari has spent 16 years in IT, the last five in Dubai, building n8n automations, websites and ERP setups for small businesses. More at &lt;a href="https://alecasgari.com" rel="noopener noreferrer"&gt;alecasgari.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>git</category>
      <category>devops</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Stop duplicate orders and leads in n8n: a practical guide to idempotent webhooks</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Sun, 29 Nov 2026 05:33:32 +0000</pubDate>
      <link>https://dev.to/alecasgari/stop-duplicate-orders-and-leads-in-n8n-a-practical-guide-to-idempotent-webhooks-1hp5</link>
      <guid>https://dev.to/alecasgari/stop-duplicate-orders-and-leads-in-n8n-a-practical-guide-to-idempotent-webhooks-1hp5</guid>
      <description>&lt;p&gt;If you run n8n webhooks in production long enough, you will eventually see the same lead arrive twice, the same order create two invoices, or a customer receive the same Telegram message three times. Nothing is "broken" in the usual sense. The sender retried, a user double-clicked a button, or a payment provider re-delivered an event because your workflow took a few seconds too long to answer.&lt;/p&gt;

&lt;p&gt;The fix is a property called &lt;strong&gt;idempotency&lt;/strong&gt;: processing the same event twice should have the same effect as processing it once. Here's how I build that into n8n workflows for small teams, without adding a lot of moving parts.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why duplicates happen in the first place
&lt;/h2&gt;

&lt;p&gt;Most duplicate executions come from one of four places:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Sender retries.&lt;/strong&gt; Payment providers, form tools and e-commerce platforms usually retry a webhook if they don't get a fast 2xx response. If your workflow does heavy work before responding, the sender may time out and try again while the first run is still going.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Double submits.&lt;/strong&gt; A visitor clicks "Send" twice on a slow connection. Two POST requests, two executions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your own retries.&lt;/strong&gt; You enabled "Retry On Fail" on an HTTP node, the remote API actually succeeded the first time, but the response got lost. The retry creates a second record.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Manual re-runs.&lt;/strong&gt; Someone re-executes a failed execution from the n8n UI after part of it already succeeded.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can't make all of these go away, so the workflow has to tolerate them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Respond fast, work later
&lt;/h2&gt;

&lt;p&gt;The cheapest improvement is to stop making the sender wait. In the Webhook node, set &lt;strong&gt;Respond&lt;/strong&gt; to "Using 'Respond to Webhook' Node" and put a Respond to Webhook node right after your basic validation. Return a 200 (or 202) as soon as you've confirmed the payload looks sane, then continue with the slow work: CRM updates, emails, AI calls.&lt;/p&gt;

&lt;p&gt;This alone removes most sender-side retries, because the sender gets its answer in milliseconds instead of waiting for your whole workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Find or build an idempotency key
&lt;/h2&gt;

&lt;p&gt;An idempotency key is a value that is the same for every delivery of the same logical event and different for different events.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Payment and e-commerce webhooks&lt;/strong&gt; usually include an event ID or an order ID. Use it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Form submissions&lt;/strong&gt; often don't. Build one: a hash of the normalized email address, the form name and the submission date (or a 10-minute time bucket) works well for catching double-clicks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Messaging platforms&lt;/strong&gt; such as Telegram include an &lt;code&gt;update_id&lt;/code&gt; for each incoming update. That is your key.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In n8n, a Code node can build a hash key in a few lines:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'crypto'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bucket&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// 10-minute window&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;crypto&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createHash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sha256'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`${email}|contact-form|${bucket}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;digest&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'hex'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;idempotencyKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;(On self-hosted n8n you may need to allow the &lt;code&gt;crypto&lt;/code&gt; module with &lt;code&gt;NODE_FUNCTION_ALLOW_BUILTIN=crypto&lt;/code&gt;.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Record keys before you act
&lt;/h2&gt;

&lt;p&gt;Next, the workflow needs a memory of which keys it has already processed. Options, from simplest to sturdiest:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;n8n's Remove Duplicates node.&lt;/strong&gt; Recent n8n versions can remove items whose value was seen in &lt;em&gt;previous executions&lt;/em&gt;, storing history inside n8n. For low-volume workflows, this is often enough and needs no extra infrastructure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A database table.&lt;/strong&gt; A small Postgres table with a unique constraint on the key column. Insert the key first; if the insert fails because of the unique constraint, stop the workflow. The database does the hard part, including when two executions arrive at the same moment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Redis with SET NX and an expiry.&lt;/strong&gt; Good when volume is high and you only care about duplicates within a time window.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The important detail is order: &lt;strong&gt;claim the key before you do the side effect&lt;/strong&gt;, not after. If you check "have I seen this?" and only record it at the end, two near-simultaneous executions will both see "no" and both proceed.&lt;/p&gt;

&lt;p&gt;A typical shape for the Postgres version:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Code node builds &lt;code&gt;idempotencyKey&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Postgres node: &lt;code&gt;INSERT INTO processed_events (key, received_at) VALUES ($1, now()) ON CONFLICT (key) DO NOTHING RETURNING key;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;IF node: if a row came back, continue; if not, end quietly.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Step 4: Make the side effects themselves safer
&lt;/h2&gt;

&lt;p&gt;Even with a key check, it helps when downstream actions are naturally repeatable:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Upsert instead of create.&lt;/strong&gt; Many CRM and database nodes support "create or update" matched on email or external ID. A duplicate then updates the same record instead of creating a second one.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pass the key along.&lt;/strong&gt; Some APIs accept an idempotency key header on create requests. If yours does, send the same key you built in Step 2.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Store external IDs.&lt;/strong&gt; When you create an invoice, write the invoice ID back next to the event key. A re-run can check for it before creating another.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Handle partial failures deliberately
&lt;/h2&gt;

&lt;p&gt;The tricky case is a workflow that claimed the key, did half the work, and then failed. Now a retry will be blocked by your own duplicate check.&lt;/p&gt;

&lt;p&gt;Two patterns help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Status column.&lt;/strong&gt; Store &lt;code&gt;processing&lt;/code&gt;, &lt;code&gt;done&lt;/code&gt; or &lt;code&gt;failed&lt;/code&gt; with the key. Retries are allowed when the status is &lt;code&gt;failed&lt;/code&gt; or when &lt;code&gt;processing&lt;/code&gt; is older than, say, 15 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Split the workflow.&lt;/strong&gt; Put each side effect into its own sub-workflow with its own key (for example &lt;code&gt;orderId + "-invoice"&lt;/code&gt; and &lt;code&gt;orderId + "-email"&lt;/code&gt;). A retry then skips the steps that already succeeded and repeats only the failed one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 6: Clean up and keep an eye on it
&lt;/h2&gt;

&lt;p&gt;Keys don't need to live forever. A nightly job that deletes keys older than 30 days keeps the table small. It's also worth logging how many duplicates you blocked each week. A sudden jump usually means something upstream changed: a slower API, a new retry policy, or a form that no longer disables its button after submit.&lt;/p&gt;

&lt;h2&gt;
  
  
  A short checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Respond to the webhook quickly, then do the slow work.&lt;/li&gt;
&lt;li&gt;Choose an idempotency key for every trigger: event ID, order ID, &lt;code&gt;update_id&lt;/code&gt; or a hash.&lt;/li&gt;
&lt;li&gt;Claim the key before any side effect, using a unique constraint or an equivalent.&lt;/li&gt;
&lt;li&gt;Prefer upserts and pass keys to APIs that support them.&lt;/li&gt;
&lt;li&gt;Track status so partial failures can be retried safely.&lt;/li&gt;
&lt;li&gt;Expire old keys and watch the duplicate count.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;None of this is glamorous, but it's the difference between an automation people trust and one they quietly double-check by hand. If you're weighing tools before building any of this, I compared the options in &lt;a href="https://alecasgari.com/blog/n8n-vs-make-vs-zapier" rel="noopener noreferrer"&gt;n8n vs Make vs Zapier&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alec Asgari has spent 16 years in IT and builds n8n automations, websites and ERP setups for small businesses. More at &lt;a href="https://alecasgari.com" rel="noopener noreferrer"&gt;alecasgari.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>webhooks</category>
      <category>nocode</category>
    </item>
    <item>
      <title>Backing up self-hosted n8n: what to save, how often, and how to prove a restore works</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Wed, 25 Nov 2026 09:11:10 +0000</pubDate>
      <link>https://dev.to/alecasgari/backing-up-self-hosted-n8n-what-to-save-how-often-and-how-to-prove-a-restore-works-4o04</link>
      <guid>https://dev.to/alecasgari/backing-up-self-hosted-n8n-what-to-save-how-often-and-how-to-prove-a-restore-works-4o04</guid>
      <description>&lt;p&gt;Self-hosting n8n is cheap and flexible, but it moves one job from the vendor to you: backups. Most small teams I work with have &lt;em&gt;something&lt;/em&gt; in place, usually a snapshot of the whole server. That helps, but it often isn't enough to get a single broken workflow back quickly, and nobody has ever tested whether the snapshot actually restores.&lt;/p&gt;

&lt;p&gt;This is the backup routine I set up for small teams running n8n in Docker. It's boring on purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Know what actually needs saving
&lt;/h2&gt;

&lt;p&gt;An n8n instance has four things you care about:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The database.&lt;/strong&gt; Workflows, credentials (encrypted), execution history and settings live here. On small installs this is often SQLite inside the n8n data folder; on larger ones it's Postgres.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The encryption key.&lt;/strong&gt; Credentials in the database are encrypted with &lt;code&gt;N8N_ENCRYPTION_KEY&lt;/code&gt; (or the key n8n generated on first start and stored in its config file). Lose the key and your restored credentials are useless.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Your environment and compose files.&lt;/strong&gt; The &lt;code&gt;docker-compose.yml&lt;/code&gt;, the &lt;code&gt;.env&lt;/code&gt; file and any reverse-proxy config. Without these, rebuilding takes hours of guessing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Files your workflows write to disk&lt;/strong&gt;, if any (exports, generated PDFs, uploaded files).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you only take one thing from this post: store the encryption key somewhere separate from the server, such as a password manager. A backup of the database without the key is half a backup.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Two layers: whole-server and per-workflow
&lt;/h2&gt;

&lt;p&gt;I use two layers because they solve different problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1: nightly file-level backup of the data folder and database.&lt;/strong&gt; For SQLite, stop writes or use the SQLite backup command so you don't copy a file mid-write. For Postgres, a nightly &lt;code&gt;pg_dump&lt;/code&gt; is simple and reliable. Push the result off the server to object storage with a tool that does encryption and versioning (Kopia, Restic and Borg are all fine). Keep at least 14 days, longer if the storage is cheap.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2: workflow exports to Git.&lt;/strong&gt; The n8n CLI can export workflows as JSON:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker &lt;span class="nb"&gt;exec&lt;/span&gt; n8n n8n export:workflow --all --separate --output=/home/node/backup/workflows
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Commit that folder to a private repository once a day. Now when someone "improves" a workflow on Friday afternoon and breaks it, you can diff Thursday's version and paste it back in minutes, without touching the database.&lt;/p&gt;

&lt;p&gt;Credentials can be exported too, but only decrypted or encrypted with the instance key. I keep credential exports out of Git and rely on Layer 1 plus the stored key.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Schedule it, then alert on failure
&lt;/h2&gt;

&lt;p&gt;Run both layers from cron or a systemd timer, not from inside n8n itself. If n8n is down, a backup workflow inside n8n is down with it.&lt;/p&gt;

&lt;p&gt;Every backup job should end by reporting success somewhere a human will notice its &lt;em&gt;absence&lt;/em&gt;. A simple pattern: the job pings a heartbeat URL (a monitoring service, or a small webhook) and that service alerts you if the ping doesn't arrive for 26 hours. Alerting on silence catches the failure mode that matters most: the backup that quietly stopped running weeks ago.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Test a restore every quarter
&lt;/h2&gt;

&lt;p&gt;A backup you've never restored is a hope, not a backup. Once a quarter:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Start a throwaway VM or a local Docker host.&lt;/li&gt;
&lt;li&gt;Restore the compose files, &lt;code&gt;.env&lt;/code&gt; and the latest database dump.&lt;/li&gt;
&lt;li&gt;Set the same encryption key and start n8n.&lt;/li&gt;
&lt;li&gt;Log in, open three important workflows, and run one manually against a test endpoint.&lt;/li&gt;
&lt;li&gt;Write down how long it took and anything you had to look up.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first test usually reveals something: a missing environment variable, a reverse-proxy setting nobody documented, a webhook URL hard-coded to the old hostname. Fixing those on a quiet Tuesday is much better than discovering them during an outage.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Watch the execution history size
&lt;/h2&gt;

&lt;p&gt;Execution data is often the biggest part of the database. Keep enough history to debug (I like at least two weeks), but turn on pruning so the database doesn't grow forever and backups stay fast. Check the variables for execution data pruning and max age in your n8n version's docs and set them explicitly rather than trusting defaults.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. A one-page runbook
&lt;/h2&gt;

&lt;p&gt;Finally, write a single page that says:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;where backups are stored and how to access them,&lt;/li&gt;
&lt;li&gt;where the encryption key is,&lt;/li&gt;
&lt;li&gt;the exact restore commands,&lt;/li&gt;
&lt;li&gt;who to call.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put it next to the server documentation, not on the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Back up the database, the encryption key, the config files and any written files.&lt;/li&gt;
&lt;li&gt;Use a nightly off-site backup plus daily workflow exports to Git.&lt;/li&gt;
&lt;li&gt;Run backups outside n8n and alert when they &lt;em&gt;don't&lt;/em&gt; report in.&lt;/li&gt;
&lt;li&gt;Test a full restore quarterly and keep a one-page runbook.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're moving to self-hosted n8n and want this set up properly from day one, I describe how I handle it on my &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;n8n automation services page&lt;/a&gt;. If you're still on Zapier, my notes on a &lt;a href="https://alecasgari.com/blog/zapier-to-n8n-self-hosted-migration" rel="noopener noreferrer"&gt;self-hosted Zapier to n8n migration&lt;/a&gt; cover what to inventory before you move.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alec Asgari builds websites, n8n automations and ERP setups for small businesses. More at &lt;a href="https://alecasgari.com" rel="noopener noreferrer"&gt;alecasgari.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>selfhosted</category>
      <category>devops</category>
    </item>
    <item>
      <title>n8n error alerts for small teams: who gets told, what they see, and how to avoid alert fatigue</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Sun, 22 Nov 2026 09:12:25 +0000</pubDate>
      <link>https://dev.to/alecasgari/n8n-error-alerts-for-small-teams-who-gets-told-what-they-see-and-how-to-avoid-alert-fatigue-33am</link>
      <guid>https://dev.to/alecasgari/n8n-error-alerts-for-small-teams-who-gets-told-what-they-see-and-how-to-avoid-alert-fatigue-33am</guid>
      <description>&lt;p&gt;Most small teams find out an automation broke the same way: a customer asks why nobody replied to their form, or the finance person notices invoices stopped arriving in the sheet. By then the workflow has been failing quietly for days.&lt;/p&gt;

&lt;p&gt;n8n has everything you need to catch this early. The hard part isn't the feature. It's deciding who gets an alert, what the alert says, and how to keep alerts rare enough that people still read them. This is the setup I use for small teams on self-hosted n8n.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. One shared error workflow, not one per workflow
&lt;/h2&gt;

&lt;p&gt;Create a single workflow that starts with an &lt;strong&gt;Error Trigger&lt;/strong&gt; node, for example &lt;code&gt;[LIB] Error handler&lt;/code&gt;. Then open each production workflow, go to &lt;strong&gt;Settings → Error workflow&lt;/strong&gt;, and select it.&lt;/p&gt;

&lt;p&gt;When an execution fails, n8n starts the error workflow and passes it data about the failure, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;workflow.name&lt;/code&gt; and &lt;code&gt;workflow.id&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;execution.id&lt;/code&gt; and &lt;code&gt;execution.url&lt;/code&gt; (a direct link to the failed run)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;execution.lastNodeExecuted&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;execution.error.message&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the failure happens in the trigger itself (for example, a polling trigger can't authenticate), the data comes in a &lt;code&gt;trigger&lt;/code&gt; object instead of &lt;code&gt;execution&lt;/code&gt;, so handle both shapes.&lt;/p&gt;

&lt;p&gt;One shared handler means one place to change the alert format, the channel and the routing rules.&lt;/p&gt;

&lt;p&gt;Tip: make sure your instance knows its public URL (the editor/webhook base URL settings), otherwise &lt;code&gt;execution.url&lt;/code&gt; may point to &lt;code&gt;localhost&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Write alerts a non-developer can act on
&lt;/h2&gt;

&lt;p&gt;A raw error like &lt;code&gt;ECONNRESET&lt;/code&gt; or &lt;code&gt;401 Unauthorized&lt;/code&gt; means nothing to an office manager. Format the message so anyone on the team can decide what to do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[n8n] Invoice sync failed
Step: Get open invoices
Error: 401 Unauthorized
What it usually means: the accounting API key expired or was changed
Run: https://n8n.example.com/workflow/12/executions/3456
Owner: Sara
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two lines do most of the work here: &lt;strong&gt;Owner&lt;/strong&gt; and &lt;strong&gt;What it usually means&lt;/strong&gt;. Store them per workflow (in a small lookup table, a config sub-workflow, or a JSON object inside the handler keyed by workflow ID) so the handler can add them automatically.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Route by severity, not by habit
&lt;/h2&gt;

&lt;p&gt;Not every failure deserves a phone notification. I usually define three levels:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Level&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;th&gt;Where it goes&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Critical&lt;/td&gt;
&lt;td&gt;Website leads not reaching the CRM&lt;/td&gt;
&lt;td&gt;Telegram/Slack message to the owner right away&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Normal&lt;/td&gt;
&lt;td&gt;Nightly report failed once&lt;/td&gt;
&lt;td&gt;Team channel&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;A single retry-able API hiccup&lt;/td&gt;
&lt;td&gt;Daily summary only&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Add a &lt;code&gt;severity&lt;/code&gt; field to the same per-workflow config and use a &lt;strong&gt;Switch&lt;/strong&gt; node in the error handler to route it. A form that brings in customers is critical; a weekly internal report usually isn't.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Throw your own errors for "successful" failures
&lt;/h2&gt;

&lt;p&gt;Some of the worst failures don't produce an error at all. The API returns &lt;code&gt;200&lt;/code&gt; with an empty list, or a supplier sends a file with the wrong columns, and the workflow happily does nothing.&lt;/p&gt;

&lt;p&gt;Use the &lt;strong&gt;Stop and Error&lt;/strong&gt; node after a check that should never be false:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"Did we get at least one row?"&lt;/li&gt;
&lt;li&gt;"Does the parsed invoice have a total?"&lt;/li&gt;
&lt;li&gt;"Did the CRM return a contact ID?"&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The custom message ("Supplier CSV had no 'SKU' column") ends up in the error workflow and in the alert, which is much easier to act on than a mystery further down the line.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Decide where a failure should stop the workflow
&lt;/h2&gt;

&lt;p&gt;Per node, n8n lets you choose what happens on error: stop the workflow, continue, or continue using a separate error output. Combined with &lt;strong&gt;Retry on fail&lt;/strong&gt;, that gives you fine control:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retry network calls a few times with a wait between tries before alerting anyone.&lt;/li&gt;
&lt;li&gt;Use the error output for optional steps (for example, a Slack "FYI" message), so a Slack outage doesn't block the CRM update.&lt;/li&gt;
&lt;li&gt;Let essential steps fail loudly so the error workflow runs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is that every alert means a human needs to look, not that a server blinked once.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Watch for workflows that silently stop running
&lt;/h2&gt;

&lt;p&gt;An error workflow only fires when an execution fails. It can't tell you that a schedule stopped, a webhook URL changed, or the instance was down for a night.&lt;/p&gt;

&lt;p&gt;Two simple fixes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Heartbeat check:&lt;/strong&gt; a scheduled workflow that looks at the last successful run of your critical workflows (through the n8n API or a "last run" row each workflow writes) and alerts if it's older than expected.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;External ping:&lt;/strong&gt; have critical workflows call a dead-man's-switch monitoring service at the end of each run, and let that service alert you when the ping doesn't arrive.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  7. Keep alerts rare and grouped
&lt;/h2&gt;

&lt;p&gt;Alert fatigue kills monitoring faster than anything. A few rules help:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deduplicate:&lt;/strong&gt; if the same workflow fails with the same error ten times in an hour, send one message and a count, not ten messages. A small table keyed by workflow ID and error text is enough.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Daily digest for low severity:&lt;/strong&gt; collect low-level failures and send one summary each morning.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Review monthly:&lt;/strong&gt; any alert that nobody acted on is either fixed at the source, downgraded, or deleted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Remember the execution data
&lt;/h2&gt;

&lt;p&gt;Error alerts link to executions, so keep failed executions long enough to investigate (n8n's execution pruning settings control this). If workflows handle personal data, keep the alert text itself short and link to the run instead of pasting customer details into a chat channel.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;You don't need a monitoring stack to run n8n reliably as a small team: one error workflow, readable messages with an owner, severity routing and a heartbeat for critical flows cover most of it. Telegram works well as the alert channel for many small teams; I've written about building &lt;a href="https://alecasgari.com/blog/telegram-bot-for-business-n8n" rel="noopener noreferrer"&gt;Telegram bots for business with n8n&lt;/a&gt;. If you'd like help setting this up, I build and maintain these systems through my &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;n8n automation service&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Alec Asgari is a systems, automation and web consultant with 16 years in IT, the last 5 in Dubai/UAE. Awards: Best IT Company 2025 (Future Innovation Summit) and Best Web Design Company 2026 (Cybersecurity Innovators Night).&lt;/em&gt;&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>productivity</category>
      <category>smallbusiness</category>
    </item>
    <item>
      <title>Keeping n8n maintainable as a small team: sub-workflows, naming and a few house rules</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Thu, 19 Nov 2026 09:49:01 +0000</pubDate>
      <link>https://dev.to/alecasgari/keeping-n8n-maintainable-as-a-small-team-sub-workflows-naming-and-a-few-house-rules-1l2h</link>
      <guid>https://dev.to/alecasgari/keeping-n8n-maintainable-as-a-small-team-sub-workflows-naming-and-a-few-house-rules-1l2h</guid>
      <description>&lt;p&gt;The first ten n8n workflows are fun. Around workflow thirty, things change: nobody remembers which "Webhook 3" handles which form, the same Slack-notification block has been copy-pasted into twelve places, and changing one API key means opening half the instance. None of this is n8n's fault. It's what happens to any automation setup that grows without a few conventions.&lt;/p&gt;

&lt;p&gt;These are the house rules I set up for small teams running self-hosted n8n. None of them need extra tools.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Name workflows like you'd name files in a shared drive
&lt;/h2&gt;

&lt;p&gt;A consistent pattern makes the workflow list searchable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[AREA] Trigger -&amp;gt; Outcome
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[SALES] Website form -&amp;gt; CRM lead + Telegram alert
[FIN] Daily 08:00 -&amp;gt; Unpaid invoice reminders
[OPS] Supplier email -&amp;gt; Parse PDF -&amp;gt; Sheet
[LIB] Send Telegram alert
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;[LIB]&lt;/code&gt; prefix marks reusable sub-workflows (more on those below). Tags work too, but a name prefix is visible everywhere, including execution logs.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Rename every node
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;HTTP Request1&lt;/code&gt; and &lt;code&gt;IF2&lt;/code&gt; mean nothing three months later. Rename nodes to say what they do: &lt;code&gt;Get open invoices&lt;/code&gt;, &lt;code&gt;Has email?&lt;/code&gt;, &lt;code&gt;Format reminder text&lt;/code&gt;. When an execution fails, the error points straight at a readable step.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Extract repeated logic into sub-workflows
&lt;/h2&gt;

&lt;p&gt;If the same group of nodes appears in more than two workflows, it should probably be its own workflow, called with the &lt;strong&gt;Execute Workflow&lt;/strong&gt; node. Typical candidates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sending an alert to Telegram, Slack or email&lt;/li&gt;
&lt;li&gt;Looking up or creating a contact in the CRM&lt;/li&gt;
&lt;li&gt;Normalising phone numbers or country names&lt;/li&gt;
&lt;li&gt;Writing an audit row to a log table&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Give the sub-workflow an &lt;strong&gt;Execute Workflow Trigger&lt;/strong&gt; with a clear input shape, and document it in a sticky note:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"channel"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"telegram"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"level"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"title"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Invoice sync failed"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"message"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Supplier API returned 503"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now when you switch alert channels or change message formatting, you change one workflow instead of twelve.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. One credential per system, named clearly
&lt;/h2&gt;

&lt;p&gt;Avoid five slightly different credentials for the same Google account. Name credentials by system and purpose, like &lt;code&gt;Google Sheets - finance (service account)&lt;/code&gt;, and reuse them. When a token rotates, there's one place to update.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Put configuration in one place
&lt;/h2&gt;

&lt;p&gt;Hard-coded IDs scattered through nodes (sheet IDs, chat IDs, folder IDs) are a common source of "it worked in testing". Options that work well on a small setup:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Environment variables on the n8n container, read with &lt;code&gt;$env.MY_VAR&lt;/code&gt; where allowed&lt;/li&gt;
&lt;li&gt;A small &lt;code&gt;[LIB] Get config&lt;/code&gt; sub-workflow that returns a JSON object&lt;/li&gt;
&lt;li&gt;A single config table in your database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Pick one and stick with it.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Give every production workflow an error path
&lt;/h2&gt;

&lt;p&gt;Set an &lt;strong&gt;Error Workflow&lt;/strong&gt; in each production workflow's settings and point it to one shared handler that sends the workflow name, the failing node and the execution URL to your alert sub-workflow. A silent failure is the most expensive kind.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Use sticky notes as lightweight documentation
&lt;/h2&gt;

&lt;p&gt;A short sticky note at the start of each workflow answering three questions saves a lot of time:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What triggers this?&lt;/li&gt;
&lt;li&gt;What does it change, and in which system?&lt;/li&gt;
&lt;li&gt;Who should be asked before editing it?&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  8. Export workflows to git
&lt;/h2&gt;

&lt;p&gt;n8n workflows are JSON. A nightly job that exports them via the n8n API or CLI and commits them to a private repo gives you history, diffs and a backup for free. It also makes reviewing changes possible when more than one person edits automations.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Separate test and production
&lt;/h2&gt;

&lt;p&gt;Even a second, small n8n instance (or at least a &lt;code&gt;[TEST]&lt;/code&gt; prefix and test credentials) keeps experiments from sending real emails to real customers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping up
&lt;/h2&gt;

&lt;p&gt;None of these rules is complicated, and you don't need all of them on day one. Naming, error workflows and one or two shared sub-workflows already make a big difference. I've written more about moving teams onto self-hosted n8n in &lt;a href="https://alecasgari.com/blog/zapier-to-n8n-self-hosted-migration" rel="noopener noreferrer"&gt;this Zapier-to-n8n migration guide&lt;/a&gt;, and I set up and maintain these systems for small businesses through my &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;n8n automation service&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>selfhosted</category>
      <category>smallbusiness</category>
    </item>
    <item>
      <title>How I keep n8n workflows reliable when third-party APIs fail</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Sat, 14 Nov 2026 11:41:14 +0000</pubDate>
      <link>https://dev.to/alecasgari/how-i-keep-n8n-workflows-reliable-when-third-party-apis-fail-fke</link>
      <guid>https://dev.to/alecasgari/how-i-keep-n8n-workflows-reliable-when-third-party-apis-fail-fke</guid>
      <description>&lt;p&gt;Most n8n workflows I review fail in the same unglamorous way. The happy path works in a test run. Then a payment API times out, a CRM returns a 429, or a webhook is delivered twice, and the workflow either stops mid-way or writes the same record twice. The business only notices when a customer is billed twice, or when a lead never arrives.&lt;/p&gt;

&lt;p&gt;I have spent 16 years in IT, the last five in Dubai, building and reviewing automation for small teams. Reliability is a design choice, not a setting you flip on later. Below is the pattern I use when a workflow has to talk to third-party APIs and still be safe to rerun.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three failure modes that actually matter
&lt;/h2&gt;

&lt;p&gt;It helps to stop thinking in “success versus error” and start thinking in three buckets.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Transient failures&lt;/strong&gt; are timeouts, 502/503 responses, and rate limits. A retry, after a pause, often works. If you retry immediately and without a limit, you can make the rate limit worse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Permanent failures&lt;/strong&gt; are 401s, 404s, schema changes, and validation errors. Retrying these is a waste of time and can lock an account or fill an error log. These should go to a human, with the payload preserved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Partial completion&lt;/strong&gt; is the dangerous one. The CRM contact was created, then the invoice call failed. Or the invoice was created, then the confirmation email failed. A naive retry of the whole workflow creates a duplicate. This is how “simple” automations quietly damage operations.&lt;/p&gt;

&lt;p&gt;If a workflow can create, charge, email, or update a record, it needs an answer for all three.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design the workflow as steps with a recorded outcome
&lt;/h2&gt;

&lt;p&gt;I no longer build long linear chains that assume every node succeeds. Each meaningful step should:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Check whether it has already been done.&lt;/li&gt;
&lt;li&gt;Do the work, or skip it if the record already exists.&lt;/li&gt;
&lt;li&gt;Store the external ID or a status flag.&lt;/li&gt;
&lt;li&gt;Only then move on.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A Google Sheet, a row in Postgres, or a record in your CRM can be the source of truth. The workflow is not the source of truth; the data it writes is. When n8n restarts, or a webhook is replayed, the workflow should read that state and continue from the unfinished step, not from the beginning.&lt;/p&gt;

&lt;p&gt;A practical layout looks like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inbound&lt;/strong&gt;: webhook or schedule, with a unique key (form ID, order ID, email plus date, or a UUID you generate once and persist).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Load or create the job record&lt;/strong&gt;: one row per business event, with fields such as &lt;code&gt;status&lt;/code&gt;, &lt;code&gt;crm_id&lt;/code&gt;, &lt;code&gt;invoice_id&lt;/code&gt;, and &lt;code&gt;last_error&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Branch on status&lt;/strong&gt;: “new”, “crm_done”, “invoice_done”, “notified”, “failed_permanent”.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Do only the next unfinished step&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Write the result back&lt;/strong&gt; before calling the next API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is more work than a demo workflow, and it is the difference between a tool you trust and a tool you babysit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Retries need a budget, not hope
&lt;/h2&gt;

&lt;p&gt;n8n can continue on fail, and it can retry. Those features are useful only with rules.&lt;/p&gt;

&lt;p&gt;For transient errors I use a short retry budget: a few attempts, a delay between them, and a clear stop. I log the HTTP status and a truncated body. I do not retry forever, or on every status code.&lt;/p&gt;

&lt;p&gt;For permanent errors I skip retries and write the payload to a dead-letter place: a dedicated sheet tab, a table, or a Telegram message that includes the job ID. “Continue on fail” without that record is how work disappears.&lt;/p&gt;

&lt;p&gt;I also keep retries close to the failing node. Wrapping an entire 20-node workflow in one blanket retry is how you get duplicate side effects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Make every create operation idempotent
&lt;/h2&gt;

&lt;p&gt;If the API supports an idempotency key, use it. Many payment and billing APIs do. Send the same key on a retry and the provider should return the original result instead of a second charge.&lt;/p&gt;

&lt;p&gt;If the API does not support that, build your own check:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for an existing contact by email before creating one.&lt;/li&gt;
&lt;li&gt;Store the external ID on your job record the moment you get it.&lt;/li&gt;
&lt;li&gt;On retry, if &lt;code&gt;crm_id&lt;/code&gt; is already present, skip the create node.&lt;/li&gt;
&lt;li&gt;For emails, store a &lt;code&gt;notified_at&lt;/code&gt; timestamp and refuse to send twice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The unique key must come from the business event, not from the time n8n happened to run. Webhooks are often delivered more than once, and a queue retry will run the same job again. That is normal. The workflow has to be safe under those conditions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Alert on unresolved work, not on every handled retry
&lt;/h2&gt;

&lt;p&gt;A noisy Telegram or Slack channel trains people to ignore it. I alert when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A job sits in a failed state after the retry budget is used up.&lt;/li&gt;
&lt;li&gt;A job is older than a threshold and still not in a terminal status.&lt;/li&gt;
&lt;li&gt;An authentication error appears (these usually mean a token expired, and every job will fail until someone fixes it).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I do not alert on the first timeout that later succeeds. I do keep a daily digest of jobs that needed a retry, because a rising count is an early warning that a vendor is degrading.&lt;/p&gt;

&lt;h2&gt;
  
  
  What to test before the workflow goes live
&lt;/h2&gt;

&lt;p&gt;Before I trust a workflow with real customers, I run a short set of ugly tests:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replay the same webhook twice, immediately.&lt;/li&gt;
&lt;li&gt;Kill the workflow after the first successful create, then run it again.&lt;/li&gt;
&lt;li&gt;Force a 429 or a timeout on one node and confirm the job resumes without a duplicate.&lt;/li&gt;
&lt;li&gt;Revoke a token and confirm the alert is clear.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If those four tests pass, the workflow is usually safe enough for a small team. If they have never been tried, I assume it will fail in production.&lt;/p&gt;

&lt;p&gt;I also prefer fewer well-owned workflows over a large pile of quick zaps. Reliability work does not scale linearly with the number of automations.&lt;/p&gt;

&lt;p&gt;The same ideas sit behind the n8n work I publish at &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;https://alecasgari.com/services/n8n-automation&lt;/a&gt;. If you are comparing tools rather than designing a specific workflow, I also wrote a practical comparison at &lt;a href="https://alecasgari.com/blog/n8n-vs-make-vs-zapier" rel="noopener noreferrer"&gt;https://alecasgari.com/blog/n8n-vs-make-vs-zapier&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Reliability will not make a messy process elegant. It will stop a useful process from creating duplicate invoices and missing leads. That is the bar I set before an automation runs unattended.&lt;/p&gt;

&lt;p&gt;I am Alec Asgari. If you want a second pair of eyes on a workflow that already fails in one of these ways, write to &lt;a href="mailto:hello@alecasgari.com"&gt;hello@alecasgari.com&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How I automate lead intake with n8n, Cloudflare Turnstile and Telegram</title>
      <dc:creator>Alec Asgari</dc:creator>
      <pubDate>Mon, 26 Oct 2026 11:26:43 +0000</pubDate>
      <link>https://dev.to/alecasgari/how-i-automate-lead-intake-with-n8n-cloudflare-turnstile-and-telegram-2mc3</link>
      <guid>https://dev.to/alecasgari/how-i-automate-lead-intake-with-n8n-cloudflare-turnstile-and-telegram-2mc3</guid>
      <description>&lt;p&gt;Most small-business websites still treat the contact form as an afterthought. A visitor fills it in, and an email lands in a shared inbox where it waits next to newsletters and invoices. Someone notices it hours later, or never. Meanwhile, half the messages are spam.&lt;/p&gt;

&lt;p&gt;When I rebuilt my own site, I replaced that whole chain with one n8n workflow. Every real enquiry now gets stored in a spreadsheet and pings my phone on Telegram within a few seconds. Bots get rejected before they cost me anything. Here is exactly how it is built, so you can copy the pattern.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shape of the workflow
&lt;/h2&gt;

&lt;p&gt;The workflow has fourteen nodes, but the logic is simple:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Webhook&lt;/strong&gt;: receives the form POST from the website.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Normalize&lt;/strong&gt;: a Code node that trims and cleans the fields.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Honeypot check&lt;/strong&gt;: drops obvious bots quietly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Validation&lt;/strong&gt;: rejects incomplete submissions with a clear error.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Turnstile verification&lt;/strong&gt;: asks Cloudflare whether the visitor is human.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Save to Google Sheets&lt;/strong&gt;: one row per lead.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Telegram message&lt;/strong&gt;: an instant notification.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Respond&lt;/strong&gt;: tells the website whether it worked, so the visitor sees a thank-you page or an error.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each step does one job, and the order matters. The cheap checks come first and the external calls come last.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: a webhook that only does one thing
&lt;/h2&gt;

&lt;p&gt;The site is a static build on Cloudflare Pages, so there is no backend of its own. The form posts JSON straight to an n8n Webhook node set to "respond using a Respond to Webhook node". That setting is important. The browser waits for n8n to decide, which means you can return a real &lt;code&gt;200&lt;/code&gt;, &lt;code&gt;400&lt;/code&gt; or &lt;code&gt;403&lt;/code&gt; instead of always saying "thanks".&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: normalize before you check anything
&lt;/h2&gt;

&lt;p&gt;Forms send messy data: trailing spaces, uppercase emails, empty strings that should be missing. A short Code node fixes that once, so every later node can trust the shape of the data:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;email&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toLowerCase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;company&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;company&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;      &lt;span class="c1"&gt;// honeypot field&lt;/span&gt;
  &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'cf-turnstile-response'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 3: the honeypot, the cheapest spam filter there is
&lt;/h2&gt;

&lt;p&gt;The form has a hidden field that real people never see. Bots that blindly fill every input fill it in too. If the honeypot is not empty, the workflow returns a normal &lt;code&gt;200&lt;/code&gt; and stops. The bot thinks it succeeded and moves on, and nothing reaches the sheet or my phone. It costs zero API calls.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 4: validate and fail loudly
&lt;/h2&gt;

&lt;p&gt;If the name, email or message is missing, or the email does not look like an email, the workflow responds with &lt;code&gt;400&lt;/code&gt;. The front end shows "please check the form" instead of pretending everything went fine. Silent failures are the main reason small businesses lose leads without ever knowing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Cloudflare Turnstile, verified on the server
&lt;/h2&gt;

&lt;p&gt;Turnstile is Cloudflare's free CAPTCHA alternative. Most visitors never click anything. The widget in the browser produces a token, but &lt;strong&gt;the token means nothing until your server checks it&lt;/strong&gt;. An HTTP Request node posts the token and the secret key to &lt;code&gt;https://challenges.cloudflare.com/turnstile/v0/siteverify&lt;/code&gt;. An IF node then reads &lt;code&gt;success&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Two practical tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep the secret in a Set ("Config") node or in n8n credentials, never in the front end.&lt;/li&gt;
&lt;li&gt;If the check fails, return &lt;code&gt;403&lt;/code&gt;. Real users almost never see it, but headless browsers and scripted tests often will. I learned that while testing my own form from an automated browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 6: store every lead somewhere boring and reliable
&lt;/h2&gt;

&lt;p&gt;A Google Sheets node appends a row with the timestamp, name, email, message and the page the visitor came from. A spreadsheet is not a CRM, but it is searchable, shareable and impossible to lose. Later you can add a node that pushes the same data into SuiteCRM, HubSpot or whatever you use, without touching the website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 7: Telegram, because email is where leads go to die
&lt;/h2&gt;

&lt;p&gt;The last action is a Telegram node that sends me a short message: who, what, and a link to the sheet. I see it on my phone within seconds, wherever I am. For a one-person business, replying in ten minutes instead of the next morning is the cheapest conversion boost there is.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 8: tell the browser what happened
&lt;/h2&gt;

&lt;p&gt;Every branch ends in a Respond to Webhook node: &lt;code&gt;200&lt;/code&gt; for success (and for the honeypot), &lt;code&gt;400&lt;/code&gt; for invalid input, &lt;code&gt;403&lt;/code&gt; for a failed Turnstile check. The front end turns these into a thank-you redirect or a clear error message. You can also fire a &lt;code&gt;generate_lead&lt;/code&gt; event to Google Analytics only on a real &lt;code&gt;200&lt;/code&gt;, so your conversion numbers are honest.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it costs and what it saves
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Cost:&lt;/strong&gt; Turnstile is free, Telegram is free, and Google Sheets is free. n8n runs self-hosted on a small server I already pay for.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Saves:&lt;/strong&gt; no spam in the inbox, no missed enquiries, and no paid form tool with a monthly fee per seat.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ownership:&lt;/strong&gt; the workflow, the data and the server are mine. If I change the website, the workflow stays the same.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Make it yours
&lt;/h2&gt;

&lt;p&gt;This pattern works for any static site: Astro, Next.js, Hugo or plain HTML. Start with the webhook, honeypot and Telegram nodes, which take about 30 minutes. Then add Turnstile and storage. Once leads arrive reliably, you can add AI steps, such as classifying the enquiry or drafting a first reply.&lt;/p&gt;

&lt;p&gt;I build workflows like this for small businesses in the Netherlands and across the EU. If you would rather not wire it up yourself, here is what an &lt;a href="https://alecasgari.com/services/n8n-automation" rel="noopener noreferrer"&gt;n8n automation project&lt;/a&gt; with me looks like, or see &lt;a href="https://alecasgari.com/projects" rel="noopener noreferrer"&gt;more of my work&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>n8n</category>
      <category>automation</category>
      <category>webdev</category>
      <category>smallbusiness</category>
    </item>
  </channel>
</rss>
