{
 "id": "aireviewreplies",
 "name": "AutomateRecipes \u2013 ai-review-replies",
 "nodes": [
  {
   "parameters": {},
   "name": "Manual Trigger",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ],
   "id": "c4c4ab53-d2da-43bb-aa4c-d9de989cf778"
  },
  {
   "parameters": {
    "url": "http://127.0.0.1:9000/gbp/reviews",
    "options": {}
   },
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "name": "S1 GET mock/gbp/reviews",
   "position": [
    220,
    0
   ],
   "id": "20313a7a-738a-45f0-9aa0-c2f41e25bfbd"
  },
  {
   "parameters": {
    "jsCode": "return $input.first().json.reviews.map(r=>({json:r}));"
   },
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "name": "S2",
   "position": [
    440,
    0
   ],
   "id": "0253fd18-bf28-4d9f-ab6f-bfd60b675cd8"
  },
  {
   "parameters": {
    "jsCode": "return $input.all().map(i=>({json:{...i.json,service:'openai/v1/chat/completions',payload:{model:'gpt-4o-mini',messages:[{role:'user',content:'Write a polite reply to a '+i.json.starRating+' star review: '+i.json.comment}]}}}));"
   },
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "name": "AIPREP",
   "position": [
    660,
    0
   ],
   "id": "a9d0c5b8-7461-4cae-846e-a2d48eb9d0f4"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "=http://127.0.0.1:9000/{{ $json.service }}",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify($json.payload) }}",
    "options": {}
   },
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "name": "S4 POST mock (AI)",
   "position": [
    880,
    0
   ],
   "id": "d5c421e9-690d-449c-9f2a-d87e2fbfde3a"
  },
  {
   "parameters": {
    "jsCode": "const src=$('AIPREP').all();return $input.all().map((r,i)=>({json:{...src[i].json,ai:r.json.choices[0].message.content}}));"
   },
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "name": "S5",
   "position": [
    1100,
    0
   ],
   "id": "7b72e7ad-39f7-4840-bdb7-c4c8ecf2c63c"
  },
  {
   "parameters": {
    "jsCode": "return $input.all().map(i=>({json:{service:'slack/chat.postMessage',payload:{channel:'#reviews',text:`Draft reply to ${i.json.reviewer} (${i.json.starRating}): ${i.json.ai}`}}}));"
   },
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "name": "S6",
   "position": [
    1320,
    0
   ],
   "id": "67211a1d-13d7-4eaa-9523-3a719a5e82ba"
  },
  {
   "parameters": {
    "method": "POST",
    "url": "=http://127.0.0.1:9000/{{ $json.service }}",
    "sendBody": true,
    "specifyBody": "json",
    "jsonBody": "={{ JSON.stringify($json.payload) }}",
    "options": {}
   },
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "name": "S7 POST mock (send)",
   "position": [
    1540,
    0
   ],
   "id": "ae222a4d-4374-49b9-bf4f-0463d4cf8d34"
  }
 ],
 "connections": {
  "Manual Trigger": {
   "main": [
    [
     {
      "node": "S1 GET mock/gbp/reviews",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "S1 GET mock/gbp/reviews": {
   "main": [
    [
     {
      "node": "S2",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "S2": {
   "main": [
    [
     {
      "node": "AIPREP",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "AIPREP": {
   "main": [
    [
     {
      "node": "S4 POST mock (AI)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "S4 POST mock (AI)": {
   "main": [
    [
     {
      "node": "S5",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "S5": {
   "main": [
    [
     {
      "node": "S6",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "S6": {
   "main": [
    [
     {
      "node": "S7 POST mock (send)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {},
 "active": false,
 "pinData": {},
 "meta": {
  "note": "Tested on n8n 1.70.3 with local mocks for: Google Business Profile API, OpenAI, Slack approval. Replace 'POST mock'/'GET mock' HTTP nodes with the real app nodes + credentials before production."
 }
}