# How to get employees to sign off on documents

> A Pachca use case. HR publishes an order in the "Orders and policies" channel with an "Acknowledged" button. The "HR" bot records the date and time of each click, nudges anyone who hasn't clicked and compiles the acknowledgement sheet.

> This is the Markdown version of https://pachca.com/en/scenarios/oznakomlenie-s-dokumentami 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

1. The handler posts an order card with an "Acknowledged" button and @all in the "Orders and policies" channel.
2. The employee clicks "Acknowledged". The handler records the name, date and time and confirms the acknowledgement with a direct message.
3. An "Acknowledged N of M" line grows under the order, and the list is in the thread.
4. Two days before the deadline, the bot messages anyone who hasn't clicked.
5. At the deadline, or once everyone has clicked, the bot builds a PDF acknowledgement sheet and drops it in the order's thread.

The handler posts the card and counts the clicks. Without a handler, there's a simplified option with a 👀 reaction.

## What you need before you start

- Administrator rights in Pachca.
- Pachca access with the scopes `chats:create`, `chat_members:write`, `bots:write`, `users:read`. The setup and check steps also need `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 collect acknowledgements? HR posts the order in the «Приказы и регламенты» channel and asks people to add 👀: it works right away. Or the «Кадровик» bot posts the order with an acknowledgement button, counts the responses and reminds those who haven't clicked: 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 else posts orders? Send me the names.

If the bot is chosen, find out how HR will pass an order to it: with a command in the chat with the bot or another way. The bot's events depend on it.

### 2. Do it yourself through the Pachca API

1. Collect the `id`s of all employees: `GET /users` with `--all`.
2. Create the channel: `POST /chats` with `name: "Приказы и регламенты"`, `channel: true` and the `member_ids` of all employees. The creator and editors post in the channel, everyone else reads and replies in threads.
3. Make HR and the other people who publish editors of the channel: `PUT /chats/{id}/members/{user_id}` for each. Take the role value from `--describe`.
4. For option A, API setup ends here. For options B and C, create the bot: `POST /bots` with `name: "Кадровик"`, a nickname ending in `_bot` and `events: ["button_click"]`. If HR publishes the order with a command to the bot, add `message_new` to `events`. If the handler's address already exists, set `outgoing_url`. From the response, save the bot's `id` and `access_token`: the token is shown once, and the handler needs it.
5. Add the bot to the channel: `POST /chats/{id}/members` with the bot's `id` in `member_ids`.
6. Once the handler's address exists, set it: `PUT /bots/{id}` with `outgoing_url` using a personal token, or `PUT /bot/webhook` using the bot's token.

### 3. Handler (options B and C)

The handler's code isn't included here. The specification from the page:

- It receives the button click event. If orders are published with a command to the bot, it receives new messages too.
- It posts an order card in the channel: the file, an "Acknowledged" button, an @all mention.
- On an "Acknowledged" click, it saves the `user_id` from the event, the name, the date and the time. It replies to the employee in a direct message that the acknowledgement is recorded.
- It shows an "Acknowledged N of M" counter under the order and the list in the thread.
- Two days before the deadline, it messages anyone who hasn't clicked.
- At the deadline, when everyone has clicked, or on a "Close" button, it builds a PDF: names, the date and time of each click, blank for anyone absent. It drops the file in the order's thread.

Option B in n8n: a Form Trigger with "document, file, deadline" → the Pachca node posts a card with an "Acknowledged" button and @all → a Webhook node receives the button event and writes the name, date and time to a table → a Schedule Trigger two days before the deadline messages anyone missing from the table. On "Close", an HTML node builds the sheet and HTML→PDF drops the file in the thread. The Production URL of the Webhook node goes into the bot.

Option C: your own code following this specification. Help the user write it.

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

- Check on the "Outgoing webhook" tab in the bot's settings that the "Button clicks" event is selected, and "New messages" too if orders are published with a command.
- For option A: publish the order in the channel with the file, the text "Please read by Sep 30 and react with 👀" and @all. Set the reminder as a scheduled message through "Schedule message" in the send settings. Compile the sheet by hand from the list of people who reacted.
- Agree on deadlines with the team: three business days to acknowledge, a reminder two days before, and people on vacation or sick leave catch up when they return.
- Agree with a lawyer on the list of documents that go to КЭДО.

### 5. Check

1. Ask the user to publish a test order. A card with an "Acknowledged" button should appear in the channel: `GET /messages` for the channel.
2. Ask them to click "Acknowledged" and make sure the bot's direct message arrived and the record appeared in the handler's table or logs.

## What the use case can't do

- A button in chat doesn't replace an employee's signature. A recorded date and time is enough for policies and informational orders, if your internal e-interaction policy says so.
- Termination, disciplinary action and local acts at hiring are signed in КЭДО (HR-Link, Kontur.Sign). The bot brings the link to sign and the statuses.

## Troubleshooting

- The "Acknowledged" button doesn't count clicks. "Button clicks" isn't selected in the outgoing webhook, or the handler is off. n8n needs the Production URL.
- An employee didn't get the notification. The channel is muted and the message has no @all. An @all mention gets through muted notifications.
- The sheet is empty. The handler didn't save the `user_id` from the button event. Check the record for the first click in the logs.

## Links

- Use case page with the demo and instructions for a human: https://pachca.com/en/scenarios/oznakomlenie-s-dokumentami
- n8n in Pachca: https://pachca.com/en/help-center/integrations/avtomatizacii-v-pachke-s-pomoshchyu-n8n
- Buttons in chatbots: https://pachca.com/en/help-center/integrations/knopki-v-chat-botah
- Outgoing webhooks: https://pachca.com/en/help-center/integrations/ishodyashchie-webhook-kak-nastroit
- @all mentions: https://pachca.com/en/help-center/features/kak-rabotayut-upominaniya-v-pachke
- Buttons in messages for developers: https://dev.pachca.com/guides/buttons.md
- Outgoing webhooks and event types: https://dev.pachca.com/guides/webhook/events.md
