{
  "name": "Send a weekly HollyHR who's-away summary to Slack",
  "nodes": [
    {
      "id": "ed952ca4-2cd0-473d-84f1-140282822870",
      "name": "Sticky Note Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -560,
        -16
      ],
      "parameters": {
        "content": "## Weekly who's-away summary for Slack\n### How it works\nEvery Monday morning this workflow asks HollyHR who is away this week, finds each person's name and posts one summary to Slack. It shows names and dates only, never the type of leave or any reason.\n### Setup\n1. In HollyHR, open Settings > Developers and create an API key. Under Access choose Custom and tick Read for People and Time off (people:read, time_off:read).\n2. In n8n, create a Bearer Auth credential, paste the key and select it in both HollyHR HTTP Request nodes.\n3. In 'Your settings', enter your HollyHR address: the web address you sign in on, with no slash at the end.\n4. In 'Post to Slack', connect Slack and choose a channel.\n5. To preview the message first, select 'Post to Slack' and press D to turn it off. Choose 'Execute workflow' and read the result. Turn the node back on, connect Slack and publish.\n### Customization\nChange the day or time in 'Every Monday'. Edit the wording in 'Write the summary'.",
        "height": 500,
        "width": 460,
        "color": 1
      }
    },
    {
      "id": "81bd7fee-92db-485e-893d-75c0604c950f",
      "name": "When clicking 'Execute workflow'",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        304
      ],
      "parameters": {}
    },
    {
      "id": "e7a18299-cd7a-4a75-8e8a-97a10e881c91",
      "name": "Every Monday",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        0,
        112
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "triggerAtDay": [
                1
              ],
              "triggerAtHour": 8
            }
          ]
        }
      }
    },
    {
      "id": "a502399c-0db0-448b-8a42-58f8dc49aff8",
      "name": "Your settings",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        240,
        208
      ],
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "3661a1eb-b0c6-406d-8b01-b65013fa75b8",
              "name": "hollyhrUrl",
              "value": "https://your-workspace.hollyhr.com",
              "type": "string"
            }
          ]
        },
        "options": {}
      }
    },
    {
      "id": "39ebbf6a-8eca-4061-8b10-59cb8dff7768",
      "name": "Work out this week",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        480,
        208
      ],
      "parameters": {
        "jsCode": "// Monday to Sunday of the current week, in your n8n time zone.\nconst monday = $now.startOf('week');\nreturn [{ json: { from: monday.toISODate(), to: monday.plus({ days: 6 }).toISODate() } }];"
      }
    },
    {
      "id": "d4a3e856-fff7-475d-8c77-f049dc44970b",
      "name": "Get who is out",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        208
      ],
      "parameters": {
        "url": "={{ $('Your settings').first().json.hollyhrUrl.replace(/\\/+$/, '') }}/api/v1/time-off/who-is-out",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "from",
              "value": "={{ $json.from }}"
            },
            {
              "name": "to",
              "value": "={{ $json.to }}"
            },
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "pagination": {
            "pagination": {
              "paginationMode": "updateAParameterInEachRequest",
              "parameters": {
                "parameters": [
                  {
                    "type": "qs",
                    "name": "cursor",
                    "value": "={{ $response.body.pagination.next_cursor }}"
                  }
                ]
              },
              "paginationCompleteWhen": "other",
              "completeExpression": "={{ !$response.body.pagination.has_more }}",
              "limitPagesFetched": true,
              "maxRequests": 20
            }
          }
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000
    },
    {
      "id": "c2c9466e-b84d-4048-8236-de5a17612d1b",
      "name": "Get people",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        960,
        208
      ],
      "parameters": {
        "url": "={{ $('Your settings').first().json.hollyhrUrl.replace(/\\/+$/, '') }}/api/v1/people",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "limit",
              "value": "100"
            }
          ]
        },
        "options": {
          "pagination": {
            "pagination": {
              "paginationMode": "updateAParameterInEachRequest",
              "parameters": {
                "parameters": [
                  {
                    "type": "qs",
                    "name": "cursor",
                    "value": "={{ $response.body.pagination.next_cursor }}"
                  }
                ]
              },
              "paginationCompleteWhen": "other",
              "completeExpression": "={{ !$response.body.pagination.has_more }}",
              "limitPagesFetched": true,
              "maxRequests": 20
            }
          }
        }
      },
      "retryOnFail": true,
      "maxTries": 3,
      "waitBetweenTries": 5000,
      "executeOnce": true
    },
    {
      "id": "6ae68f6e-e4f8-4239-8141-9d00fe9de780",
      "name": "Write the summary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1200,
        208
      ],
      "parameters": {
        "jsCode": "// One message: each person once, with their dates this week.\nconst names = new Map();\nfor (const page of $input.all()) {\n  for (const person of page.json.data ?? []) names.set(person.id, person.display_name);\n}\nconst day = (iso) => DateTime.fromISO(iso).toFormat('ccc d LLL');\nconst { from, to } = $('Work out this week').first().json;\nconst byPerson = new Map();\nfor (const page of $('Get who is out').all()) {\n  for (const leave of page.json.data ?? []) {\n    const start = leave.start_date < from ? from : leave.start_date;\n    const end = leave.end_date > to ? to : leave.end_date;\n    const when = start === end ? day(start) : day(start) + ' – ' + day(end);\n    const part = (leave.is_from_half_day && start === leave.start_date) ||\n      (leave.is_to_half_day && end === leave.end_date) ? ' (part of a day)' : '';\n    const list = byPerson.get(leave.person_id) ?? [];\n    list.push(when + part);\n    byPerson.set(leave.person_id, list);\n  }\n}\nconst lines = [...byPerson].map(\n  ([id, dates]) => '• ' + (names.get(id) ?? 'Someone') + ': ' + dates.join(', '),\n);\nconst heading = \"Who's away, \" + day(from) + ' – ' + day(to);\nconst text = lines.length ? heading + '\\n' + lines.sort().join('\\n') : heading + '\\nNobody is away.';\nreturn [{ json: { text } }];"
      }
    },
    {
      "id": "c23a0a2b-81f7-4f6e-8ff0-570fcb8f5a04",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        1440,
        208
      ],
      "parameters": {
        "select": "channel",
        "channelId": {
          "__rl": true,
          "value": "",
          "mode": "list"
        },
        "text": "={{ $json.text }}",
        "otherOptions": {}
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking 'Execute workflow'": {
      "main": [
        [
          {
            "node": "Your settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Every Monday": {
      "main": [
        [
          {
            "node": "Your settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Your settings": {
      "main": [
        [
          {
            "node": "Work out this week",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Work out this week": {
      "main": [
        [
          {
            "node": "Get who is out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get who is out": {
      "main": [
        [
          {
            "node": "Get people",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get people": {
      "main": [
        [
          {
            "node": "Write the summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the summary": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}
