The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "RTK-AG04 | The Writer - Journalist Agent",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "ag04-writer",
"responseMode": "responseNode",
"options": {}
},
"name": "Webhook: Receive Assignment",
"type": "n8n-nodes-base.webhook",
"typeVersion": 2,
"position": [
0,
300
]
},
{
"parameters": {
"method": "GET",
"url": "={{ $env.SUPABASE_URL }}/rest/v1/actor_profiles?name=ilike.*{{ encodeURIComponent(($json.actors || []).map(a => a.name).join('|')) }}*&limit=10",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "apikey",
"value": "={{ $env.SUPABASE_KEY }}"
},
{
"name": "Authorization",
"value": "=Bearer {{ $env.SUPABASE_KEY }}"
}
]
},
"options": {}
},
"name": "Supabase: Get Actor Context",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
240,
300
],
"continueOnFail": true
},
{
"parameters": {
"jsCode": "const article = $('Webhook: Receive Assignment').first().json;\nconst actorContext = $input.first().json || [];\n\nconst contentType = article.content_type || 'analytical_report';\nconst wordRanges = {\n 'deep_analysis': '1800 \u0625\u0644\u0649 2800',\n 'analytical_report': '900 \u0625\u0644\u0649 1400',\n 'flash': '350 \u0625\u0644\u0649 550'\n};\nconst wordRange = wordRanges[contentType] || '900 \u0625\u0644\u0649 1400';\n\nconst actorContextStr = Array.isArray(actorContext) && actorContext.length > 0\n ? '\u0633\u064a\u0627\u0642 \u0627\u0644\u0634\u062e\u0635\u064a\u0627\u062a \u0627\u0644\u0645\u0639\u0631\u0648\u0641\u0629: ' + actorContext.map(a => `${a.name}: ${a.last_mentions || ''}`).join(' | ')\n : '';\n\nconst systemPrompt = `\u0623\u0646\u062a \u0635\u062d\u0641\u064a \u0639\u0631\u0628\u064a \u0642\u0636\u064a\u062a \u062b\u0644\u0627\u062b\u064a\u0646 \u0639\u0627\u0645\u0627\u064b \u0641\u064a \u0643\u0628\u0631\u064a\u0627\u062a \u0627\u0644\u0635\u062d\u0641 \u0648\u0627\u0644\u0645\u062c\u0644\u0627\u062a \u0627\u0644\u0639\u0627\u0644\u0645\u064a\u0629. \u0643\u062a\u0628\u062a \u0644\u0640 \u0627\u0644\u062d\u064a\u0627\u0629\u060c \u0648\u0627\u0644\u0634\u0631\u0642 \u0627\u0644\u0623\u0648\u0633\u0637\u060c \u0648\u0644\u0641\u062a\u0631\u0627\u062a \u0641\u064a \u0627\u0644\u063a\u0627\u0631\u062f\u064a\u0627\u0646. \u062a\u0643\u062a\u0628 \u0644\u0644\u0642\u0627\u0631\u0626 \u0627\u0644\u0630\u064a \u064a\u0642\u0631\u0623 Foreign Affairs \u0628\u0627\u0644\u0625\u0646\u062c\u0644\u064a\u0632\u064a\u0629 \u0644\u0623\u0646\u0647 \u0644\u0627 \u064a\u062c\u062f \u0645\u0627 \u064a\u0639\u0627\u062f\u0644\u0647 \u0628\u0627\u0644\u0639\u0631\u0628\u064a\u0629.\n\n\u0642\u0648\u0627\u0639\u062f \u0644\u0627 \u062a\u064f\u062e\u0627\u0644\u064e\u0641:\n- \u0627\u0641\u062a\u062d \u0628\u0645\u0634\u0647\u062f \u0623\u0648 \u0633\u0624\u0627\u0644 \u0645\u062d\u062f\u062f\u060c \u0644\u0627 \u0628\u0625\u0639\u0644\u0627\u0646 \u0639\u0646 \u0627\u0644\u0645\u0648\u0636\u0648\u0639\n- \u0636\u0639 \u0627\u0644\u062e\u0628\u0631 \u0641\u064a \u0627\u0644\u0641\u0642\u0631\u0629 \u0627\u0644\u062b\u0627\u0646\u064a\u0629 \u0623\u0648 \u0627\u0644\u062b\u0627\u0644\u062b\u0629\n- \u062c\u0645\u0644\u0629 \u0637\u0648\u064a\u0644\u0629 \u062a\u0644\u064a\u0647\u0627 \u062c\u0645\u0644\u0629 \u0642\u0635\u064a\u0631\u0629. \u062f\u0627\u0626\u0645\u0627\u064b.\n- \u0627\u062d\u062c\u0628 \u0623\u0647\u0645 \u0641\u0643\u0631\u0629 \u062d\u062a\u0649 \u0627\u0644\u0641\u0642\u0631\u0627\u062a \u0627\u0644\u0623\u062e\u064a\u0631\u0629\n- \u0627\u0644\u062d\u0643\u0645 \u0636\u0645\u0646\u064a \u0639\u0628\u0631 \u0627\u0644\u0627\u062e\u062a\u064a\u0627\u0631 \u0648\u0627\u0644\u062d\u0630\u0641 \u0644\u0627 \u0639\u0628\u0631 \u0627\u0644\u062a\u0635\u0631\u064a\u062d\n\n\u0645\u0627 \u064a\u064f\u062d\u0638\u0631 \u062a\u0645\u0627\u0645\u0627\u064b:\n- \u0644\u0627 \u0634\u0631\u0637\u0629 \u0645\u0632\u062f\u0648\u062c\u0629 \u0641\u064a \u0627\u0644\u0646\u0635 \u0625\u0637\u0644\u0627\u0642\u0627\u064b\n- \u0644\u0627 \u0639\u0628\u0627\u0631\u0627\u062a AI: (\u0641\u064a \u0627\u0644\u062e\u062a\u0627\u0645 / \u064a\u062a\u0636\u062d \u0645\u0645\u0627 \u0633\u0628\u0642 / \u0644\u0627 \u0634\u0643 \u0623\u0646 / \u064a\u0645\u0643\u0646 \u0627\u0644\u0642\u0648\u0644 / \u062a\u062c\u062f\u0631 \u0627\u0644\u0625\u0634\u0627\u0631\u0629 / \u0641\u064a \u0647\u0630\u0627 \u0627\u0644\u0625\u0637\u0627\u0631 / \u0639\u0644\u0649 \u0635\u0639\u064a\u062f / \u0648\u0641\u064a \u0633\u064a\u0627\u0642)\n- \u0644\u0627 \u0647\u064a\u0627\u0643\u0644 \u0645\u062a\u0646\u0627\u0638\u0631\u0629: (\u0645\u0646 \u0646\u0627\u062d\u064a\u0629... \u0648\u0645\u0646 \u0646\u0627\u062d\u064a\u0629 \u0623\u062e\u0631\u0649)\n- \u0644\u0627 \u062d\u064a\u0627\u062f\u064a\u0629 \u0632\u0627\u0626\u0641\u0629 \u062d\u064a\u0646 \u0627\u0644\u062d\u0642\u064a\u0642\u0629 \u0648\u0627\u0636\u062d\u0629\n- \u0644\u0627 \u062e\u0627\u062a\u0645\u0627\u062a \u0623\u062e\u0644\u0627\u0642\u064a\u0629 \u0645\u0628\u0627\u0634\u0631\u0629\n- \u0644\u0627 \"\u0625\u0646 \u0635\u062d \u0627\u0644\u062a\u0639\u0628\u064a\u0631\"\";\n\nconst userPrompt = `\u0627\u0643\u062a\u0628 \u0645\u0642\u0627\u0644\u0627\u064b \u062a\u062d\u0644\u064a\u0644\u064a\u0627\u064b \u0628\u0627\u0644\u0639\u0631\u0628\u064a\u0629 \u0627\u0644\u0641\u0635\u062d\u0649 \u0628\u0637\u0648\u0644 ${wordRange} \u0643\u0644\u0645\u0629.\n\n\u0627\u0644\u0645\u0648\u0636\u0648\u0639: ${article.title_ar}\n\u0627\u0644\u0632\u0627\u0648\u064a\u0629: ${article.recommended_angle || article.title_ar}\n\u0645\u0627 \u0641\u0627\u062a\u062a \u0648\u0633\u0627\u0626\u0644 \u0627\u0644\u0625\u0639\u0644\u0627\u0645 \u0627\u0644\u0623\u062e\u0631\u0649: ${article.what_media_missed || ''}\n\u0627\u0644\u0645\u0648\u0627\u0632\u064a \u0627\u0644\u062a\u0627\u0631\u064a\u062e\u064a: ${article.historical_parallel || ''}\n\u0627\u0644\u0625\u0634\u0627\u0631\u0629 \u0627\u0644\u062a\u0646\u0628\u0624\u064a\u0629: ${article.predictive_signal || ''}\n\u0627\u0644\u0623\u0637\u0631\u0627\u0641 \u0627\u0644\u0645\u0639\u0646\u064a\u0629: ${JSON.stringify(article.actors || [])}\n${actorContextStr}\n\n\u0627\u0644\u0645\u0635\u0627\u062f\u0631 \u0627\u0644\u0645\u062a\u0627\u062d\u0629:\n\u0627\u0644\u0639\u0646\u0648\u0627\u0646: ${article.title_ar}\n\u0627\u0644\u0648\u0635\u0641: ${article.description_ar}\n\n\u0645\u062a\u0637\u0644\u0628\u0627\u062a \u0627\u0644\u0628\u0646\u064a\u0629:\n1. \u0627\u0641\u062a\u062d \u0628\u0645\u0634\u0647\u062f \u0623\u0648 \u0633\u0624\u0627\u0644 \u0644\u0627 \u0628\u062e\u0628\u0631\n2. \u0627\u0644\u062e\u0628\u0631 \u0641\u064a \u0627\u0644\u0641\u0642\u0631\u0629 \u0627\u0644\u062b\u0627\u0646\u064a\u0629 \u0623\u0648 \u0627\u0644\u062b\u0627\u0644\u062b\u0629\n3. \u0637\u0628\u0642\u0627\u062a \u0627\u0644\u062f\u0644\u064a\u0644: \u0634\u0647\u0627\u062f\u0629 + \u0645\u0642\u0627\u0631\u0646\u0629 \u062a\u0627\u0631\u064a\u062e\u064a\u0629\n4. \u0627\u0644\u0637\u0631\u0641 \u0627\u0644\u063a\u0627\u0626\u0628 \u0639\u0646 \u0627\u0644\u062a\u063a\u0637\u064a\u0629: \u0627\u0630\u0643\u0631\u0647\n5. \u0627\u0644\u0642\u0646\u0628\u0644\u0629 \u0641\u064a \u0627\u0644\u0646\u0647\u0627\u064a\u0629\n6. \u0627\u062e\u062a\u0645 \u0628\u0633\u0624\u0627\u0644 \u0645\u0641\u062a\u0648\u062d \u0644\u0627 \u0628\u062d\u0643\u0645 \u0623\u062e\u0644\u0627\u0642\u064a`;\n\nreturn [{ json: { article, systemPrompt, userPrompt, contentType, wordRange } }];"
},
"name": "Code: Build Writer Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
480,
300
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.anthropic.com/v1/messages",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "x-api-key",
"value": "={{ $env.ANTHROPIC_API_KEY }}"
},
{
"name": "anthropic-version",
"value": "2023-06-01"
},
{
"name": "content-type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "raw",
"rawContentType": "application/json",
"body": "={\n \"model\": \"claude-sonnet-4-6\",\n \"max_tokens\": 4000,\n \"system\": {{ JSON.stringify($json.systemPrompt) }},\n \"messages\": [{\n \"role\": \"user\",\n \"content\": {{ JSON.stringify($json.userPrompt) }}\n }]\n}"
},
"name": "Claude Sonnet: Write Article",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
720,
300
]
},
{
"parameters": {
"jsCode": "const promptData = $('Code: Build Writer Prompt').first().json;\nconst claudeResponse = $input.first().json;\nconst articleText = claudeResponse.content?.[0]?.text || '';\n\nif (articleText.length < 200) {\n return [{ json: { error: true, reason: 'Article too short', original: promptData.article } }];\n}\n\n// Count words approximately\nconst wordCount = articleText.split(/\\s+/).length;\n\n// Generate article ID\nconst articleId = 'ART-' + Date.now().toString(36).toUpperCase();\n\nreturn [{\n json: {\n article_id: articleId,\n source_event: promptData.article,\n content_ar: articleText,\n word_count: wordCount,\n content_type: promptData.contentType,\n topic_tags: promptData.article.topic_tags || [],\n geographic_focus: promptData.article.geographic_focus || [],\n priority_score: promptData.article.priority_score,\n actors: promptData.article.actors || [],\n written_at: new Date().toISOString(),\n status: 'written_pending_qa'\n }\n}];"
},
"name": "Code: Package Article",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
960,
300
]
},
{
"parameters": {
"method": "POST",
"url": "={{ $env.N8N_WEBHOOK_AG05 }}",
"sendBody": true,
"contentType": "json",
"body": "={{ $json }}"
},
"name": "Trigger: Send to AG-05 Editor",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
1200,
300
],
"continueOnFail": true
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={\"status\": \"written\", \"article_id\": \"{{ $json.article_id }}\", \"words\": {{ $json.word_count }}}"
},
"name": "Response: Article Written",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1.1,
"position": [
1440,
300
]
}
],
"connections": {
"Webhook: Receive Assignment": {
"main": [
[
{
"node": "Supabase: Get Actor Context",
"type": "main",
"index": 0
}
]
]
},
"Supabase: Get Actor Context": {
"main": [
[
{
"node": "Code: Build Writer Prompt",
"type": "main",
"index": 0
}
]
]
},
"Code: Build Writer Prompt": {
"main": [
[
{
"node": "Claude Sonnet: Write Article",
"type": "main",
"index": 0
}
]
]
},
"Claude Sonnet: Write Article": {
"main": [
[
{
"node": "Code: Package Article",
"type": "main",
"index": 0
}
]
]
},
"Code: Package Article": {
"main": [
[
{
"node": "Trigger: Send to AG-05 Editor",
"type": "main",
"index": 0
}
]
]
},
"Trigger: Send to AG-05 Editor": {
"main": [
[
{
"node": "Response: Article Written",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1",
"errorWorkflow": "RTK-AG15-TechOps"
},
"tags": [
"rethink",
"production",
"writer",
"ag04"
]
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
RTK-AG04 | The Writer - Journalist Agent. Uses httpRequest. Webhook trigger; 7 nodes.
Source: https://github.com/Khaledalnaser/rethink-media-intelligence/blob/ffc342cea03be02633fbf96bd9abfb58c53955af/workflows/AG-04-writer.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Jigsaw API key for image processing, I use this as a gatekeeper/second pair of eyes. LINK to their website https://jigsawstack.com/ SECOND A postgress DATABASE (I use Supabase) LlamaCloud for the pars
Onsite Photos to Jobs (SMS Agent). Uses dataTable, twilio, httpRequest, airtable. Webhook trigger; 62 nodes.
W1 - IN WhatsApp Adapter (Secure + Fast ACK). Uses postgres, redis, httpRequest. Webhook trigger; 50 nodes.
W1 - IN WhatsApp Adapter (Secure + Fast ACK). Uses postgres, redis, httpRequest. Webhook trigger; 48 nodes.