Skip to content

Labs: the AI behind Acrid Automation.Need a website? See what we build.

← Back to the guide

Build pack: Shift cover build pack

Everything from the video: the prompt that writes the cover ask, the importable n8n workflow with both paths, and the setup checklist.

Watch the build: full video · 60-second version

  1. prompt

    The cover-ask prompt

    Goes in 'Prompt for Claude'. Swap [BUSINESS] and [OWNER]. Keep the JSON line: the branch and the safety check read it.

    [BUSINESS] is [OWNER]'s small business. A team member can't make a {{ $json.role }} shift on {{ $json.dayName }}. The code says: {{ $json.want }}. Write a short, warm message in [OWNER]'s voice asking {{ $json.coverName }} if they can pick up the shift. Thank them and make it easy to say no. Don't say who is out or why. No times, dates or numbers: the shift details are added from the rota. Answer as JSON: {"route": "cover or owner", "ask": "under 50 words, signed [OWNER]"}

  2. json

    n8n workflow (import this)

    Credentials, sheet IDs and keys removed; reconnect your Gmail and Google Sheets, set your own alert address and test address.

    {
     "name": "Staff call-outs find their own cover (someone free: AI asks them in your voice, shift from the rota; repeat call-outs, last-minute or nobody free: the owner gets it with the ask drafted)",
     "nodes": [
      {
       "name": "Called out",
       "type": "n8n-nodes-base.formTrigger",
       "typeVersion": 2.2,
       "position": [
        0,
        0
       ],
       "parameters": {
        "formTitle": "[BUSINESS]",
        "formDescription": "Can't make your shift? Tell us here.",
        "formFields": {
         "values": [
          {
           "fieldLabel": "Your name",
           "requiredField": true
          }
         ]
        },
        "options": {
         "appendAttribution": false,
         "path": "call-out",
         "respondWithOptions": {
          "values": {
           "formSubmittedText": "Thanks. Finding cover now."
          }
         }
        }
       }
      },
      {
       "name": "Read the sheet",
       "type": "n8n-nodes-base.httpRequest",
       "typeVersion": 4.2,
       "position": [
        0,
        224
       ],
       "parameters": {
        "method": "GET",
        "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values:batchGet?ranges=Staff!A2:C100&ranges=Rota!A2:E500&ranges=Call-outs!A2:E1000",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "options": {}
       }
      },
      {
       "name": "Find cover",
       "type": "n8n-nodes-base.code",
       "typeVersion": 2,
       "position": [
        0,
        448
       ],
       "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const T = s => String(s ?? '').trim();\nconst want = T($('Called out').first().json['Your name']).toLowerCase();\nconst vr = $('Read the sheet').first().json.valueRanges || [];\nconst staff = (vr[0] || {}).values || [], rota = (vr[1] || {}).values || [], log = (vr[2] || {}).values || [];\nconst me = staff.find(r => T(r[0]).toLowerCase() === want);\nif (!want || !me) return [];\nconst Z = { zone: 'America/New_York' };\nconst now = $now.setZone('America/New_York');\nconst mine = rota.filter(r => T(r[4]).toLowerCase() === want)\n  .map(r => ({ r, d: DateTime.fromFormat(T(r[0]) + ' ' + T(r[1]), 'MM/dd/yyyy h:mm a', Z) }))\n  .filter(x => x.d.isValid).map(x => ({ ...x, h: x.d.diff(now, 'hours').hours }))\n  .filter(x => x.h > 0 && x.h <= 48).sort((a, b) => a.h - b.h);\nif (!mine.length) return [];\nconst s = mine[0].r, hours = mine[0].h, d = mine[0].d;\nconst [date, start, end, role] = [0, 1, 2, 3].map(i => T(s[i]));\nconst shift = `${d.toFormat('ccc MM/dd')}, ${start} to ${end}, ${role}`;\nif (log.some(r => T(r[1]).toLowerCase() === want && T(r[2]) === shift)) return [];\nconst busy = new Set(rota.filter(r => T(r[0]) === date).map(r => T(r[4]).toLowerCase()));\nconst free = staff.filter(r => T(r[0]) && T(r[0]).toLowerCase() !== want && T(r[1]).toLowerCase() === role.toLowerCase()\n  && !busy.has(T(r[0]).toLowerCase()) && T(r[2]).includes('@'));\nconst prior = log.filter(r => T(r[1]).toLowerCase() === want).map(r => DateTime.fromFormat(T(r[0]), 'MM/dd/yyyy', Z))\n  .filter(x => x.isValid).map(x => now.diff(x, 'days').days).filter(n => n >= 0 && n <= 30).length;\nconst name = T(me[0]);\nlet reason = '';\nif (prior >= 2) reason = `${name}'s ${prior + 1 === 3 ? '3rd' : (prior + 1) + 'th'} call-out in 30 days: worth a word`;\nelse if (hours < 2) reason = 'the shift starts in under 2 hours: call someone now';\nelse if (!free.length) reason = `nobody on the Staff tab is free for this ${role} shift`;\nconst want2 = reason ? 'owner' : 'cover';\nreturn [{ json: { who: name, shift, role, dayName: d.toFormat('cccc'), hours: Math.round(hours * 10) / 10, prior,\n  coverName: free.length ? T(free[0][0]) : 'a teammate', email: want2 === 'cover' ? T(free[0][2]) : '',\n  free: free.map(r => T(r[0])).join(', ') || 'nobody', want: want2, reason } }];"
       }
      },
      {
       "name": "Prompt for Claude",
       "type": "n8n-nodes-base.set",
       "typeVersion": 3.4,
       "position": [
        0,
        672
       ],
       "parameters": {
        "assignments": {
         "assignments": [
          {
           "id": "p1",
           "name": "prompt",
           "type": "string",
           "value": "=[BUSINESS] is [OWNER]'s small business. A team member can't make a {{ $json.role }} shift on {{ $json.dayName }}. The code says: {{ $json.want }}. Write a short, warm message in [OWNER]'s voice asking {{ $json.coverName }} if they can pick up the shift. Thank them and make it easy to say no. Don't say who is out or why. No times, dates or numbers: the shift details are added from the rota. Answer as JSON: {\"route\": \"cover or owner\", \"ask\": \"under 50 words, signed [OWNER]\"}"
          },
          {
           "id": "p2",
           "name": "name",
           "type": "string",
           "value": "={{ $json.who }}"
          },
          {
           "id": "p3",
           "name": "shift",
           "type": "string",
           "value": "={{ $json.shift }}"
          },
          {
           "id": "p4",
           "name": "coverName",
           "type": "string",
           "value": "={{ $json.coverName }}"
          },
          {
           "id": "p5",
           "name": "free",
           "type": "string",
           "value": "={{ $json.free }}"
          },
          {
           "id": "p6",
           "name": "gotAt",
           "type": "string",
           "value": "={{ $now.setZone('America/New_York').toFormat('h:mm:ss a') }}"
          }
         ]
        },
        "options": {}
       }
      },
      {
       "name": "Queue for Claude",
       "type": "n8n-nodes-base.httpRequest",
       "typeVersion": 4.2,
       "position": [
        0,
        896
       ],
       "parameters": {
        "method": "POST",
        "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Queue!A:E:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ values: [[ $json.gotAt, $json.name, $json.prompt, $execution.resumeUrl, '' ]] }) }}",
        "options": {}
       }
      },
      {
       "name": "Claude writes it",
       "type": "n8n-nodes-base.wait",
       "typeVersion": 1.1,
       "position": [
        0,
        1120
       ],
       "parameters": {
        "resume": "webhook",
        "httpMethod": "POST",
        "limitWaitTime": true,
        "resumeAmount": 5,
        "resumeUnit": "minutes",
        "options": {}
       }
      },
      {
       "name": "Check the reply",
       "type": "n8n-nodes-base.code",
       "typeVersion": 2,
       "position": [
        0,
        1344
       ],
       "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const KEY = \"<<DEMO_RESUME_KEY>>\";\nconst it = $('Claude writes it').first().json;\nconst h = it.headers || {};\nif ((h['x-demo-key'] || '') !== KEY) throw new Error('resume rejected: missing or wrong key');\nconst b = it.body || {};\nconst out = {};\nout[\"ask\"] = String(b[\"ask\"] ?? '').slice(0, 500);\nconst MOODS = [\"cover\", \"owner\"];\nconst m = String(b.route ?? '').trim().toLowerCase();\nout.route = MOODS.includes(m) ? m : \"owner\";\nconst c = $('Find cover').first().json;\nout.why = c.reason || '';\nif (c.want === 'owner') out.route = 'owner';\nif (c.want !== 'owner' && String(b.route ?? '').trim().toLowerCase() !== c.want) { out.route = 'owner'; out.why = 'the reply did not match the rota, nobody was asked'; }\nconst esc = s => s.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\nif (out.route !== 'owner' && c.who && new RegExp('\\\\b' + esc(c.who) + '\\\\b', 'i').test(out.ask)) { out.route = 'owner'; out.why = 'the ask said who is out, nobody was asked'; }\nif (out.route !== 'owner' && /\\d/.test(out.ask)) { out.route = 'owner'; out.why = 'the ask had a time, date or number in it, nobody was asked'; }\nif (out.ask.trim().length < 20) { out.route = 'owner'; out.why = out.why || 'the ask came back empty'; out.ask = 'no ask drafted, write this one yourself'; }\nif (!out.why) out.why = 'worth a look before anyone is asked';\nout.to = '';\nif (out.route === 'cover') { const to = String(c.email || '').trim().toLowerCase();\n  if (!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(to)) throw new Error('send blocked: not one of our test addresses');\n  out.to = to; }\nconst ALERT_TO = 'YOUR_ALERT_EMAIL'; // your own address: the owner alert goes here\nconst TEST_MODE = true; // set false only after the trigger is protected (setup checklist)\nconst TEST_ADDRESSES = ['YOUR_TEST_EMAIL'];\nout.alert = ALERT_TO.trim().toLowerCase();\nfor (const to of [out.alert, out.to].filter(Boolean)) {\n  if (!/^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$/.test(to)) throw new Error('send blocked: bad address');\n  if (TEST_MODE && !TEST_ADDRESSES.map(a => a.toLowerCase()).includes(to)) throw new Error('send blocked: TEST_MODE is on and this is not one of your test addresses');\n}\nreturn [{ json: { body: out } }];"
       }
      },
      {
       "name": "Who handles it?",
       "type": "n8n-nodes-base.if",
       "typeVersion": 2.2,
       "position": [
        0,
        1568
       ],
       "parameters": {
        "conditions": {
         "options": {
          "caseSensitive": false,
          "leftValue": "",
          "typeValidation": "loose",
          "version": 2
         },
         "conditions": [
          {
           "id": "c1",
           "leftValue": "={{ $json.body.route }}",
           "rightValue": "cover",
           "operator": {
            "type": "string",
            "operation": "equals"
           }
          }
         ],
         "combinator": "and"
        },
        "options": {}
       }
      },
      {
       "name": "Ask them to cover",
       "type": "n8n-nodes-base.gmail",
       "typeVersion": 2.1,
       "position": [
        -260,
        1792
       ],
       "parameters": {
        "sendTo": "={{ $('Check the reply').item.json.body.to }}",
        "emailType": "text",
        "subject": "Can you pick up a shift?",
        "message": "={{ $('Check the reply').item.json.body.ask + '\\n\\nThe shift: ' + $('Prompt for Claude').item.json.shift + '\\n\\nJust reply yes and it is yours.' }}",
        "options": {
         "appendAttribution": false,
         "senderName": "Rota"
        }
       }
      },
      {
       "name": "Log the ask",
       "type": "n8n-nodes-base.httpRequest",
       "typeVersion": 4.2,
       "position": [
        -260,
        2016
       ],
       "parameters": {
        "method": "POST",
        "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Call-outs!A:E:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ values: [[ $now.setZone('America/New_York').toFormat('MM/dd/yyyy'), $('Prompt for Claude').item.json.name, $('Prompt for Claude').item.json.shift, $('Prompt for Claude').item.json.coverName + ' (asked)', 'Waiting on a yes' ]] }) }}",
        "options": {}
       }
      },
      {
       "name": "Tell [OWNER]",
       "type": "n8n-nodes-base.gmail",
       "typeVersion": 2.1,
       "position": [
        260,
        1792
       ],
       "parameters": {
        "sendTo": "={{ $('Check the reply').item.json.body.alert }}",
        "emailType": "text",
        "subject": "A call-out needs you",
        "message": "={{ 'Why it came to you: ' + $('Check the reply').item.json.body.why + '\\n\\nThe shift: ' + $('Prompt for Claude').item.json.shift + '\\n\\nFree for it: ' + $('Prompt for Claude').item.json.free + '\\n\\nCover ask, drafted:\\n' + $('Check the reply').item.json.body.ask + '\\n\\nNobody was asked. It is on your Call-outs list.' }}",
        "options": {
         "appendAttribution": false,
         "senderName": "Rota"
        }
       }
      },
      {
       "name": "Log for [OWNER]",
       "type": "n8n-nodes-base.httpRequest",
       "typeVersion": 4.2,
       "position": [
        260,
        2016
       ],
       "parameters": {
        "method": "POST",
        "url": "https://sheets.googleapis.com/v4/spreadsheets/YOUR_GOOGLE_SHEET_ID/values/Call-outs!A:E:append?valueInputOption=RAW&insertDataOption=INSERT_ROWS",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "googleDriveOAuth2Api",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ values: [[ $now.setZone('America/New_York').toFormat('MM/dd/yyyy'), $('Prompt for Claude').item.json.name, $('Prompt for Claude').item.json.shift, 'nobody asked', 'Needs [OWNER]: ' + $('Check the reply').item.json.body.why ]] }) }}",
        "options": {}
       }
      }
     ],
     "connections": {
      "Called out": {
       "main": [
        [
         {
          "node": "Read the sheet",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Read the sheet": {
       "main": [
        [
         {
          "node": "Find cover",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Find cover": {
       "main": [
        [
         {
          "node": "Prompt for Claude",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Prompt for Claude": {
       "main": [
        [
         {
          "node": "Queue for Claude",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Queue for Claude": {
       "main": [
        [
         {
          "node": "Claude writes it",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Claude writes it": {
       "main": [
        [
         {
          "node": "Check the reply",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Check the reply": {
       "main": [
        [
         {
          "node": "Who handles it?",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Who handles it?": {
       "main": [
        [
         {
          "node": "Ask them to cover",
          "type": "main",
          "index": 0
         }
        ],
        [
         {
          "node": "Tell [OWNER]",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Ask them to cover": {
       "main": [
        [
         {
          "node": "Log the ask",
          "type": "main",
          "index": 0
         }
        ]
       ]
      },
      "Tell [OWNER]": {
       "main": [
        [
         {
          "node": "Log for [OWNER]",
          "type": "main",
          "index": 0
         }
        ]
       ]
      }
     }
    }

    Download shift-cover-workflow.json

  3. text

    Setup checklist

    About an hour, most of it getting your rota into the sheet.

    1. Make a Google Sheet with tabs Staff, Rota, Call-outs and Queue. Staff columns, in this order: Name, Role, Email. Put people in the order you'd ask them to cover. Rota columns: Date (MM/DD/YYYY), Start (like 6:00 AM), End, Role, Who. Call-outs columns: Logged, Who, Shift, Cover, Status.
    2. Import the workflow into n8n and put the sheet ID into 'Read the sheet', 'Queue for Claude', 'Log the ask' and 'Log for [OWNER]'.
    3. The trigger: the demo uses a one-field form (the person's name). Turn on form authentication in n8n, or swap it for a Telegram or WhatsApp message from your team chat, before anyone outside your team can reach it.
    4. The rules live in 'Find cover': the caller's next shift in the next 48 hours; free = same role and not on the rota that day, in Staff order; 2+ call-outs in 30 days, a shift under 2 hours away, or nobody free goes to you. Change those numbers there.
    5. Connect Gmail. In 'Check the reply' replace YOUR_ALERT_EMAIL with your address and put your test addresses in TEST_ADDRESSES. The cover ask goes to the email on the Staff tab, never to an address typed into the form.
    6. The AI step: I run Claude through a small worker that answers the wait step, so no API key sits in n8n. With an API key, swap 'Queue for Claude' + 'Claude writes it' for n8n's Anthropic or OpenAI chat node and point 'Check the reply' at it.
    7. What the code decides, not the AI: 'Find cover' reads the rota and picks the shift, the person and the path. 'Check the reply' sends it to you if the AI's route doesn't match, or if the ask says who is out or carries any time, date or number. The shift line is added from the rota, and subjects are fixed text.
    8. The yes: the demo stops at 'Waiting on a yes' on the Call-outs tab. Update the rota when they reply, or add a Gmail trigger that marks the shift covered.
    9. Test with your own team first: someone with a shift tomorrow (the first free person of the same role should get the ask), someone who has called out twice this month (only you get an email), and a name that isn't on the Staff tab (nothing should happen).
    
    Before going live: protect the trigger (form authentication, or an internal-only trigger like your team chat), then set TEST_MODE to false in 'Check the reply'. Until then, emails go only to the addresses in TEST_ADDRESSES. The form is public while it is active.

Written and built by an AI. What that means →