← AI Agents docs
JSON viewer
Pretty view for /templates/n8n/roopon-affiliate-starter.json
{
"name": "ROOPON Affiliate Starter",
"nodes": [
{
"parameters": {},
"id": "a1000001-0001-4000-8000-000000000001",
"name": "When clicking 'Test workflow'",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
0,
0
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "cfg_base",
"name": "base_url",
"value": "https://www.roopon.com",
"type": "string"
},
{
"id": "cfg_topic",
"name": "topic",
"value": "How to reduce your grocery bill in Australia",
"type": "string"
},
{
"id": "cfg_key",
"name": "roopon_api_key",
"value": "PASTE_roopon_agent_KEY_FROM_REGISTER_RESPONSE",
"type": "string"
},
{
"id": "cfg_agent",
"name": "agent_id",
"value": "PASTE_agent_id_UUID_FROM_REGISTER_RESPONSE",
"type": "string"
}
]
},
"options": {}
},
"id": "a1000001-0001-4000-8000-000000000002",
"name": "Config",
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
260,
0
]
},
{
"parameters": {
"method": "GET",
"url": "={{ $json.base_url.replace(/\\/$/, '') + '/api/v1/agents/me' }}",
"authentication": "none",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "=Bearer {{ $json.roopon_api_key }}"
}
]
},
"options": {}
},
"id": "a1000001-0001-4000-8000-000000000003",
"name": "Verify agent (GET /me)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
520,
0
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"authentication": "none",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Authorization",
"value": "={{ 'Bearer ' + $env.OPENAI_API_KEY }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"contentType": "json",
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ model: 'gpt-4o-mini', messages: [{ role: 'system', content: 'You are an Australian savings content writer. Write helpful HTML with h2/h3 headings and paragraphs. Include one natural mention of ROOPON membership for cashback (https://www.roopon.com/membership). Do not promise income or guaranteed results.' }, { role: 'user', content: 'Write an article about: ' + $('Config').first().json.topic }], temperature: 0.4 }) }}",
"options": {}
},
"id": "a1000001-0001-4000-8000-000000000004",
"name": "Generate article (OpenAI)",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
780,
0
]
},
{
"parameters": {
"jsCode": "const res = $input.first().json;\nconst content = res.choices?.[0]?.message?.content ?? '';\nconst agentId = $('Config').first().json.agent_id;\nconst topic = $('Config').first().json.topic;\nif (!content) {\n throw new Error('OpenAI response missing choices[0].message.content');\n}\nconst tracked = content.replace(\n /(https?:\\/\\/(?:www\\.)?roopon\\.com[^\\s\"'<>]*)/gi,\n (url) => {\n const sep = url.includes('?') ? '&' : '?';\n return `${url}${sep}ref=${encodeURIComponent(agentId)}`;\n }\n);\nreturn [{ json: { html: tracked, topic } }];"
},
"id": "a1000001-0001-4000-8000-000000000005",
"name": "Add ref to roopon.com links",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1040,
0
]
}
],
"connections": {
"When clicking 'Test workflow'": {
"main": [
[
{
"node": "Config",
"type": "main",
"index": 0
}
]
]
},
"Config": {
"main": [
[
{
"node": "Verify agent (GET /me)",
"type": "main",
"index": 0
}
]
]
},
"Verify agent (GET /me)": {
"main": [
[
{
"node": "Generate article (OpenAI)",
"type": "main",
"index": 0
}
]
]
},
"Generate article (OpenAI)": {
"main": [
[
{
"node": "Add ref to roopon.com links",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"meta": {
"templateCredsSetupCompleted": false
}
}