{
  "name": "Google Sheets content calendar to sprkly",
  "nodes": [
    {
      "id": "8bc35655-1922-4f21-8f74-e284d8d7ffea",
      "name": "Read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -1640,
        -630
      ],
      "parameters": {
        "content": "## Google Sheets content calendar to sprkly\nApproved rows in your sheet become scheduled posts, and each row gets its status and link back. Refused rows reach you on Telegram, and each morning you get the day in one message.\n\n### You need\n- The sprkly node: Settings, Community nodes, install `n8n-nodes-sprkly` (self-hosted n8n)\n- A sprkly API key: https://sprkly.app/docs/api?utm_source=n8n&utm_medium=workflow&utm_campaign=google-sheets-to-sprkly\n- A Google Sheets login\n- A sheet with: Row ID, Status, Caption, Schedule Time, Accounts, Media URL, sprkly Post ID, Scheduled For, Link, Error\n- A Telegram bot and your chat ID\n\n### Set it up\n1. Add your sprkly key to each sprkly step.\n2. Pick your sheet in every Google Sheets step. Put its ID in **Published log settings** too.\n3. Give every row its own Row ID. Write Accounts like instagram:yourhandle, facebook:Your Page.\n4. Add your bot to the Telegram steps and your chat ID in **Settings**. Set your time zone in Workflow settings. Times in the sheet use it.\n5. Failure alert: put your chat ID in **Write the failure alert** and your bot in **Send the failure alert**. Then in Workflow settings, set Error workflow to this workflow.\n\n### Test it\n- Add one row a day away with Status Approved, and one with no caption. Run the workflow once.\n- The first row gets a sprkly Post ID. You get a message about the second. Delete the test post in sprkly after.",
        "height": 910,
        "width": 560,
        "color": 4
      }
    },
    {
      "id": "4b65bbe4-ec51-401d-9e26-a4ea89666cf0",
      "name": "Note: schedule rows",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        80
      ],
      "parameters": {
        "content": "## Schedule approved rows\nThe sprkly node checks each row and gives back one result row. An empty Schedule Time is refused, so nothing posts by accident. The result goes back to the same row. Rows sprkly refuses reach you on Telegram. Each morning you get the day in one message.",
        "height": 420,
        "width": 1960,
        "color": 7
      }
    },
    {
      "id": "871dfeb1-048d-4286-8b46-7954b732b905",
      "name": "Note: track posts",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -440,
        620
      ],
      "parameters": {
        "content": "## Track what happened\nWhen a post goes out or fails, the row is found by its Row ID. Only posts with an External ID that starts with sheet- reach this sheet. A post with no Row ID is skipped.",
        "height": 440,
        "width": 760,
        "color": 7
      }
    },
    {
      "id": "05ab5363-c4fd-497d-8048-6134f1a4d12d",
      "name": "Every 15 minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        -400,
        320
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      }
    },
    {
      "id": "a3fed0b4-00fb-4b03-b7c8-130f45788131",
      "name": "Get approved rows",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        320,
        320
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "Status",
              "lookupValue": "Approved"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "73d39e6b-1d96-4719-95bc-6c96d4cc097c",
      "name": "Schedule post in sprkly",
      "type": "n8n-nodes-sprkly.sprkly",
      "typeVersion": 1.1,
      "position": [
        560,
        320
      ],
      "parameters": {
        "resource": "post",
        "operation": "create",
        "accountMode": "name",
        "accountNames": "={{ $json.Accounts }}",
        "caption": "={{ $json.Caption }}",
        "scheduledTime": "={{ $json['Schedule Time'] }}",
        "output": "resultRow",
        "additionalFields": {
          "externalId": "={{ $json['Row ID'] ? 'sheet-' + String($json['Row ID']).trim() : '' }}",
          "mediaUrls": "={{ $json['Media URL'] }}",
          "requireExternalId": true
        }
      }
    },
    {
      "id": "88d29d63-319c-4960-b764-68138948b967",
      "name": "Write result to row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        800,
        320
      ],
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "row_number": "={{ $json.row_number }}",
            "Status": "={{ $json.status }}",
            "sprkly Post ID": "={{ $json.postId }}",
            "Scheduled For": "={{ $json.scheduledFor }}",
            "Link": "={{ $json.link }}",
            "Error": "={{ $json.error }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "number",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            },
            {
              "id": "Row ID",
              "displayName": "Row ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Caption",
              "displayName": "Caption",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Schedule Time",
              "displayName": "Schedule Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Accounts",
              "displayName": "Accounts",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Media URL",
              "displayName": "Media URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "sprkly Post ID",
              "displayName": "sprkly Post ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Scheduled For",
              "displayName": "Scheduled For",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Error",
              "displayName": "Error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "3ea6a65b-6680-4ac9-9389-e52a2de4cabb",
      "name": "When a post goes out",
      "type": "n8n-nodes-sprkly.sprklyTrigger",
      "typeVersion": 1,
      "position": [
        -400,
        780
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 5,
              "unit": "minutes"
            }
          ]
        },
        "event": "postPublished",
        "externalIdPrefix": "sheet-",
        "stripPrefix": true
      }
    },
    {
      "id": "41cc5d98-bba6-44ac-b9c8-2eb76a1f08b6",
      "name": "When a post fails",
      "type": "n8n-nodes-sprkly.sprklyTrigger",
      "typeVersion": 1,
      "position": [
        -400,
        960
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyX",
              "value": 5,
              "unit": "minutes"
            }
          ]
        },
        "event": "postFailed",
        "externalIdPrefix": "sheet-",
        "stripPrefix": true
      }
    },
    {
      "id": "9fc67ff5-4c81-47eb-bbe0-e350aa503aac",
      "name": "Write post status to row",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        -120,
        860
      ],
      "parameters": {
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Row ID": "={{ $json.sourceId }}",
            "Status": "={{ $json.statusLabel }}",
            "Link": "={{ $json.link }}",
            "Error": "={{ $json.error }}"
          },
          "matchingColumns": [
            "Row ID"
          ],
          "schema": [
            {
              "id": "Row ID",
              "displayName": "Row ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Status",
              "displayName": "Status",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Caption",
              "displayName": "Caption",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Schedule Time",
              "displayName": "Schedule Time",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Accounts",
              "displayName": "Accounts",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Media URL",
              "displayName": "Media URL",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "sprkly Post ID",
              "displayName": "sprkly Post ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Scheduled For",
              "displayName": "Scheduled For",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "Link",
              "displayName": "Link",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Error",
              "displayName": "Error",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ]
        },
        "options": {}
      }
    },
    {
      "name": "Note: automatic published post log",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "id": "93d01b7a-3d38-5339-b247-48e416d01ea0",
      "position": [
        -1000,
        -630
      ],
      "parameters": {
        "content": "## Log posts as they go live\n\nSet **Spreadsheet ID** in **Published log settings**. Use the same Google Sheets credential in the two log steps and your sprkly API credential on **When this workflow's post goes live**.\n\nThe workflow checks each minute for its published posts. It creates **Published Posts** and its headers as needed, then writes one row per Post ID. This branch runs after publication. It leaves the scheduling and source status branches intact.",
        "height": 215,
        "width": 520,
        "color": 5
      }
    },
    {
      "name": "When this workflow's post goes live",
      "type": "n8n-nodes-sprkly.sprklyTrigger",
      "typeVersion": 1,
      "id": "c35ee175-6b0b-59d0-8c40-eb9ed4d61931",
      "position": [
        -1000,
        -380
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "event": "postPublished",
        "externalIdPrefix": "sheet-",
        "stripPrefix": false
      }
    },
    {
      "name": "Build published log rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "id": "e56abc10-2469-575c-9a23-84b7a2106a6f",
      "position": [
        -760,
        -380
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const prefix = \"sheet-\";\nconst text = value => typeof value === 'string' || typeof value === 'number' ? String(value).trim() : '';\nconst values = input => Array.isArray(input) ? input.map(text).filter(Boolean) : [];\nconst rows = new Map();\n\nfor (const [index, item] of $input.all().entries()) {\n  const post = item.json;\n  const id = text(post.id);\n  const externalId = text(post.externalId);\n  if (!id || post.deleted || !['posted', 'published'].includes(post.status) ||\n      !externalId.startsWith(prefix) || externalId.length === prefix.length) continue;\n\n  const platforms = values(post.platforms);\n  const accounts = values(post.profileIds);\n  const suffix = ':' + platforms[0] + ':' + accounts[0];\n  const source = platforms.length && accounts.length && externalId.endsWith(suffix)\n    ? externalId.slice(0, -suffix.length) : externalId;\n  if (source.length <= prefix.length) continue;\n  const previous = rows.get(id)?.json;\n  rows.set(id, {\n    json: {\n      'Post ID': id,\n      Status: 'Published',\n      'Published At': text(post.publishedAt) || previous?.['Published At'] || '',\n      Platform: platforms.join(', '),\n      'Account ID': accounts.join(', '),\n      'Source ID': source,\n      'External ID': externalId,\n      'Live URL': text(post.permalink) || text(post.link) || previous?.['Live URL'] || '',\n      'Sprkly URL': 'https://sprkly.app/schedule?utm_source=n8n&utm_medium=workflow&utm_campaign=google-sheets-to-sprkly&post=' + encodeURIComponent(id),\n    },\n    pairedItem: index,\n  });\n}\nreturn [...rows.values()];"
      }
    },
    {
      "name": "Published log settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "id": "4ca87626-165c-5df6-a718-c03470d7516f",
      "position": [
        -520,
        -380
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "765cd59b-eece-5953-996a-c5680aebd93f",
              "name": "Spreadsheet ID",
              "type": "string",
              "value": ""
            },
            {
              "id": "9937af42-26bc-55e7-88f2-585479c7e4a1",
              "name": "Tab name",
              "type": "string",
              "value": "Published Posts"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      },
      "executeOnce": true
    },
    {
      "name": "Ensure published log tab",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "id": "635b6257-e09d-5883-bb53-4662338bea57",
      "position": [
        -280,
        -380
      ],
      "parameters": {
        "resource": "sheet",
        "operation": "create",
        "documentId": {
          "__rl": true,
          "value": "={{ String($json[\"Spreadsheet ID\"]).trim() }}",
          "mode": "id"
        },
        "title": "={{ String($json[\"Tab name\"]).trim() }}",
        "options": {}
      },
      "alwaysOutputData": true,
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 3000
    },
    {
      "name": "Restore published log rows",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "id": "47c3ee36-688f-5e53-9adf-bed00c62b395",
      "position": [
        -40,
        -380
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "// Create Sheet has one output for the setup call. Restore every publication in the trigger batch.\nreturn $('Build published log rows').all().map(({ json }) => ({ json, pairedItem: 0 }));"
      }
    },
    {
      "name": "Upsert published post log",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "id": "f90df023-b939-5bf9-b6ef-ba87aca4fcc7",
      "position": [
        200,
        -380
      ],
      "parameters": {
        "resource": "sheet",
        "operation": "appendOrUpdate",
        "documentId": {
          "__rl": true,
          "value": "={{ String($(\"Published log settings\").first().json[\"Spreadsheet ID\"]).trim() }}",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "={{ String($(\"Published log settings\").first().json[\"Tab name\"]).trim() }}",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "matchingColumns": [
            "Post ID"
          ],
          "schema": []
        },
        "options": {
          "cellFormat": "RAW",
          "handlingExtraData": "insertInNewColumn",
          "useAppend": true
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 3000
    },
    {
      "id": "dbd6644e-e0d0-48a4-bc2b-6707be60a0fb",
      "name": "When this workflow fails",
      "type": "n8n-nodes-base.errorTrigger",
      "typeVersion": 1,
      "position": [
        -1600,
        360
      ],
      "parameters": {}
    },
    {
      "id": "e974fa6c-5533-4abe-9f1e-9960cb5a0d45",
      "name": "Write the failure alert",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1380,
        360
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_TELEGRAM_CHAT_ID"
            },
            {
              "id": "f2",
              "name": "message",
              "type": "string",
              "value": "={{ 'A workflow stopped.\\n\\nWorkflow: ' + (($json.workflow || {}).name || 'unknown') + '\\nFailed step: ' + (($json.execution || {}).lastNodeExecuted || 'unknown') + '\\nWhy: ' + String((($json.execution || {}).error || {}).message || 'n8n did not give a reason.').slice(0, 300) + (($json.execution || {}).url ? '\\nOpen the run: ' + $json.execution.url : '') }}"
            }
          ]
        },
        "includeOtherFields": false,
        "options": {}
      }
    },
    {
      "id": "700107b7-8ccb-4f28-82cf-9b0d8a094265",
      "name": "Send the failure alert",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        -1160,
        360
      ],
      "parameters": {
        "chatId": "={{ $json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "f82c17bb-c32c-4cb6-bc1e-b5b07d2654aa",
      "name": "Every morning",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.3,
      "position": [
        -400,
        140
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "triggerAtHour": 8
            }
          ]
        }
      }
    },
    {
      "id": "35eaa017-f213-4c75-a7e5-1e7886e84b44",
      "name": "Settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -160,
        320
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "f1",
              "name": "telegramChatId",
              "type": "string",
              "value": "YOUR_CHAT_ID"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      }
    },
    {
      "id": "21d23c4e-1bf0-48f8-bc84-c357c9c48fb6",
      "name": "Morning run?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        80,
        320
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $('Every morning').isExecuted }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "looseTypeValidation": true,
        "options": {}
      }
    },
    {
      "id": "46570164-3094-4d58-a01e-a725ded1189d",
      "name": "Read the whole calendar",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        320,
        140
      ],
      "parameters": {
        "operation": "read",
        "documentId": {
          "__rl": true,
          "value": "",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "options": {}
      },
      "executeOnce": true,
      "alwaysOutputData": true
    },
    {
      "id": "a0c727b1-f2ce-499c-ad02-4afd6ce88753",
      "name": "Count the day",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        560,
        140
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const rows = $input.all().map(i => i.json).filter(r => r['Row ID'] || r.Caption);\nconst st = r => String(r.Status || '').trim().toLowerCase();\nconst when = r => { const d = DateTime.fromISO(String(r['Scheduled For'] || '')); return d.isValid ? d.setZone($now.zoneName) : null; };\nconst today = rows.filter(r => { const d = when(r); return d && d.toISODate() === $now.toISODate() && !/fail|error/.test(st(r)); })\n  .sort((a, b) => when(a).toMillis() - when(b).toMillis());\nconst waiting = rows.filter(r => st(r) === 'approved');\nconst broken = rows.filter(r => /fail|error/.test(st(r)));\nconst cut = t => { t = String(t || ''); return t.length > 50 ? t.slice(0, 47) + '...' : t; };\nconst parts = ['Your sheet this morning', '', 'Going out today: ' + today.length];\nfor (const r of today.slice(0, 10)) parts.push('- ' + when(r).toFormat('HH:mm') + ' ' + cut(r.Caption));\nparts.push('', 'Approved, not scheduled yet: ' + waiting.length, 'Need fixing: ' + broken.length);\nfor (const r of broken.slice(0, 10)) parts.push('- Row ' + (r['Row ID'] || r.row_number) + ': ' + cut(r.Error || r.Status));\nreturn [{ json: { message: parts.join('\\n') } }];"
      }
    },
    {
      "id": "4b7d80bd-5671-4bef-a2c3-faca537aa606",
      "name": "Send the morning summary",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        800,
        140
      ],
      "parameters": {
        "chatId": "={{ $('Settings').first().json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "4f6d27c3-d48c-4460-8bd9-3b96cf9eb191",
      "name": "Rows sprkly refused",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1040,
        320
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const bad = $('Schedule post in sprkly').all().map(i => i.json).filter(r => r.ok !== true);\nif (bad.length === 0) return [];\nconst why = r => typeof r.error === 'string' && r.error ? r.error : (r.error && r.error.message) || 'sprkly did not give a reason.';\nconst lines = bad.slice(0, 10).map(r => '- Row ' + (r['Row ID'] || r.row_number) + ': ' + why(r));\nreturn [{ json: { message: 'Rows sprkly did not schedule: ' + bad.length + '\\n\\n' + lines.join('\\n') + (bad.length > 10 ? '\\n...and ' + (bad.length - 10) + ' more' : '') + '\\n\\nFix them in the sheet, then set Status back to Approved.' } }];"
      }
    },
    {
      "id": "4748a459-d857-433c-b1ab-1b174b09d503",
      "name": "Tell you what to fix",
      "type": "n8n-nodes-base.telegram",
      "typeVersion": 1.2,
      "position": [
        1280,
        320
      ],
      "parameters": {
        "chatId": "={{ $('Settings').first().json.telegramChatId }}",
        "text": "={{ $json.message }}",
        "additionalFields": {
          "appendAttribution": false
        }
      }
    }
  ],
  "connections": {
    "Every 15 minutes": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get approved rows": {
      "main": [
        [
          {
            "node": "Schedule post in sprkly",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule post in sprkly": {
      "main": [
        [
          {
            "node": "Write result to row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When a post goes out": {
      "main": [
        [
          {
            "node": "Write post status to row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When a post fails": {
      "main": [
        [
          {
            "node": "Write post status to row",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When this workflow's post goes live": {
      "main": [
        [
          {
            "node": "Build published log rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build published log rows": {
      "main": [
        [
          {
            "node": "Published log settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Published log settings": {
      "main": [
        [
          {
            "node": "Ensure published log tab",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ensure published log tab": {
      "main": [
        [
          {
            "node": "Restore published log rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Restore published log rows": {
      "main": [
        [
          {
            "node": "Upsert published post log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When this workflow fails": {
      "main": [
        [
          {
            "node": "Write the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the failure alert": {
      "main": [
        [
          {
            "node": "Send the failure alert",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every morning": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Morning run?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Morning run?": {
      "main": [
        [
          {
            "node": "Read the whole calendar",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get approved rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Read the whole calendar": {
      "main": [
        [
          {
            "node": "Count the day",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Count the day": {
      "main": [
        [
          {
            "node": "Send the morning summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write result to row": {
      "main": [
        [
          {
            "node": "Rows sprkly refused",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rows sprkly refused": {
      "main": [
        [
          {
            "node": "Tell you what to fix",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}
