YA, BISA — DAN INI BEST PRACTICE. Membuat workflow terpisah per niche (satu untuk kuliner, satu untuk teknologi, satu untuk properti) adalah anti-pattern: maintenance ganda, update prompt berulang, credential management repot, scaling susah.
Arsitektur modern n8n: Config-Driven Architecture — satu workflow generic, parameterisasi semua yang niche-specific (prompt, credential, domain, tone, schedule) via config external (Google Sheets, Airtable, Baserow, JSON file). Artikel ini mengajarkan cara membangun & mengelolanya.
Mengapa Satu Workflow Multi-Niche Lebih Unggul?
| Aspek | Workflow Terpisah per Niche (Anti-Pattern) | Satu Workflow Config-Driven (Best Practice) |
|---|---|---|
| Maintenance | Update 5 workflow kalau ganti prompt outline | Update 1 workflow, semua niche ikut |
| Credential Management | Credential duplikat per workflow | Satu set credential, referensi di config |
| Deployment | Import/activate 5x | Import/activate 1x |
| Monitoring | Dashboard terpecah | Satu log terpusat, filter by niche |
| Scaling Niche Baru | Bikin workflow baru (copy-paste-modify) | Tambah 1 baris di config sheet (2 menit) |
| Version Control | 5 file .json terpisah, sync manual | 1 file .json, Git-friendly |
| Team Collaboration | VA bingung buka workflow mana | VA hanya edit config sheet |
Arsitektur Config-Driven: Konsep Inti
│
├── Trigger (Cron / Sheets / Telegram / Webhook)
│
├── Node: Load Config (Read Google Sheets/Airtable → Filter by Niche/Run)
│ │
│ └── Output: domain_wp, wp_cred_ref, ai_model, ai_cred_ref,
│ prompt_outline, prompt_section, prompt_merge,
│ tone, language, schedule, max_articles, etc.
│
├── Node: Set Dynamic Credentials (Expression: {{$json.wp_cred_ref}})
│
├── Node: Auto Content Pipeline (Outline → Write Loop → Merge → Publish)
│ │
│ └── Semua prompt & parameter pakai expression {{$json.prompt_outline}}, {{$json.tone}}, dll
│
├── Node: Log & Notify (Include niche label di log)
│
└── Output: Success/Failed → Update Config Sheet (Last Run, Status, Count)
Kunci: Expression di n8n support dynamic credential reference — Anda bisa set credential HTTP Request via expression {{$json.wp_cred_ref}} (harus enable “Define Credentials Dynamically” di node settings).
Struktur Config External (Google Sheets / Airtable)
Tab Niche_Config (satu baris = satu niche/site):
| Kolom | Contoh: Kuliner | Contoh: Teknologi | Contoh: Properti | Keterangan |
|---|---|---|---|---|
| niche_id | kuliner | teknologi | properti | Unique key, dipakai filter |
| niche_name | Kuliner & Resep | Teknologi & Gadget | Properti & Real Estate | Label untuk log/notif |
| wp_domain | resepkita.com | teknoupdate.com | propertiprima.com | Domain WP target |
| wp_cred_ref | WP_ResepKita | WP_TeknoUpdate | WP_PropertiPrima | Nama credential di n8n (Header Auth) |
| ai_model | gpt-4o-mini | claude-3-5-haiku | gemini-1.5-flash | Model AI per niche |
| ai_cred_ref | OpenAI_GPT4oMini | Claude_Haiku | Gemini_Flash | Nama credential AI di n8n |
| prompt_outline | ID_OUTLINE_KULINER | ID_OUTLINE_TEKNO | ID_OUTLINE_PROPERTI | Reference ke tab Prompt_Templates |
| prompt_section | ID_SECTION_KULINER | ID_SECTION_TEKNO | ID_SECTION_PROPERTI | Reference ke tab Prompt_Templates |
| prompt_merge | ID_MERGE_KULINER | ID_MERGE_TEKNO | ID_MERGE_PROPERTI | Reference ke tab Prompt_Templates |
| tone | ramah, praktis, ibu rumah tangga | teknis, analitis, early adopter | profesional, investasi, trusted advisor | Tone of voice untuk AI |
| language | id | id | id | Bahasa (id/en/auto) |
| lsi_keywords_default | resep, cara masak, bumbu, tips | review, spesifikasi, harga, fitur | harga, lokasi, investasi, legalitas | Fallback jika tidak pakai SerpAPI |
| internal_link_sources | https://resepkita.com/kategori/ | https://teknoupdate.com/kategori/ | https://propertiprima.com/kategori/ | Base URL untuk internal link |
| schedule_cron | 0 7,19 * * * | 0 8,20 * * * | 0 9,18 * * 1-5 | Cron expression per niche |
| timezone | Asia/Jakarta | Asia/Jakarta | Asia/Jakarta | IANA timezone |
| max_articles_per_run | 3 | 2 | 2 | Batch size per eksekusi |
| approval_required | false | true | false | Butuh human approval? |
| status | active | active | paused | active/paused/archived |
| last_run | 2026-11-24 07:00 | 2026-11-24 08:00 | Auto-update by workflow | |
| articles_today | 2 | 1 | 0 | Counter harian (reset cron harian) |
| max_articles_daily | 10 | 5 | 5 | Limit harian per niche |
Tab Prompt_Templates (prompt terpisah per niche, versioned):
| prompt_id | niche_id | type | version | system_prompt | user_prompt_template | updated_at |
|---|---|---|---|---|---|---|
| ID_OUTLINE_KULINER | kuliner | outline | v2.1 | Anda SEO Strategis kuliner… | Judul: {{judul}} Keyword: {{keyword}} LSI: {{lsi}}… | 2026-11-20 |
| ID_SECTION_KULINER | kuliner | section | v2.1 | Anda Copywriter kuliner… | H2: {{h2}} Poin: {{points}} Tone: {{tone}}… | 2026-11-20 |
| ID_MERGE_KULINER | kuliner | merge | v1.0 | Anda Editor… | Sections: {{sections}} FAQ: {{faq}}… | 2026-11-15 |
Implementasi di n8n: Step-by-Step
1. Setup Credential di n8n (Satu Kali)
Buat credential untuk SETIAP domain WP & AI model (bukan per workflow):
- Header Auth:
WP_ResepKita,WP_TeknoUpdate,WP_PropertiPrima - OpenAI API:
OpenAI_GPT4oMini,OpenAI_GPT4o - Anthropic API:
Claude_Haiku,Claude_Sonnet - Google PaLM API:
Gemini_Flash,Gemini_Pro
2. Node: Load Config (Google Sheets Read)
- Operation: Read
- Range:
Niche_Config!A:Z - Filter (node IF setelah Read):
{{$json.status === 'active' && $json.articles_today < $json.max_articles_daily}} - Untuk scheduled run: tambah filter cron match (node IF: check apakah niche ini scheduled sekarang)
3. Node: Split In Batches (Per Niche/Item)
- Mode: Run Once for Each Item
- Input: filtered config rows
- Batch Size: 1
4. Node: Set Dynamic Variables (Di Dalam Loop)
Nama: Set Niche Variables — extract config ke variables flat untuk expression mudah:
niche_id:{{$json.niche_id}}niche_name:{{$json.niche_name}}wp_domain:{{$json.wp_domain}}wp_cred_ref:{{$json.wp_cred_ref}}ai_model:{{$json.ai_model}}ai_cred_ref:{{$json.ai_cred_ref}}prompt_outline_id:{{$json.prompt_outline}}prompt_section_id:{{$json.prompt_section}}prompt_merge_id:{{$json.prompt_merge}}tone:{{$json.tone}}language:{{$json.language}}lsi_default:{{$json.lsi_keywords_default}}internal_base:{{$json.internal_link_sources}}approval_required:{{$json.approval_required}}max_articles:{{$json.max_articles_per_run}}
5. Node: Load Prompt Templates (Google Sheets Read — Cached)
Baca tab Prompt_Templates → Filter by prompt_id dari config → Merge ke item.
- Gunakan node Merge (Combine) mode Wait for All → combine config item + prompt templates
- Atau: Load semua prompt sekali di awal workflow (sebelum Split), lalu Set di dalam loop pick by ID
6. Node: Auto Content Pipeline (Parameterized)
Semua node AI menggunakan expression dynamic:
- OpenAI/Anthropic/Gemini Node:
- Credential: Define Credentials Dynamically: ON → Expression:
{{$json.ai_cred_ref}} - Model: Expression:
{{$json.ai_model}} - System Prompt: Expression:
{{$json.prompt_outline_system}}(dari prompt template) - User Prompt: Expression dengan variable injection:
Judul: {{$json.judul}} Keyword: {{$json.keyword_utama}} Tone: {{$json.tone}} LSI: {{$json.lsi_keywords}}...
- Credential: Define Credentials Dynamically: ON → Expression:
- HTTP Request (WP Publish):
- Credential: Define Credentials Dynamically: ON → Expression:
{{$json.wp_cred_ref}} - URL: Expression:
https://{{$json.wp_domain}}/wp-json/wp/v2/posts
- Credential: Define Credentials Dynamically: ON → Expression:
- Code Node (Merge/Finalize):
- Internal link base:
{{$json.internal_base}} - Language:
{{$json.language}} - Tone:
{{$json.tone}}
- Internal link base:
7. Node: Log & Update Config (Setelah Publish)
- Google Sheets Update: tab
Niche_Config→ row niche ini:last_run:{{$now.format('YYYY-MM-DD HH:mm:ss')}}articles_today:{{$json.articles_today + 1}}
- Google Sheets Append: tab
Publish_Log(log terpusat semua niche):- Timestamp, Niche, Judul, Slug, Status, Post ID, Link, Duration, Error
- Telegram Notif:
✅ [{{$json.niche_name}}] {{$json.judul}} → {{$json.wp_response.link}}
8. Cron Harian Reset Counter (Workflow Terpisah)
- Cron:
0 0 * * *(midnight WIB) - Google Sheets Update: tab
Niche_Config→ Setarticles_today = 0untuk semua rowstatus=active
Multi-Site vs Multi-Niche Same Site
| Skenario | Config Strategy | |
|---|---|---|
| Multi-site (domain berbeda per niche) | Config di atas: wp_domain & wp_cred_ref berbeda per niche | |
| Multi-niche same site (satu WP, kategori berbeda) | wp_domain & wp_cred_ref SAMA, beda: internal_base per kategori, prompt per niche, schedule bisa sama/berbeda | |
| Multi-client Agency (white-label) | Config per client: wp_domain (client), wp_cred_ref (client), niche (client), approval_required=true. Satu workflow serve N client. |
| Issue | Penyebab | Fix |
|---|---|---|
| Wrong credential used (publish ke site salah) | Define Credentials Dynamically OFF / expression salah | ON kan "Define Credentials Dynamically" di node HTTP Request & AI. Test expression: {{$json.wp_cred_ref}} harus return exact credential name di n8n |
| Prompt tidak ke-load (undefined) | Merge prompt template gagal / prompt_id mismatch | Log prompt_id di Set node. Debug: tambah node Set "Debug Prompt" → output prompt_outline: {{$json.prompt_outline_system?.substring(0,50)}} → cek execution log |
| Niche tidak jalan padahal active | articles_today >= max_articles_daily / cron filter salah | Cek sheets: articles_today vs max_articles_daily. Cek cron expression & timezone di config |
| Internal link salah domain | internal_base tidak di-set / hardcoded | Pastikan internal_base di config per niche. Di Code Merge: gunakan {{$json.internal_base}} untuk generate link |
| Rate limit AI karena multi-niche jalan paralel | Split In Batches jalan paralel default | Set Batch Size: 1 + Options: Reset: Never + node Wait di loop. Atau gunakan Queue mode (Baserow/Redis) untuk serialize |