Shift swaps usually live in a group chat and a paper rota, so nobody is sure who approved what. This workflow takes swap requests from your form or internal tool, checks them against the roster and earlier requests, lets a GPT-6.1-sol agent add its judgement, and gives the manager a simple approve or deny webhook. Pending swaps are chased daily and the month is reported with real counts.
Last updated: November 2026.
Quick Overview
A swap request arrives on the shift-swap/advance webhook and is normalized. Requests missing the name, date or requested shift are bounced back on Telegram. The workflow then reads a Roster tab and the ShiftSwaps log. A code step flags same shift swaps, unreadable or past dates, shifts within two days, missing reasons, a requested shift that is not on the roster and an employee who already works it, and stops exact duplicates before any AI call. The agent reviews the rest, and its verdict is combined with the rule flags, so a rule hit always means manager review. Every request is logged. Pending swaps reach the manager on Telegram and Gmail, and the manager answers through a second webhook, which updates the row and tells the employee. A daily check nudges the manager about waiting swaps, and the monthly report is built from computed counts.
How it works
- When Shift Swap Requested receives the request, Set Normalize Shift Request builds the record and Validate Shift Request bounces incomplete ones through Notify Invalid Request.
- Read Roster and Read Recent Swaps load the rota and the log. Check Conflicts and Rules computes the rule flags and detects duplicates. Duplicate Request? sends repeats to Tell Employee Duplicate.
- AI Swap Review Agent returns a JSON verdict and Set Extracted AI Data maps it. Combine Rule and AI Verdict forces review whenever a rule flag is present.
- Append Swap to Sheets logs the request with status, rule flags, the employee chat id and empty decision columns.
- If Manager Review Needed sends pending swaps to Notify Manager via Telegram and Email Manager Shift Summary, which explains how to decide. Clean swaps get Confirm Shift via Telegram.
- When Manager Decides receives a POST with request_id, decision and an optional note. Normalize Manager Decision and Look Up Swap Request find the row, and Check Decision Call rejects unknown ids, bad decisions and swaps that are no longer pending.
- Valid calls go to Record Manager Decision, which writes APPROVED or DENIED, and Tell Employee Decision messages the employee. Invalid calls trigger Alert Invalid Decision.
- Daily Pending Swap Check 9am finds swaps pending over 24 hours or with a shift within three days, and Remind Manager About Swap plus Update Swap Reminders nudge the manager up to three times.
- On the first of the month Count Monthly Swaps counts last month by status, rule flags and reasons. The agent only adds highlights, merged by Merge Monthly Figures before the Telegram report.
Setup
- Activate the workflow and point your swap form at shift-swap/advance. Keep the shift-swap/decision URL for managers or a simple approval button.
- In the spreadsheet create ShiftSwaps with the original columns plus rule_flags, employee_chat_id, manager_decision, manager_note, decided_at and reminders, and a Roster tab with shift_date, shift and employee_name.
- Add OpenAI credentials on both model nodes, which use gpt-4o-mini.
- Connect Telegram and replace the placeholder chat id 123456789. Employee messages use the chat id sent with the request.
- Connect Gmail and set the manager address, [email protected] in the template.
Quick Answers
Can the AI approve a risky swap on its own?
No. Any rule flag from the roster check forces manager review, whatever the agent says.
How does the manager answer?
By posting request_id and approve or deny to the shift-swap/decision webhook. The row is updated and the employee is told.
What stops duplicate requests?
Check Conflicts and Rules looks for the same employee, date and requested shift that is already logged, pending or approved.
Will a forgotten request just sit there?
No. The daily check reminds the manager up to three times.
Additional info
Built with n8n. Need an assessment on your business? Feel free to reach out at https://khmuhtadin.com/consultation/