# Human oversight and approval

Polyant's governance gates automatically return `allow`, `warn` or `block`. The policy assignment determines how the verdict is applied. To add human approval to a workflow, configure the agent to ask a reviewer on a connected channel and wait for a reply before acting.

Use an approval step when a person owns the decision, such as granting an exception to a customer policy.

## How the workflow fits together

The pattern below uses two agents, Slack for the team and an event source that sends the approved answer to the customer:

1. **The user-facing agent** answers the customer on their channel, for example WhatsApp. When a request needs approval, it posts it to the team's Slack channel with `slackPostMessage` and tells the customer that the team has been notified.
2. **A reviewer-side agent** is connected to Slack and to no customer channel. A team member asks it, in Slack, to prepare the answer. It drafts the message and names the recipient by the customer's identifier on their channel, such as the phone number.
3. **A person approves the draft.** In this pattern the answer goes out only after that.
4. **The approval calls a webhook of the user-facing agent**, with the recipient and the approved text in the payload. The webhook's event definition starts a conversation turn and sends the agent's reply on the customer's channel, to the recipient in the payload.

The recipient identifier links the approved answer to the original request. A trigger that sends on a channel uses the conversation keyed by that channel and that recipient, the same one the customer's own messages open. The answer leaves from the agent's own number and appears in the customer's existing chat, and the customer can reply and carry on.

Instead of a reviewer-side agent, a [Room](https://docs.polyant.ai/admin-panel/room) can work with the team: `send_message_to_human` posts on the Room's outbound Slack destination, and a reply there starts a new cycle.

## Set up the user-facing agent

1. In **Channels**, configure the customer's channel and Slack. The Slack configuration is what `slackPostMessage` posts with, whatever channel the conversation came in on. See [Connect a Slack channel](https://docs.polyant.ai/getting-started/connect-a-channel#slack).
2. In **Tools**, enable `slackPostMessage`. It can send the request to a Slack channel or DM a reviewer by user ID. The optional **Slack allowed channels (allowlist)** setting (`slack_allowed_channels`) restricts which destinations the tool can use.
3. In **Prompts**, use `04-safety` to name the action that needs approval, who can approve it, and what to tell the customer while the team decides. In `03-tooling`, specify when to call `slackPostMessage` and what to send: a summary of the request and the customer's identifier on their channel. The agent sees that identifier as the *Channel ID* of the current conversation (see [Prompt](https://docs.polyant.ai/concepts/prompt)).
4. In **Automations → Webhooks**, click **Add** and create an event source, for example *Message from the team*. Copy its **Webhook URL**: it is the address the approval step calls. Under **Event Definitions**, click **Add** and set:
   - **Matching Prompt** - when the definition applies, for example *"The payload carries a message approved by the team, with `phone` and `text`."*
   - **Action** - **Conversation**, so the event starts a turn immediately.
   - **Context Prompt** - the instruction for that turn, with the approved text, for example *"The team approved this message for the customer. Send it as written: {{payload.text}}"*.
   - **Outbound channel** - the customer's channel, for example **WhatsApp**.
   - **Outbound Target** - the recipient taken from the payload, for example `{{payload.phone}}`.

The webhook URL is a credential. To require a secret as well, use **Webhook Authentication** → **Set secret** on the event source; every call must then carry `Authorization: Bearer <secret>`. See [Webhooks (Inbound)](https://docs.polyant.ai/reference/webhooks).

WhatsApp accepts a free-form message only within its customer service window. If approval can arrive later, plan for a pre-approved template sent with `send_whatsapp_template` (see [Channels](https://docs.polyant.ai/admin-panel/channels#whatsapp-via-twilio)).

## Set up the reviewer side

1. Create the reviewer-side agent and configure **Slack** in **Channels** with its own Slack app: fill in **Bot Token** and **Signing Secret**, set the channel to **On** and save. In the Slack app's **Event Subscriptions**, use the **Slack Events API Request URL** shown in Polyant and subscribe to `app_mention` and `message.im`. Invite the bot to the review channel.
2. In **Prompts**, tell it how to prepare an answer for a customer, how to name the recipient, and that it presents the draft for approval before anything is sent.
3. Decide how the approval reaches the webhook. The call is a `POST` of a JSON payload such as `{"phone": "+15555550100", "text": "..."}` to the event source's webhook URL. A button in Slack that posts it on a person's click is an integration Exelab builds in delivery. The reviewer-side agent can also make the call itself with `httpRequest` once the reviewer confirms in Slack, provided the engine's webhook URL is a public address.

## Review the conversation and tool calls

Open **Conversations** to read the customer's exchange: the escalation turn and, after approval, the turn started by the webhook, in the same conversation. Turn on **Show activity** to see the tool calls alongside the messages. The reviewer-side agent's Slack thread is its own conversation.

For a request sent with `slackPostMessage`, open **Monitor → Tools** and inspect the recorded call. The drawer shows the recorded arguments, redacted for this tool, and the result or error, and links to the conversation when available. The agent's **Monitor** section lists the conversations started by a webhook. See [Conversations](https://docs.polyant.ai/admin-panel/conversations), [Monitor](https://docs.polyant.ai/admin-panel/activity) and [Audit logs](https://docs.polyant.ai/admin-panel/audit-logs).

## See also

- [Governance](https://docs.polyant.ai/admin-panel/governance) - the automatic policy gates.
- [Room](https://docs.polyant.ai/admin-panel/room) - proactive cycles and `send_message_to_human`.
- [Webhooks (Inbound)](https://docs.polyant.ai/reference/webhooks) - the event source endpoint.
