Vibe Coder #6.2: n8n and Workflow Architecture – Patching Calls Through the Switchboard
A workflow tool doesn't remove the backend; it moves it out of the repository and into a database row. I installed n8n 2.48.7 and put it on the scale: an open webhook, two emails for one order, a dedupe node that drops retries, an error workflow that never fires, agents publishing over MCP, and a PHP script that brings flows back to the weighbridge.
This post is also available in Turkish →
We closed the previous chapter with a confession: we built the weighbridge, the barrier and the calibration seal, and all of it lives inside the code repository. An agent's job doesn't always end with a commit. A webhook arrives, a table gets updated, an email goes out. The series index gave this chapter a one-line promise: "Connect systems instead of writing a backend." This chapter looks at n8n workflow automation and adds up the bill for that promise.
The metaphor: an old telephone switchboard. The operator plugs two cables together, the line connects, the call starts. Connecting a line is the easy part. The hard part is choosing who gets to call, knowing what happens when the same call comes in twice, making sure someone hears a dropped line, and keeping track of whose conversation ends up in the switchboard log. Workflow tools hand you the cables. The rest is still our job.
What does workflow architecture mean?#
In a workflow tool, work starts with a trigger and flows between nodes: a webhook arrives, data is transformed, a request goes out to a service. You draw connections instead of writing code. In vibe mode, the agent usually draws those connections too.
Here is the definition up front: A workflow tool doesn't remove the backend. It moves the backend out of the code repository and into a database row. The weighbridge we built in 6.1 can't see that row. The rest of this chapter is about putting the row back on the scale.
n8n is one of the best-known tools in this space that you can run on your own server. Its latest stable release on npm is 2.48.7, dated 20.11.2026, and it requires Node.js 24 or newer. The repository calls itself "fair-code": the source is open, but the license isn't open source in the OSI sense. The license file spells out the difference. The Sustainable Use License lets you use and modify the software only for your own internal business purposes or for non-commercial use, and files with .ee in their name fall under a separate enterprise license. Automating your own company's work is inside that definition; hosting n8n and offering it to customers as a service is, going by the license text, outside it. The company's CEO is Jan Oberhauser, and the npm package maintainers are n8n staff.
Setting up the switchboard#
I ran the tests on 22.11.2026 in a cloud sandbox: n8n 2.48.7 installed from npm on Node.js 24.22.3, with the default SQLite database. On startup n8n printed a notice: running outside a container is deprecated, and future versions will require the official Docker image. Worth knowing if you were planning an npm install on a shared PHP host.
The scenario is e-commerce: an order arrives, the customer gets an "order received" email. Instead of a real mail service I used a fake endpoint running under php -S that appends every incoming request to a log file. The first version of the flow:
{
"name": "Sipariş bildirimi (ajanın ilk hali)",
"nodes": [
{
"name": "Sipariş geldi",
"type": "n8n-nodes-base.webhook",
"parameters": { "httpMethod": "POST", "path": "siparis", "responseMode": "onReceived" }
},
{
"name": "Müşteriye e-posta",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"method": "POST",
"url": "http://127.0.0.1:8099/mail.php",
"sendHeaders": true,
"headerParameters": { "parameters": [
{ "name": "Authorization", "value": "Bearer sk_live_DENEME0000000000000000" }
] }
}
}
]
}
That's a trimmed version of the JSON; I imported the full file with the CLI and published it with n8n publish:workflow. I wrote the flow myself, not an agent, but I built in three patterns we keep seeing in agent output: a webhook with no authentication, a key pasted into a parameter, and a response sent the moment the request lands. Let's see where each one breaks.
An open line: the unauthenticated webhook#
I sent the same order twice with curl. Both returned 200, and two lines landed in the fake mail service's log:
$ curl -s -X POST localhost:5678/webhook/siparis -H 'Content-Type: application/json' \
-d '{"siparis_no":"S-1042","eposta":"ayse@example.com","telefon":"+90 555 000 00 00"}'
{"message":"Workflow was started"}
A webhook that doesn't ask who's calling is a listed number anyone can dial. Anyone who knows the URL, guesses it or spots it in a log can make your system email your customers.
The interesting part is that this default isn't an accident. The Webhook node's authentication field offers five options (Basic Auth, Header Auth, JWT Auth, n8n User Auth, None), and the default is none. The node definition in the installed package also carries a @builderHint line. These lines tell n8n's AI workflow builders, including the type definitions handed to an agent over MCP, how to fill in a node. The webhook's hint starts with Default to 'none'.: n8n keeps trigger URLs public by design, so only pick an authentication method if the user explicitly asks for one.
So when a user says "build me a flow that emails the customer when an order comes in", the agent will leave the door open unless authentication was requested. When patching a line is this easy, saying who may call is your job, and it belongs in the prompt.
The fix: I switched authentication to Header Auth and stored the key in a credential. Requests with no key and with the wrong key both got 403 with Authorization data is wrong! in the body. The Webhook docs also describe an IP allowlist; left blank, any address can trigger the URL. If the sender is a fixed server, use both.
The double call: the same order twice#
Authentication is fixed, but the second email from the first test is still there. In real life that second request doesn't come from an attacker. It comes from the sender: your payment provider or your own PHP app retries the same notification after a timeout. If the workflow isn't ready for that, the customer gets two emails. If the step decrements stock instead of sending email, it gets expensive.
n8n has a node for this: Remove Duplicates, with the "remove items seen in previous executions" operation. I keyed it on the order number and put it between the webhook and the email. Same order twice, one email. Nice.
Then I configured the mail service to return 500 for one order. S-9999 came in, the mail service refused, and the execution ended in error. The sender retried. Result: execution success, and not a single request reached the mail service. The node had stored the key before the email was sent, so it dropped the retry of a failed job as "already seen". The switchboard gives the second call a busy signal without knowing the first one never connected.
The duplicate check belongs where the side effect happens, in the same transaction as the side effect. If the email goes out from your own PHP endpoint, a primary key and a transaction are all it takes:
CREATE TABLE gonderilen_bildirim (
siparis_no VARCHAR(32) NOT NULL PRIMARY KEY,
gonderildi DATETIME NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
<?php
declare(strict_types=1);
// n8n'in çağırdığı uç: aynı sipariş için e-postayı bir kez gönderir.
// Tekrarı sipariş numarası ayıklar, kaydı ancak gönderim başarılı olunca kalıcı olur.
header('Content-Type: application/json');
function cevap(int $kod, array $govde): never
{
http_response_code($kod);
echo json_encode($govde, JSON_UNESCAPED_UNICODE);
exit;
}
$beklenen = (string) getenv('BILDIRIM_ANAHTARI');
if ($beklenen === '' || !hash_equals($beklenen, $_SERVER['HTTP_X_IMZA'] ?? '')) {
cevap(401, ['hata' => 'yetkisiz']);
}
$istek = json_decode((string) file_get_contents('php://input'), true);
$siparisNo = is_array($istek) ? (string) ($istek['siparis_no'] ?? '') : '';
$alici = is_array($istek) ? (string) ($istek['eposta'] ?? '') : '';
if (preg_match('/^S-[0-9A-Za-z-]{1,24}$/', $siparisNo) !== 1 || filter_var($alici, FILTER_VALIDATE_EMAIL) === false) {
cevap(422, ['hata' => 'geçersiz istek']);
}
$db = new PDO((string) getenv('BILDIRIM_DSN'), (string) getenv('BILDIRIM_DB_KULLANICI'), (string) getenv('BILDIRIM_DB_SIFRE'), [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
]);
$db->beginTransaction();
try {
$db->prepare('INSERT INTO gonderilen_bildirim (siparis_no, gonderildi) VALUES (?, NOW())')->execute([$siparisNo]);
} catch (PDOException $e) {
$db->rollBack();
if (($e->errorInfo[1] ?? 0) === 1062) {
cevap(200, ['durum' => 'zaten gönderildi']); // tekrar: yan etki yok
}
throw $e;
}
$baglam = stream_context_create(['http' => [
'method' => 'POST',
'header' => "Content-Type: application/json\r\nAuthorization: Bearer " . getenv('EPOSTA_ANAHTARI'),
'content' => json_encode(['to' => $alici, 'konu' => "Siparişiniz alındı: {$siparisNo}"], JSON_UNESCAPED_UNICODE),
'ignore_errors' => true,
'timeout' => 10,
]]);
$sonuc = @file_get_contents((string) getenv('EPOSTA_URL'), false, $baglam);
$durumSatiri = $http_response_header[0] ?? '';
if ($sonuc === false || preg_match('#^HTTP/\S+ 2\d\d#', $durumSatiri) !== 1) {
$db->rollBack(); // kayıt düşer, gönderen tekrar denediğinde yeniden dener
cevap(502, ['hata' => 'e-posta servisi cevap vermedi']);
}
$db->commit();
cevap(200, ['durum' => 'gönderildi']);
The row lock does half the work: a second request with the same order number waits until the first transaction finishes. If the first commits, the second gets 1062 and answers "zaten gönderildi" (already sent); if the first rolls back, the second takes its turn. With MariaDB 10.11.14 and PHP 8.3.6 I sent the same order as five parallel requests: one "sent", four "already sent", a single request to the mail service. Switching the mail service off and on behaved correctly too: the first request got 502, the retry got "sent". We discussed the same idea for stock counts in the ON DUPLICATE KEY UPDATE post; here we use it as a lock instead of a counter.
This isn't an n8n bug; it's a boundary. A workflow tool can't know whether a side effect actually happened. The endpoint doing the work knows. The flow calls the endpoint, and the endpoint decides what counts as a repeat.
The dropped line: when nobody hears it#
When S-9999 failed in the first flow, what did the sender see? 200 and {"message":"Workflow was started"}. The webhook was set to answer as soon as the request arrived (responseMode: onReceived). The sender assumed the job was done and never retried. The failure survived only as a red row in n8n's execution list.
With the webhook set to return the last node's result (lastNode), the sender got 500 when the PHP endpoint returned 502, so a retry finally meant something. That's also why the endpoint from the previous section matters: the moment you turn retries on, you need an endpoint that survives repeats.
Then there's the error workflow: a separate flow that runs when another one fails and passes the alarm on to you. I selected one in the settings, and the first failure produced no alarm. n8n's log had the reason:
Calling Error Workflow for "SiparisBildirim02". Workflow "HataAkisi01" is not active and cannot be executed
In 2.48.7 the error workflow itself has to be published. After I published it, the next failure dropped an alarm into the fake service. The setting had been selected all along; I only found out it wasn't working by reading the server log. We wired the line and installed the alarm bell, but nobody put a battery in it.
The switchboard log: execution records#
Old switchboard operators kept a log: who called whom, and when. n8n's log is more detailed; it records the conversation too. I looked at the records of the first two executions in SQLite: the customer's phone number sat in plain text in the execution_data table, together with the full body that hit the webhook.
According to the execution data docs, the defaults are: every successful and failed execution is saved, pruning is on, and records are kept for 336 hours (14 days) or up to 10,000 executions. I turned off saving successful executions in the workflow settings; the records weren't deleted immediately, they were stamped with deletedAt. The docs put the hard-delete buffer at one hour.
For any flow carrying personal data, ask two questions: how long does it stay in the log, and who can read the log? The next section answers the second one.
When the agent gets into the switchboard: MCP#
n8n ships an instance-level MCP server. The docs list Claude Code, Codex and Gemini CLI on the CLI side; Cursor, VS Code and Windsurf on the editor side; Claude.ai and ChatGPT on the web. In the MCP post we said the protocol standardizes the plug, not what runs inside the cable. I read the 2.48.7 source to see what's inside this one:
- Building and publishing: the
create_workflow_from_code,update_workflowandpublish_workflowtools are in the installed package. An agent can write a flow and put it live. None of the weighbridge, barrier or seal from 6.1 sits on that path. - Credentials: according to the tools reference,
create_workflow_from_codeassigns available credentials to nodes automatically. - The log:
get_workflow_executionwithincludeData: truereturns node execution data, and it's annotated as read-only (readOnlyHint: true). So even with the instance in read-only mode, an agent can read the phone number above. - Scope: MCP is enabled per instance, and each workflow must be enabled separately; "auto-expose new workflows" is off by default. The docs also state a limit plainly: you can't restrict specific workflows to specific clients.
My recommendation: connect agents to a separate development instance with no real customer data, not to production. Let the agent build flows there, bring the workflow JSON into the repository, and let promotion to production go through the weighbridge. If you don't want MCP in production at all, N8N_DISABLED_MODULES=mcp removes the module from a self-hosted instance.
Moving the weighbridge to the switchboard: workflows in git#
n8n's built-in source control (pushing and pulling workflows to git) is available on the Business and Enterprise plans only. If you self-host the community edition, you have the CLI:
n8n export:workflow --all --separate --output=akislar/
Each workflow comes out as a separate JSON file, and files are something the weighbridge can weigh. Credentials don't go into the workflow file, only their ID and name; export:credentials writes encrypted data by default, and the help text for the --decrypted flag warns in capital letters. One catch: the exported file includes a pinData field. If you pinned a real customer record as sample data in the editor, that goes into the repository too.
The weighbridge follows the same pattern as the mine gate from 6.1: a dependency-free PHP script, 0 clean, 2 findings, 1 usage error. Its messages are in Turkish, like the rest of the series code:
<?php
declare(strict_types=1);
/**
* akis-kantari.php — n8n'den dışa aktarılan workflow JSON'larını tartar.
* Kullanım: php akis-kantari.php <klasör>
* Çıkış: 0 temiz, 2 bulgu var, 1 kullanım/okuma hatası.
*/
const KAPI_TURLERI = [
'n8n-nodes-base.webhook',
'n8n-nodes-base.formTrigger',
'@n8n/n8n-nodes-langchain.chatTrigger',
'@n8n/n8n-nodes-langchain.mcpTrigger',
];
const ANAHTAR_KALIPLARI = [
'/\b[sr]k_(live|test)_[A-Za-z0-9]{8,}/' => 'ödeme/servis anahtarı',
'/Bearer\s+[A-Za-z0-9._\-]{12,}/' => 'Bearer token',
'/\bAKIA[0-9A-Z]{16}\b/' => 'AWS erişim anahtarı',
'/\bgh[pousr]_[A-Za-z0-9]{20,}/' => 'GitHub token',
'/-----BEGIN [A-Z ]*PRIVATE KEY-----/' => 'özel anahtar',
];
/** @return list<string> */
function duzMetinler(mixed $deger): array
{
if (is_string($deger)) {
// "=" ile başlayan değer n8n ifadesidir; çalışma anında çözülür, dosyada sır taşımaz.
return str_starts_with($deger, '=') ? [] : [$deger];
}
if (!is_array($deger)) {
return [];
}
$metinler = [];
foreach ($deger as $alt) {
array_push($metinler, ...duzMetinler($alt));
}
return $metinler;
}
$klasor = $argv[1] ?? '';
if ($klasor === '' || !is_dir($klasor)) {
fwrite(STDERR, "Kullanım: php akis-kantari.php <dışa aktarma klasörü>\n");
exit(1);
}
$akislar = [];
foreach (glob(rtrim($klasor, '/') . '/*.json') ?: [] as $dosya) {
$veri = json_decode((string) file_get_contents($dosya), true);
if (!is_array($veri) || !isset($veri['id'], $veri['nodes'])) {
fwrite(STDERR, "Okunamadı: {$dosya}\n");
exit(1);
}
$akislar[(string) $veri['id']] = $veri;
}
$bulgular = [];
$uyarilar = [];
foreach ($akislar as $id => $akis) {
$ad = (string) ($akis['name'] ?? $id);
$yayinda = ($akis['active'] ?? false) === true;
$disaAcik = false;
foreach ($akis['nodes'] as $dugum) {
$tur = (string) ($dugum['type'] ?? '');
$parametre = $dugum['parameters'] ?? [];
$etiket = "{$ad} / " . ($dugum['name'] ?? '?');
if (in_array($tur, KAPI_TURLERI, true)) {
$disaAcik = true;
if (($parametre['authentication'] ?? 'none') === 'none') {
$bulgular[] = "{$etiket}: kimliksiz giriş — URL'yi bilen herkes akışı çalıştırır";
}
}
foreach (duzMetinler($parametre) as $metin) {
foreach (ANAHTAR_KALIPLARI as $kalip => $tanim) {
if (preg_match($kalip, $metin) === 1) {
$bulgular[] = "{$etiket}: parametrede düz metin {$tanim} — credential'a taşı";
}
}
}
if ($tur === 'n8n-nodes-base.removeDuplicates'
&& ($parametre['operation'] ?? '') === 'removeItemsSeenInPreviousExecutions') {
$uyarilar[] = "{$etiket}: anahtar yan etkiden önce kaydediliyor — başarısız işin tekrarı düşer";
}
}
if ($yayinda && $disaAcik) {
$hataAkisi = (string) ($akis['settings']['errorWorkflow'] ?? '');
if ($hataAkisi === '') {
$bulgular[] = "{$ad}: hata akışı tanımlı değil — hata yalnızca yürütme listesinde kalır";
} elseif (!isset($akislar[$hataAkisi])) {
$bulgular[] = "{$ad}: hata akışı ({$hataAkisi}) dışa aktarmada yok";
} elseif (($akislar[$hataAkisi]['active'] ?? false) !== true) {
$bulgular[] = "{$ad}: hata akışı ({$hataAkisi}) yayında değil — n8n onu çalıştırmaz";
}
}
}
foreach ($uyarilar as $uyari) {
echo "uyarı: {$uyari}\n";
}
foreach ($bulgular as $bulgu) {
echo "{$bulgu}\n";
}
if ($bulgular === []) {
echo count($akislar) . " akış tartıldı. Kantar temiz.\n";
exit(0);
}
echo count($bulgular) . " bulgu. Kantar kapalı.\n";
exit(2);
If the authentication field is missing from the file, the script treats it as none; the export of the first flow had no authentication key, because n8n doesn't write default values. Output against the export of all four flows from the experiment:
$ php akis-kantari.php akislar/
uyarı: Sipariş bildirimi (kantarlı) / Aynı sipariş ikinci kez mi?: anahtar yan etkiden önce kaydediliyor — başarısız işin tekrarı düşer
Sipariş bildirimi (ajanın ilk hali) / Sipariş geldi: kimliksiz giriş — URL'yi bilen herkes akışı çalıştırır
Sipariş bildirimi (ajanın ilk hali) / Müşteriye e-posta: parametrede düz metin ödeme/servis anahtarı — credential'a taşı
Sipariş bildirimi (ajanın ilk hali) / Müşteriye e-posta: parametrede düz metin Bearer token — credential'a taşı
Sipariş bildirimi (ajanın ilk hali): hata akışı tanımlı değil — hata yalnızca yürütme listesinde kalır
4 bulgu. Kantar kapalı.
$ echo $?
2
The script flags an open webhook ("kimliksiz giriş"), two plain-text secrets in a parameter ("düz metin ... credential'a taşı"), a missing error workflow, and warns about the Remove Duplicates trap. I weighed the final version (Header Auth, PHP endpoint, published error workflow) together with the error workflow in a separate folder: "2 akış tartıldı. Kantar temiz." (2 flows weighed, clean), exit 0. With the error workflow marked unpublished, the script reported it as not live and exited with 2.
The rest is familiar from 6.1. Add the script to kantar.yml as one more step; the TABAN (base) variable comes from that job definition, and the script is again taken from the base branch:
- name: Akış kantarı (tabandaki sürümle)
run: |
git show "$TABAN:araclar/akis-kantari.php" > "$RUNNER_TEMP/akis-kantari.php"
php "$RUNNER_TEMP/akis-kantari.php" akislar/
Add /akislar/ @HalitYesil to CODEOWNERS as well. Workflow JSON now goes through review like code. I didn't run this step on GitHub Actions; I checked that it parses as YAML and ran the script locally in four scenarios.
Hard Truth: this is only a gate if production workflows come from the repository. If someone opens the editor and changes a flow there, the repository and the switchboard drift apart. Restrict edit rights on the production instance, run the export regularly and look at git diff; if there's a difference, someone drove around the weighbridge.
n8n isn't the only option#
Tools doing the same job sit in different places. Licenses were read from official pages and npm on 22.11.2026:
| Tool | What | License | When |
|---|---|---|---|
| n8n | Visual flows + code node, MCP server | Sustainable Use License, .ee files enterprise |
Internal integrations, lots of ready-made connectors |
| Node-RED | Visual, event-driven flows | Apache-2.0 (npm 5.0.10) | Devices, MQTT, light integration; when you want a permissive license |
| Activepieces | Visual flows | MIT core, enterprise folders commercial | When you want an MIT core |
| Windmill | Scripts and flows, code first | AGPLv3, clients Apache-2.0, enterprise features commercial | When the flow should really live as code |
| Temporal | Durable workflows as code | TypeScript SDK is MIT | Long-running work that must retry step by step |
| Plain PHP + cron + queue | Your own code | Yours | Two or three steps, and you already run a PHP server |
The last row isn't a joke. For a flow that takes a webhook and sends one email, a separate Node.js service, a separate database and a separate backup plan are often overkill. Once a flow spans ten steps and five services, and teammates who don't write code need to read it, the switchboard pays for itself.
When isn't it enough?#
- The switchboard isn't where business logic lives. Pricing, stock decrements and permission checks buried in a flow as code nodes turn into a backend with no tests, no types and no code review. Keep the rule in PHP and let the flow call it.
- A flow built by an agent is still code written by an agent. The point from 5.3 holds here: tests ask about what we want, not about what we don't want. Saying "no unauthenticated webhooks" in the prompt isn't enough; the rule belongs on the weighbridge too.
- Updates are a line item. n8n's security update of 28.10.2026 listed twelve advisories in one go, three rated high. In January 2026 the Canadian Centre for Cyber Security issued an alert covering three n8n vulnerabilities, including a critical remote code execution flaw (CVE-2025-68613). A switchboard facing the internet needs as much patching attention as your PHP version.
We'd built the weighbridge; now the road it couldn't see is on the map too. The next chapter, Vibe Coder #7.1: The Age of Agents, moves from individual tools to autonomous agent units. The full series and the list of published chapters are on the Vibe Coder's Handbook page (in Turkish).
A switchboard connects the line. Who called, whether the same call came in twice and who hears the dropped line are still yours to know. Stay with technology.
Comments
0 comments
Leave a comment