n8n-workflow / Multi-Photo_FB_SchedulePost.json
salmonrk's picture
Upload Multi-Photo_FB_SchedulePost.json
4d5993d verified
{
"name": "PageFB-FB-SchedulePost",
"nodes": [
{
"parameters": {
"fileSelector": "={{ $json.ImgPath + '/**.***'}}",
"options": {}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
200,
-380
],
"id": "e7cc6080-d4f3-4f3d-886a-2313aed9c697",
"name": "Image"
},
{
"parameters": {
"fileSelector": "={{ $json.ImgPath +'/Caption/hashtag.txt' }}",
"options": {
"fileExtension": ".txt",
"dataPropertyName": "hashtag"
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
220,
40
],
"id": "ed72dc72-bfbc-4993-bd65-944c9f086fe9",
"name": "Hastag"
},
{
"parameters": {
"command": "=powershell -Command \"$d=Get-Date -Format 'yyyyMMdd'; $p='{{ $('ImgPath').item.json.ImgPath+'/' }}' + $d; New-Item -ItemType Directory -Path $p -Force; Move-Item -Path '{{ $('ImgPath').item.json.ImgPath + '/' + $('Merge1').item.json.fileName }}' -Destination $p\"\n"
},
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
1380,
-360
],
"id": "f76bf628-d924-4155-89cf-4cfa9c91159e",
"name": "Move image to Posted date folder"
},
{
"parameters": {
"fileSelector": "={{ $json.ImgPath + '/Caption/description.txt' }}",
"options": {
"fileExtension": ".txt",
"dataPropertyName": "description"
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
220,
-160
],
"id": "c5193895-9d89-4c28-9635-a505de559e4d",
"name": "Description1"
},
{
"parameters": {
"operation": "text",
"binaryPropertyName": "description",
"destinationKey": "description_random",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
420,
-160
],
"id": "9e796c5b-5e83-4dc0-8cfc-e4682fcc2c1a",
"name": "Extract from File"
},
{
"parameters": {
"jsCode": "const lines = $input.first().json.description_random.split(/\\r?\\n/).filter(Boolean);\n\nconst random = lines[Math.floor(Math.random() * lines.length)];\nreturn [{ json: { description: random } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
580,
-160
],
"id": "b827ecc0-955c-4757-b5a7-ac794169724a",
"name": "Code"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
740,
20
],
"id": "15757ed4-bc84-4a62-ac2c-1b09587f14f6",
"name": "Merge"
},
{
"parameters": {
"operation": "text",
"binaryPropertyName": "hashtag",
"destinationKey": "hashtag_random",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
420,
40
],
"id": "0a5fecce-b975-46a1-8631-2009cc2ab145",
"name": "Extract from File1"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
920,
-360
],
"id": "d5f86f4f-7d21-4539-a9df-ed9f4fb16ebd",
"name": "Merge1"
},
{
"parameters": {
"httpRequestMethod": "POST",
"graphApiVersion": "v22.0",
"node": "me",
"edge": "photos",
"sendBinaryData": true,
"binaryPropertyName": "data",
"options": {
"queryParameters": {
"parameter": [
{
"name": "message",
"value": "={{ $json.description + \"\\n\\n\" + $json.hashtag_random }}"
},
{
"name": "published",
"value": "true"
}
]
}
}
},
"type": "n8n-nodes-base.facebookGraphApi",
"typeVersion": 1,
"position": [
1060,
-360
],
"id": "adceb034-ed53-42bb-b107-768692e7da42",
"name": "Facebook Graph API - Photo",
"credentials": {
"facebookGraphApi": {
"id": "lD5bQ4cH7qrQ2UQ3",
"name": "Facebook Graph - PageFB"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "8110d0be-82b5-4637-bb67-229481c91723",
"name": "ImgPath",
"value": "E:/Autopost-media/PageFB/202506-Images",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-100,
-160
],
"id": "ed8d5c71-d74f-43fb-afb9-8ec1d01d220d",
"name": "ImgPath"
},
{
"parameters": {
"amount": 10
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
1220,
-360
],
"id": "f73ebe72-e6b2-4d4e-9d91-d68743fa8be9",
"name": "Wait1",
"webhookId": "8e506978-bb6d-4c9e-963c-b4fa4e02d78f"
},
{
"parameters": {
"rule": {
"interval": [
{
"field": "hours",
"hoursInterval": 2,
"triggerAtMinute": 10
}
]
}
},
"type": "n8n-nodes-base.scheduleTrigger",
"typeVersion": 1.2,
"position": [
-380,
560
],
"id": "57e4ee5f-d13c-4ff4-8344-8c1a07eb647f",
"name": "Schedule Trigger"
},
{
"parameters": {
"content": "# A Image Facebook post",
"height": 820,
"width": 1760
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
-140,
-540
],
"id": "c6a49ce4-bdec-4470-9180-675b7f8b7d72",
"name": "Sticky Note"
},
{
"parameters": {
"content": "# Multi-Photo FB Post\n- Cloudunary\n- Limit 3 Images/post",
"height": 1320,
"width": 2080
},
"type": "n8n-nodes-base.stickyNote",
"typeVersion": 1,
"position": [
600,
2740
],
"id": "f4e996ac-04fc-443c-a646-b54a58600b01",
"name": "Sticky Note1"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "208ef60a-4235-4615-aa4d-ae83905df4d5",
"leftValue": "={{ $json.id }}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
1040,
1120
],
"id": "add4e120-f093-414e-b7fe-b20f4d4ddeb9",
"name": "If"
},
{
"parameters": {
"options": {
"reset": false
}
},
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
1500,
1300
],
"id": "890895a5-8c0d-4adc-bc54-53fd7338afaa",
"name": "Loop Over Items"
},
{
"parameters": {
"graphApiVersion": "v22.0",
"node": "={{ $('ImgPath2').item.json.PageFBFB }}",
"edge": "=feed",
"options": {}
},
"type": "n8n-nodes-base.facebookGraphApi",
"typeVersion": 1,
"position": [
1800,
900
],
"id": "666ec878-cde2-4a5c-b2bc-7c5daa7644d7",
"name": "GET",
"credentials": {
"facebookGraphApi": {
"id": "lD5bQ4cH7qrQ2UQ3",
"name": "Facebook Graph - PageFB"
}
}
},
{
"parameters": {
"maxItems": 3
},
"type": "n8n-nodes-base.limit",
"typeVersion": 1,
"position": [
400,
780
],
"id": "61e8be98-f9c2-4c2a-870b-49142ed05430",
"name": "Limit1"
},
{
"parameters": {
"fieldsToAggregate": {
"fieldToAggregate": [
{
"fieldToAggregate": "id"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
1000,
780
],
"id": "e6cf8b49-bffb-454f-9d19-29047d76e536",
"name": "Aggregate1"
},
{
"parameters": {
"method": "POST",
"url": "https://api.cloudinary.com/v1_1/dxepor8fh/image/upload",
"sendBody": true,
"contentType": "multipart-form-data",
"bodyParameters": {
"parameters": [
{
"name": "upload_preset",
"value": "srk_uploads"
},
{
"parameterType": "formBinaryData",
"name": "file",
"inputDataFieldName": "data"
}
]
},
"options": {
"redirect": {
"redirect": {}
}
}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
640,
780
],
"id": "22ebf0c7-9e5e-46c5-960c-c7908253112d",
"name": "upload to file server1"
},
{
"parameters": {
"method": "POST",
"url": "https://graph.facebook.com/v23.0/me/photos",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "facebookGraphApi",
"sendBody": true,
"contentType": "multipart-form-data",
"bodyParameters": {
"parameters": [
{
"name": "url",
"value": "={{ $json.url }}"
},
{
"name": "published",
"value": "false"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
820,
780
],
"id": "a57785d3-790e-4b4b-898a-e2b3c0247fef",
"name": "HTTP Request",
"credentials": {
"facebookGraphApi": {
"id": "lD5bQ4cH7qrQ2UQ3",
"name": "Facebook Graph - PageFB"
}
}
},
{
"parameters": {
"httpRequestMethod": "POST",
"graphApiVersion": "v22.0",
"node": "={{ $('ImgPath2').item.json.PageFBFB }}",
"edge": "feed",
"options": {
"queryParameters": {
"parameter": [
{
"name": "message",
"value": "={{ $json.description + \"\\n\\n\" + $json.hashtag_random }}"
},
{
"name": "attached_media",
"value": "={{ JSON.stringify($json.id.map(media_id => ({ media_fbid: media_id }))) }}"
}
]
}
}
},
"type": "n8n-nodes-base.facebookGraphApi",
"typeVersion": 1,
"position": [
1440,
900
],
"id": "5d872967-7dfa-4313-9807-38b6999b3d6b",
"name": "Multi-Photo1",
"credentials": {
"facebookGraphApi": {
"id": "lD5bQ4cH7qrQ2UQ3",
"name": "Facebook Graph - PageFB"
}
}
},
{
"parameters": {
"fileSelector": "={{ $json.ImgPath + '**.***'}}",
"options": {}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
220,
780
],
"id": "df0a3b80-a464-4471-a343-9ffd0273e5ca",
"name": "Image3"
},
{
"parameters": {
"fileSelector": "={{ $json.ImgPath +'Caption\\\\\\\\hashtag.txt' }}",
"options": {
"fileExtension": ".txt",
"dataPropertyName": "hashtag"
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
200,
580
],
"id": "cb2e5bca-3ca8-40a2-ad4a-5971c66ac625",
"name": "Hastag2"
},
{
"parameters": {
"fileSelector": "={{ $json.ImgPath + 'Caption/description.txt' }}",
"options": {
"fileExtension": ".txt",
"dataPropertyName": "description"
}
},
"type": "n8n-nodes-base.readWriteFile",
"typeVersion": 1,
"position": [
200,
380
],
"id": "d0566983-4ba0-49ff-ae24-86bfad645a28",
"name": "Description2"
},
{
"parameters": {
"operation": "text",
"binaryPropertyName": "description",
"destinationKey": "description_random",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
380,
380
],
"id": "3a59aa9d-8402-453f-bd48-26f1da438cdd",
"name": "Extract from File4"
},
{
"parameters": {
"jsCode": "const lines = $input.first().json.description_random.split(/\\r?\\n/).filter(Boolean);\n\nconst random = lines[Math.floor(Math.random() * lines.length)];\nreturn [{ json: { description: random } }];"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
560,
380
],
"id": "fefa57a6-02cc-4671-a949-20b59d28f1f5",
"name": "Code2"
},
{
"parameters": {
"operation": "text",
"binaryPropertyName": "hashtag",
"destinationKey": "hashtag_random",
"options": {}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
380,
580
],
"id": "c9043785-d899-4244-9cee-a3a8961d0251",
"name": "Extract from File5"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "8110d0be-82b5-4637-bb67-229481c91723",
"name": "ImgPath",
"value": "E:\\\\Autopost-media\\\\PageFB\\\\202506-Images\\\\",
"type": "string"
},
{
"id": "1f40e74e-0baf-4905-88d4-296e34fab8b9",
"name": "PageFBFB",
"value": "694076880451435",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
-40,
560
],
"id": "6d46541e-0582-4030-9895-0d62b89c6039",
"name": "ImgPath2"
},
{
"parameters": {
"command": "=powershell -Command \"$d = Get-Date -Format 'yyyyMMdd'; $p = '{{ $('ImgPath2').item.json.ImgPath }}' + $d; New-Item -ItemType Directory -Path $p -Force; $files = @('{{ $json.mediafile }}'); foreach ($file in $files) { if (Test-Path $file) { Move-Item -Path $file -Destination $p -Force; Write-Host \\\"Moved: $file\\\" } else { Write-Host \\\"File not found: $file\\\" } }\""
},
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
1680,
1380
],
"id": "6c51d87e-6bda-4320-b0b8-81a522681cd0",
"name": "Move image to Posted date folder2"
},
{
"parameters": {
"amount": 10
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
1600,
900
],
"id": "1441ba89-00ba-4886-8232-a05ba330bd1a",
"name": "Wait2",
"webhookId": "8e506978-bb6d-4c9e-963c-b4fa4e02d78f"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
700,
560
],
"id": "1f1bb923-1098-460d-9744-9edcdd7016b1",
"name": "Caption"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineByPosition",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.1,
"position": [
1200,
900
],
"id": "931c035c-2397-4419-ab43-1decc8a743d2",
"name": "PreparePost"
},
{
"parameters": {},
"type": "n8n-nodes-base.merge",
"typeVersion": 3.2,
"position": [
1140,
1300
],
"id": "9618f9ae-447c-425d-922f-11d4c5cf1848",
"name": "MoveFile"
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "16b57477-fa2b-49b3-b987-69b3f7c0b028",
"name": "mediafile",
"value": "={{ $('ImgPath2').item.json.ImgPath + $json.fileName}}",
"type": "string"
}
]
},
"options": {}
},
"type": "n8n-nodes-base.set",
"typeVersion": 3.4,
"position": [
1300,
1300
],
"id": "1e356986-65cb-4845-816d-f7aafe2513ed",
"name": "ImagePath"
}
],
"pinData": {},
"connections": {
"Image": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 0
}
]
]
},
"Hastag": {
"main": [
[
{
"node": "Extract from File1",
"type": "main",
"index": 0
}
]
]
},
"Description1": {
"main": [
[
{
"node": "Extract from File",
"type": "main",
"index": 0
}
]
]
},
"Extract from File": {
"main": [
[
{
"node": "Code",
"type": "main",
"index": 0
}
]
]
},
"Code": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Merge": {
"main": [
[
{
"node": "Merge1",
"type": "main",
"index": 1
}
]
]
},
"Extract from File1": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Merge1": {
"main": [
[
{
"node": "Facebook Graph API - Photo",
"type": "main",
"index": 0
}
]
]
},
"Facebook Graph API - Photo": {
"main": [
[
{
"node": "Wait1",
"type": "main",
"index": 0
}
]
]
},
"ImgPath": {
"main": [
[
{
"node": "Image",
"type": "main",
"index": 0
},
{
"node": "Description1",
"type": "main",
"index": 0
},
{
"node": "Hastag",
"type": "main",
"index": 0
}
]
]
},
"Wait1": {
"main": [
[
{
"node": "Move image to Posted date folder",
"type": "main",
"index": 0
}
]
]
},
"Schedule Trigger": {
"main": [
[
{
"node": "ImgPath2",
"type": "main",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "MoveFile",
"type": "main",
"index": 0
}
]
]
},
"Loop Over Items": {
"main": [
[],
[
{
"node": "Move image to Posted date folder2",
"type": "main",
"index": 0
}
]
]
},
"Limit1": {
"main": [
[
{
"node": "upload to file server1",
"type": "main",
"index": 0
},
{
"node": "MoveFile",
"type": "main",
"index": 1
}
]
]
},
"Aggregate1": {
"main": [
[
{
"node": "PreparePost",
"type": "main",
"index": 0
}
]
]
},
"upload to file server1": {
"main": [
[
{
"node": "HTTP Request",
"type": "main",
"index": 0
}
]
]
},
"HTTP Request": {
"main": [
[
{
"node": "Aggregate1",
"type": "main",
"index": 0
}
]
]
},
"Multi-Photo1": {
"main": [
[
{
"node": "Wait2",
"type": "main",
"index": 0
}
]
]
},
"Image3": {
"main": [
[
{
"node": "Limit1",
"type": "main",
"index": 0
}
]
]
},
"Hastag2": {
"main": [
[
{
"node": "Extract from File5",
"type": "main",
"index": 0
}
]
]
},
"Description2": {
"main": [
[
{
"node": "Extract from File4",
"type": "main",
"index": 0
}
]
]
},
"Extract from File4": {
"main": [
[
{
"node": "Code2",
"type": "main",
"index": 0
}
]
]
},
"Code2": {
"main": [
[
{
"node": "Caption",
"type": "main",
"index": 0
}
]
]
},
"Extract from File5": {
"main": [
[
{
"node": "Caption",
"type": "main",
"index": 1
}
]
]
},
"ImgPath2": {
"main": [
[
{
"node": "Image3",
"type": "main",
"index": 0
},
{
"node": "Description2",
"type": "main",
"index": 0
},
{
"node": "Hastag2",
"type": "main",
"index": 0
}
]
]
},
"Move image to Posted date folder2": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
},
"Wait2": {
"main": [
[
{
"node": "GET",
"type": "main",
"index": 0
},
{
"node": "If",
"type": "main",
"index": 0
}
]
]
},
"Caption": {
"main": [
[
{
"node": "PreparePost",
"type": "main",
"index": 1
}
]
]
},
"PreparePost": {
"main": [
[
{
"node": "Multi-Photo1",
"type": "main",
"index": 0
}
]
]
},
"MoveFile": {
"main": [
[
{
"node": "ImagePath",
"type": "main",
"index": 0
}
]
]
},
"ImagePath": {
"main": [
[
{
"node": "Loop Over Items",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1",
"timezone": "Asia/Bangkok",
"callerPolicy": "workflowsFromSameOwner"
},
"versionId": "5b853a0e-5de3-4727-b591-be7d0be7309a",
"meta": {
"templateCredsSetupCompleted": true,
"instanceId": "52186cf1b8efe42bc5d27bbce9c2dedc42f74757c6fd390a78301306ccc29052"
},
"id": "chcfJgqm2NoGDQCU",
"tags": [
{
"createdAt": "2025-06-03T16:42:32.022Z",
"updatedAt": "2025-06-03T16:42:32.022Z",
"id": "6E0gIDsPI6Rume0O",
"name": "Social media"
},
{
"createdAt": "2025-06-03T16:45:27.162Z",
"updatedAt": "2025-06-03T16:45:27.162Z",
"id": "q7URTQC723lARcBj",
"name": "Facebook"
}
]
}