# How do you close an offboarding checklist fast?

> A Pachca use case. The leaver card lands in the "Offboarding" chat and turns into a checklist by department. Each team closes its item with a "Done" button, the bot nudges whoever is behind and drops a PDF of the checklist into the thread.

> This is the Markdown version of https://pachca.com/en/scenarios/obhodnoy-list for AI agents. The API methods named here are documented at https://dev.pachca.com/llms-en.txt — open it before calling the API. Other use cases are listed at https://pachca.com/en/llms.txt.

## What you'll get

The page offers three options. Start with the first: it needs no handler.

- Option A. HR posts a checklist template with team tags in the "Offboarding" chat. A team reacts with ✅ and writes in the thread what it did.
- Option B. A handler in n8n receives the leaver card and runs the checklist with buttons, reminders and a PDF.
- Option C. The same, in your own code.

## What you need before you start

- Pachca access as an administrator with the scopes `chats:create`, `chat_members:write`, `bots:write`, `messages:create`, `pins:write`. The setup and check steps also need `search:users`, `group_tags:read`, `group_tags:write`, `messages:read`. Signing in is covered in the rules below.
- For option B, n8n with the Pachca node: https://pachca.com/en/help-center/integrations/avtomatizacii-v-pachke-s-pomoshchyu-n8n

## If you're an AI agent: working rules

### Who does what

- You do everything the instructions name an API method for. Don't ask the user to create a chat, a bot or a message by hand.
- Ask the user only to sign in to Pachca and to do what is listed in "Ask the user to do by hand".
- If you have no terminal, say so right away and don't pretend you set it up. Walk the user through the steps for people on the use case page and help with the template or the handler code.

### How to talk to the user

- The user is not a developer. Write briefly and in plain words. Don't mention API methods, scopes, response codes, `id`s or CLI profiles. Say "permissions" instead of "scopes" and "the program behind the bot" instead of "handler".
- Don't report your checks. A message contains only three things: what is done, what you need from the user, what you'll do next.
- Don't ask for what you can find out through the API or what is easy to change later. Take the value from the instructions and name it.
- Take the bot's message texts from the instructions or write them yourself and carry on. Show them in your final message and offer to change them. Don't wait for approval.
- Ask the questions from "Ask the user" in the same words.

### Your first message to the user

It has three parts. The first two together take at most five lines.

1. What the user will get: one or two lines.
2. What you will create yourself: the chat, the bot and the messages, with the names from the instructions. Word anything that depends on the user's choice as a condition: "if you choose the bot, I'll also create…".
3. "What I need from you": signing in to Pachca, if the user isn't signed in yet, and the questions from "Ask the user". If the use case or one of its options needs n8n, ask here whether the user has it and ask for access right away in the words from the "n8n" section below: "if you have n8n, send me…".

If part of the result appears only after a manual step by the user, say so in one line: "you'll schedule the retro questions yourself, I'll show you how".

The user's answers are their consent to the plan. Start the setup right after them, without asking for a second confirmation.

### Access to Pachca

- The user doesn't need to issue a token or send it in the chat. Before your first message, check the login: `npx -y @pachca/cli@latest auth status`. If there is none, ask the user to run `npx -y @pachca/cli@latest auth login` in their own terminal. The CLI shows a code; the user enters it in the browser and confirms access. Write the commands with `@latest`: without it an old cached CLI version may start, and it asks to paste a token instead of signing in through the browser.
- This login has the same rights as the user's role. Compare them with the scopes in "What you need before you start" yourself: `npx -y @pachca/cli@latest api GET /oauth/token/info` shows the scopes. If something is missing, say in plain words what you won't be able to do, for example "I can't send messages". There are two ways out: add this permission to the token in Pachca, under "Automations" → "API", or sign in again as the workspace owner or an administrator.
- If `auth status` shows `scopes: null`, it doesn't mean there are no rights: look at `GET /oauth/token/info`. The checks in these rules also need `search:chats`, `bots:read` and `profile:read`.
- When the user says "me", they mean the owner of the login. `GET /profile` returns their `id` and nickname.
- Call the API with `npx -y @pachca/cli@latest api <METHOD> <path> -o json`. Write the full command in every call; don't put it into a shell variable.
- Pass query parameters as `--query key=value`, for example `--query query=Purchasing`. The CLI silently drops a parameter without a key and returns the whole list, so it's easy to conclude that the chat already exists.
- Pass the request body with `--data` or `--input`. Almost every write method wraps the body in an object: `chat` for `POST /chats`, `message` for `POST /messages`, `task` for `POST /tasks`, `group_tag` for `POST /group_tags`, `user` for `PUT /users/{id}`, `webhook` for bots. `--describe` shows the wrapper; write its path with `{id}`, not with a number. Without the wrapper, `POST /chats` creates the chat but silently adds no members.
- Don't print tokens or bots' incoming webhook URLs in the chat. A bot's token is shown only once, when it's created: save it to a file.

### n8n

- If the user has no n8n, say that it comes as the hosted n8n Cloud or can be installed on their own server, and give the link for installing the Pachca nodes: https://dev.pachca.com/guides/n8n/setup.md. These instructions don't cover installing n8n. If they have an option without n8n, suggest starting with it and coming back to the bot once n8n is there.
- If the user has n8n, ask for access in these words: "Send me your n8n address: the link you open it with in the browser. Don't send the key in the chat. In n8n, open Settings → n8n API → Create an API key and copy the key. Right after that, run the command below in your terminal exactly as it is; you don't need to put anything into it. It saves the copied key to a file and prints nothing. Then write 'key saved'." The command for macOS: `pbpaste > ~/n8n-key.txt`. For another system, pick the matching one.
- Build everything in n8n on the official Pachca nodes, `n8n-nodes-pachca`. Don't use the `HTTP Request` node for Pachca API calls.

### Setup

- Take API methods from https://dev.pachca.com/llms-en.txt, don't rely on memory. The command `npx -y @pachca/cli@latest api <METHOD> <path> --describe` shows a method's schema.
- The Pachca skills cover the call order and error handling for chats, bots and forms: `npx skills add pachca/openapi`. Install them when you need them, without asking the user.
- Before creating anything, check whether the chat and the bot already exist: `GET /search/chats`, `GET /bots`. If they do, ask whether to set them up or create new ones.
- `POST /group_tags` creates an empty tag. `PUT /users/{id}` with `list_tags` assigns it to an employee; it needs the `users:update` scope. The field replaces the whole set of tags: first read the employee's current tags with `GET /users/{id}` and send them together with the new one. While the tag has no members, mentioning it notifies no one.
- If a method returns an error, stop and tell the user in plain words what failed and what you need to continue.
- The messages you post yourself and the ones the bot sends must be easy to read on a screen, without overdoing spacing or emphasis. Make the heading bold and start the text on the next line. Write connected text as one paragraph. Put rules and steps on numbered lines one under another and separate them from the intro with a single empty line. A short message needs no other empty lines. In a card, make the field labels bold and put the fields on consecutive lines. Use bold only for the heading and the field labels. Pachca markup has no lists or tables: the numbers at the start of lines stay plain text. A sample:

  ```text
  **Retro rules**
  On the last day of the sprint a message with questions arrives here. We reply in the thread under it.

  1. Each point is a separate message.
  2. We add 👍 to what is worth discussing.
  3. The facilitator posts the outcomes in one message and pins it.
  ```
- A pin can't be checked through the API: only a successful `POST /messages/{id}/pin` response confirms it.
- If you sent service messages to a chat to check a bot, such as `/start`, delete them: `DELETE /messages/{id}`. Don't delete messages with rules and templates.
- At the end, say what was created, what is left for the user to do by hand and how to check that the use case works.
- To undo the setup: `DELETE /bots/{id}` deletes the bot, `PUT /chats/{id}/archive` sends the chat to the archive.

## How to set up the use case with the user

### 1. Ask the user

Ask these questions in these words:

1. How do you want to run the offboarding checklist? HR posts it from a template in the "Offboarding" chat and departments tick themselves off: it works right away. Or the "HR Assistant" bot runs the checklist with buttons and reminders: that needs n8n. Do you have n8n? If not, or if you're not sure, we'll start with the simple option and add the bot later.
2. Who is the HR specialist and who are the department heads? Send me the names and I'll add them to the chat.
3. Who is responsible for IT, facilities and accounting? These departments sign off on the checklist.
4. If you choose the bot: how does it learn about an offboarding — from 1С:ЗУП, from your HR system, or does HR message the bot?

Check yourself whether the workspace has the "IT", "Facilities" and "Accounting" tags.

### 2. Do it yourself through the Pachca API: the common part

1. Find the `id`s of HR and the team leads: `GET /search/users` or `GET /users`.
2. Find the team tags: `GET /group_tags` with `names`. If the tags don't exist, suggest creating them via `POST /group_tags`, and check the fields with `--describe`.
3. Create the chat: `POST /chats` with `name: "Offboarding"`, `member_ids` and the `group_tag_ids` of the "IT", "Facilities" and "Accounting" tags. If the chat already exists, add the tags via `POST /chats/{id}/group_tags`. Without the tag in the chat, an **@IT** mention won't notify anyone.

### 3. Option A: a template and reactions

1. Post the checklist template to the "Offboarding" chat: `POST /messages`. The template text from the page:

```
@IT @Facilities @Accounting @<manager's nickname> offboarding checklist: <full name> · <department> · last day <date>
☐ Equipment and access — IT
☐ Badge and keys — Facilities
☐ Final pay and paperwork — Accounting
☐ Handover of clients and work — manager
☐ Library and warehouse equipment — Facilities
Once your item is done, react with ✅ and post what you did in the thread
```

2. Pin the template: `POST /messages/{id}/pin`.
3. Suggest posting the team rules: `POST /messages`. The checklist starts on the day the notice comes in. IT revokes access on the evening of the last day. The manager posts the handover as a list in the thread: who got the clients, where the tasks are.

### 4. Options B and C: the "HR Assistant" bot

1. Create the bot: `POST /bots` with `name: "HR Assistant"`, a nickname ending in `_bot` and `events: ["button_click"]`. If HR fills in the card, add `message_new` to `events`, `trigger_on: "commands"` and `commands: ["/offboarding"]`. Save the bot `id` and `access_token` from the response: the handler needs the token, and it's shown once.
2. Add the bot to the chat: `POST /chats/{id}/members` with the bot `id` in `member_ids`.
3. Once the handler has an address, put it in the outgoing webhook: `PUT /bots/{id}` with `outgoing_url` using the personal token, or `PUT /bot/webhook` using the bot token. In n8n, use the Production URL.

### 5. Handler specification

The handler is built in n8n (option B) or in your own code (option C). The code isn't part of this instruction.

- Receives the leaver card: in n8n, with a Webhook or Form Trigger node. If HR fills in the card, on the `/offboarding` command it opens a form via `POST /views/open`.
- Posts the card to the "Offboarding" chat with a "Start offboarding checklist" button.
- On the click, turns the card into a five-line checklist with a "Done" button on each line and messages the owners.
- Receives the `button_click` event. Checks that "Done" was clicked by the line's owner or a member of their tag.
- Stores `user_id` and the click time for each line. Edits the line and posts a message in the thread. Shows a "Closed 3 of 5" counter.
- Notes on the line the handover the manager wrote in the thread.
- On a schedule, the day before the leaving date and at 12:00 on the last day, messages the owners of unclosed lines.
- At 5 of 5, builds a PDF of the checklist and drops the file in the thread.

On the page, option C additionally includes a message to the employee and blocking the employee in Pachca by date through the API.

### 6. Ask the user to do by hand

- For option A: ask HR to copy the template into the chat for every leaver and set a reminder: message menu → Remind me, with the date set to the day before the employee leaves.
- Turn on the bot's incoming webhook for "HR Assistant" and copy the Webhook URL. API responses don't include this address. Paste the address into 1С:ЗУП or the HR system.
- Set up the handler itself in n8n or on your own server and turn on the scheduled run.
- If the tags don't exist and you couldn't set their members, tag the employees: Members → table view → tag icon.

### 7. Check

1. Ask the user to send a test card. A "Start offboarding checklist" button should appear in the chat: `GET /messages` for the "Offboarding" chat.
2. Ask them to click "Done" on one line and check that a message appeared in the thread.

## What the use case can't do

The offboarding checklist is an internal company tool. Final pay and the employment record don't depend on it. For document deadlines, the user checks with their accountant or КЭДО.

## Troubleshooting

- The "Done" button does nothing. The bot's `events` doesn't include `button_click`, the handler is off, or the outgoing webhook has the Test URL instead of the Production URL.
- The reminder never arrived. The team tag isn't in the chat, or the scheduled run is off in the handler. Check the tag's capitalization: "@IT" and "@it" are different tags.
- The PDF is empty or has no names. The handler didn't store `user_id` and the click time for each line.

## Links

- Use case page with the demo and the human instructions: https://pachca.com/en/scenarios/obhodnoy-list
- Granting and revoking access: https://pachca.com/en/scenarios/dostupy-sotrudnikam
- n8n in Pachca: https://pachca.com/en/help-center/integrations/avtomatizacii-v-pachke-s-pomoshchyu-n8n
- Buttons in chat bots: https://pachca.com/en/help-center/integrations/knopki-v-chat-botah
- Outgoing webhooks: https://pachca.com/en/help-center/integrations/ishodyashchie-webhook-kak-nastroit
- Forms: https://pachca.com/en/help-center/integrations/formy
- Tags for developers: https://dev.pachca.com/guides/tags.md
- Buttons in messages: https://dev.pachca.com/guides/buttons.md
- Outgoing webhooks and event types: https://dev.pachca.com/guides/webhook/events.md
