Every Monday morning, posts who is on leave this week from BambooHR to Slack, with their dates, holidays and work anniversaries.

UsesBambooHRSlack

Tell the team who's out this week

On Monday morning nobody knows who is off this week, so meetings get booked with people who are away, cover isn't arranged and HR spends the week answering "is Sam off?". Every Monday at 08:00, the week's approved time off and company holidays are read from BambooHR and posted to your team's Slack channel as one message: how many people are out, then each person with the real dates of their leave, so someone away since last Thursday or back next Tuesday shows exactly that. Company holidays follow, then the work anniversaries that fall this week, such as "Priya Shah – 3 years on Wednesday".

Only names and dates are posted. The type of leave stays private unless you switch it on, so a sick day reads simply as a day out. A week with nobody away gets one short line saying so. If BambooHR can't be read, nothing is posted and the run is marked as failed, so an outage never reads as "nobody is out"; if only the anniversaries can't be checked, who's out is still posted and the run names what was left out.

You need BambooHR and Slack connected, with BambooHR connected through an HR admin's account so it can see everyone's time off and hire dates, and the ID of the Slack channel the message goes to. Two settings let you show the type of leave and switch anniversaries off.

Run every Monday at 08:00.Run every Monday at 08:00.
Set showLeaveType to false.Set showLeaveType to false.
Set includeWorkAnniversaries to true.Set includeWorkAnniversaries to true.
Set slackChannelId to blank.Set slackChannelId to blank.
Get today's date and save it as today.Get today's date and save it as today.
Get the start of the week for today and save it as weekStart.Get the start of the week for today and save it as weekStart.
Get the end of the week for today and save it as weekEnd.Get the end of the week for today and save it as weekEnd.
Make weekStart readable as “2 Nov” and save it as weekFrom.Make weekStart readable as “2 Nov” and save it as weekFrom.
Make weekEnd readable as “2 Nov” and save it as weekTo.Make weekEnd readable as “2 Nov” and save it as weekTo.
Set entries to an empty list.Set entries to an empty list.
Set nextPage to 1.Set nextPage to 1.
Set morePages to true.Set morePages to true.
While morePages is yes:While morePages is yes:
If a step below fails, save the error as readErrorIf a step below fails, save the error as readError
Try
BambooHRBambooHRList who's out in BambooHR from weekStart to weekEnd. Save it as whosOut.List who's out in BambooHR from weekStart to weekEnd. Save it as whosOut.
Combine entries and whosOut.entries into one list and save it as entries.Combine entries and whosOut.entries into one list and save it as entries.
Change morePages to whosOut.has_more.Change morePages to whosOut.has_more.
On error
Stop and report a problem: Nothing was posted: who's out could not be read from BambooHR (readError.message). Check under Apps that BambooHR is still connected, then run the workflow again.Stop and report a problem: Nothing was posted: who's out could not be read from BambooHR (readError.message). Check under Apps that BambooHR is still connected, then run the workflow again.
Add 1 to nextPage.Add 1 to nextPage.
Keep each item in entries where item.type in lowercase is “holiday” and save it as holidays.Keep each item in entries where item.type in lowercase is “holiday” and save it as holidays.
Keep each item in entries where item.type in lowercase is not “holiday” and save it as absences.Keep each item in entries where item.type in lowercase is not “holiday” and save it as absences.
If showLeaveType is yesIf showLeaveType is yes
Yes
If a step below fails, save the error as typesErrorIf a step below fails, save the error as typesError
Try
BambooHRBambooHRList time off types. Save it as leaveTypes.List time off types. Save it as leaveTypes.
Rename fields in leaveTypes.time_off_types and save it as leaveTypeNames.Rename fields in leaveTypes.time_off_types and save it as leaveTypeNames.
Match absences with leaveTypeNames by “timeOffTypeId” and save it as absences.Match absences with leaveTypeNames by “timeOffTypeId” and save it as absences.
On error
Stop and report a problem: Nothing was posted: the types of leave could not be read from BambooHR (typesError.message). Check that BambooHR is still connected, or set showLeaveType to false, then run the workflow again.Stop and report a problem: Nothing was posted: the types of leave could not be read from BambooHR (typesError.message). Check that BambooHR is still connected, or set showLeaveType to false, then run the workflow again.
No
No steps
Sort absences by name, smallest first and save it as absencesByName.Sort absences by name, smallest first and save it as absencesByName.
Sort absencesByName by start, smallest first and save it as absencesInOrder.Sort absencesByName by start, smallest first and save it as absencesInOrder.
Group the items in absencesInOrder by “employeeId” and save it as peopleOut.Group the items in absencesInOrder by “employeeId” and save it as peopleOut.
Set personLines to an empty list.Set personLines to an empty list.
For each person in peopleOut:For each person in peopleOut:
Set periods to an empty list.Set periods to an empty list.
For each absence in person.items:For each absence in person.items:
Make absence.start readable as “Mon 2 Nov” and save it as period.Make absence.start readable as “Mon 2 Nov” and save it as period.
If absence.end is not absence.startIf absence.end is not absence.start
Yes
Make absence.end readable as “Mon 2 Nov” and save it as absenceLastDay.Make absence.end readable as “Mon 2 Nov” and save it as absenceLastDay.
Change period to “@period to absenceLastDay”.Change period to “@period to absenceLastDay”.
No
No steps
Use absence.leaveType, or “” if it is empty and save it as leaveTypeName.Use absence.leaveType, or “” if it is empty and save it as leaveTypeName.
If leaveTypeName isn't blankIf leaveTypeName isn't blank
Yes
Change period to “@period (leaveTypeName)”.Change period to “@period (leaveTypeName)”.
No
No steps
Add period to the end of periods and save it as periods.Add period to the end of periods and save it as periods.
Join periods with “, ” and save it as periodList.Join periods with “, ” and save it as periodList.
Add • person.items[0].name – periodList to the end of personLines and save it as personLines.Add • person.items[0].name – periodList to the end of personLines and save it as personLines.
Sort holidays by start, smallest first and save it as holidaysInOrder.Sort holidays by start, smallest first and save it as holidaysInOrder.
Set holidayLines to an empty list.Set holidayLines to an empty list.
For each holiday in holidaysInOrder:For each holiday in holidaysInOrder:
Make holiday.start readable as “Mon 2 Nov” and save it as holidayDates.Make holiday.start readable as “Mon 2 Nov” and save it as holidayDates.
If holiday.end is not holiday.startIf holiday.end is not holiday.start
Yes
Make holiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.Make holiday.end readable as “Mon 2 Nov” and save it as holidayLastDay.
Change holidayDates to “@holidayDates to holidayLastDay”.Change holidayDates to “@holidayDates to holidayLastDay”.
No
No steps
Add • holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.Add • holiday.name – holidayDates to the end of holidayLines and save it as holidayLines.
Set anniversaries to an empty list.Set anniversaries to an empty list.
Set anniversaryProblems to an empty list.Set anniversaryProblems to an empty list.
If showLeaveType is yes and absences isn't empty and the items in absences where…If showLeaveType is yes and absences isn't empty and the items in absences where…
Yes
Add “the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it.” to the end of anniversaryProblems and save it as anniversaryProblems.Add “the type of leave was left out because BambooHR did not say which type each absence is. Set showLeaveType to false to post without it.” to the end of anniversaryProblems and save it as anniversaryProblems.
No
No steps
If includeWorkAnniversaries is yesIf includeWorkAnniversaries is yes
Yes
Set colleagues to an empty list.Set colleagues to an empty list.
Set datedColleagues to an empty list.Set datedColleagues to an empty list.
Set staffCursor to blank.Set staffCursor to blank.
Set moreStaff to true.Set moreStaff to true.
If a step below fails, save the error as staffErrorIf a step below fails, save the error as staffError
Try
While moreStaff is yes:While moreStaff is yes:
BambooHRBambooHR List employees. Save it as staffPage. List employees. Save it as staffPage.
Combine colleagues and staffPage.employees into one list and save it as colleagues. Combine colleagues and staffPage.employees into one list and save it as colleagues.
Change staffCursor to staffPage.next_cursor. Change staffCursor to staffPage.next_cursor.
Change moreStaff to staffPage.has_more. Change moreStaff to staffPage.has_more.
Keep each item in colleagues where item.hireDate, or “” if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.Keep each item in colleagues where item.hireDate, or “” if it is empty isn't blank and item.hireDate is not… and save it as datedColleagues.
Keep each item in colleagues where item._restrictedFields contains “hireDate” and save it as hiddenHireDates.Keep each item in colleagues where item._restrictedFields contains “hireDate” and save it as hiddenHireDates.
Count the items in colleagues and save it as activeCount.Count the items in colleagues and save it as activeCount.
If activeCount is 0If activeCount is 0
Yes
Add “work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records.” to the end of anniversaryProblems and save it as anniversaryProblems.Add “work anniversaries were left out because BambooHR returned no active employees. Connect BambooHR with a key from someone who can see everyone's records.” to the end of anniversaryProblems and save it as anniversaryProblems.
Else if @hiddenHireDates isn't empty
Count the items in hiddenHireDates and save it as hiddenCount.Count the items in hiddenHireDates and save it as hiddenCount.
Add BambooHR hides the hire date of hiddenCount of your activeCount active employees from this BambooHR account, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.Add BambooHR hides the hire date of hiddenCount of your activeCount active employees from this BambooHR account, so their work anniversaries were left out. Connect BambooHR with a key from someone who can see hire dates, or set includeWorkAnniversaries to false. to the end of anniversaryProblems and save it as anniversaryProblems.
Else if @datedColleagues is empty
Add work anniversaries were left out because none of your activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because none of your activeCount active employees has a hire date in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.
Otherwise
No steps
On error
Change datedColleagues to an empty list.Change datedColleagues to an empty list.
Add work anniversaries were left out because the employee list could not be read from BambooHR (staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.Add work anniversaries were left out because the employee list could not be read from BambooHR (staffError.message). to the end of anniversaryProblems and save it as anniversaryProblems.
Set unreadableHireDates to an empty list.Set unreadableHireDates to an empty list.
For each colleague in datedColleagues:For each colleague in datedColleagues:
If a step below fails, save the error as dateError If a step below fails, save the error as dateError
Try
Count the years from colleague.hireDate to weekEnd and save it as yearsBySunday.Count the years from colleague.hireDate to weekEnd and save it as yearsBySunday.
If yearsBySunday is greater than or equal to 1If yearsBySunday is greater than or equal to 1
Yes
Move colleague.hireDate by yearsBySunday years and save it as anniversaryDate.Move colleague.hireDate by yearsBySunday years and save it as anniversaryDate.
If the difference between weekStart and anniversaryDate in “days” is greater than…If the difference between weekStart and anniversaryDate in “days” is greater than…
Yes
Use colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.Use colleague.displayName, or colleague.firstName colleague.lastName if it is empty and save it as colleagueName.
Get the day of the week for anniversaryDate and save it as anniversaryDay.Get the day of the week for anniversaryDate and save it as anniversaryDay.
Set yearsText to “@yearsBySunday years”.Set yearsText to “@yearsBySunday years”.
If yearsBySunday is 1If yearsBySunday is 1
Yes
Change yearsText to “1 year”.Change yearsText to “1 year”.
No
No steps
Add a record of date and line to the end of anniversaries and save it as anniversaries.Add a record of date and line to the end of anniversaries and save it as anniversaries.
No
No steps
No
No steps
On error
Add colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.Add colleague.displayName to the end of unreadableHireDates and save it as unreadableHireDates.
If unreadableHireDates isn't emptyIf unreadableHireDates isn't empty
Yes
Join unreadableHireDates with “, ” and save it as unreadableNames.Join unreadableHireDates with “, ” and save it as unreadableNames.
Add the hire date of unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.Add the hire date of unreadableNames could not be read, so their work anniversaries were left out. Correct it in BambooHR. to the end of anniversaryProblems and save it as anniversaryProblems.
No
No steps
No
No steps
Sort anniversaries by date, smallest first and save it as anniversariesInOrder.Sort anniversaries by date, smallest first and save it as anniversariesInOrder.
Get “line” from every item in anniversariesInOrder and save it as anniversaryLines.Get “line” from every item in anniversariesInOrder and save it as anniversaryLines.
Count the items in peopleOut and save it as peopleCount.Count the items in peopleOut and save it as peopleCount.
Set outSummary to “@peopleCount people”.Set outSummary to “@peopleCount people”.
If peopleCount is 0If peopleCount is 0
Yes
Change outSummary to “nobody has time off booked”.Change outSummary to “nobody has time off booked”.
Else if @peopleCount is 1
Change outSummary to “1 person”.Change outSummary to “1 person”.
Otherwise
No steps
Set peopleSection to blank.Set peopleSection to blank.
If peopleCount is greater than 0If peopleCount is greater than 0
Yes
Join personLines with a new line and save it as personList.Join personLines with a new line and save it as personList.
Change peopleSection to Change peopleSection to personList.
No
No steps
Set holidaySection to blank.Set holidaySection to blank.
If holidayLines isn't emptyIf holidayLines isn't empty
Yes
Join holidayLines with a new line and save it as holidayList.Join holidayLines with a new line and save it as holidayList.
Change holidaySection to Change holidaySection to *Holidays* holidayList.
No
No steps
Set anniversarySection to blank.Set anniversarySection to blank.
If anniversaryLines isn't emptyIf anniversaryLines isn't empty
Yes
Join anniversaryLines with a new line and save it as anniversaryList.Join anniversaryLines with a new line and save it as anniversaryList.
Change anniversarySection to Change anniversarySection to *Work anniversaries* anniversaryList.
No
No steps
If a step below fails, save the error as postErrorIf a step below fails, save the error as postError
Try
SlackSlackSend a message to slackChannelId. Save it as posted.Send a message to slackChannelId. Save it as posted.*Who's out this week (weekFrom – weekTo):* outSummary@peopleSection@holidaySection@anniversarySection
On error
Stop and report a problem: The message could not be posted to Slack (postError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.Stop and report a problem: The message could not be posted to Slack (postError.message). Check that 'slackChannelId' at the top of the workflow is your team channel's ID, and for a private channel add the Lodol app to it by typing /invite Lodol in that channel.
Count the items in holidayLines and save it as holidayCount.Count the items in holidayLines and save it as holidayCount.
Count the items in anniversaryLines and save it as anniversaryCount.Count the items in anniversaryLines and save it as anniversaryCount.
If anniversaryProblems isn't emptyIf anniversaryProblems isn't empty
Yes
Join anniversaryProblems with “ Also, ” and save it as problemList.Join anniversaryProblems with “ Also, ” and save it as problemList.
Stop and report a problem: Posted who's out for weekFrom – weekTo (outSummary), but problemList.Stop and report a problem: Posted who's out for weekFrom – weekTo (outSummary), but problemList.
No
No steps
Finish the run: Posted who's out for weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.Finish the run: Posted who's out for weekFrom – weekTo: outSummary; holidays: holidayCount; work anniversaries: anniversaryCount.