> Index of all Nori docs pages for agents: https://docs.noriagentic.com/llms.txt · Ask a question: https://noriagentic.com/ask

# How to trigger a coding agent from a webhook with an approval step

Create a **From a webhook** automation delivered to a **Slack thread**, and write its instructions in two phases: investigate and post a plan, then stop. The run’s thread stays open to your team, so the agent continues only when a person replies “approved” there. Pull request review and branch protection add a second gate before anything merges.

The approval step for each run is a reply in its Slack thread from someone your [Slack inbound access](https://docs.noriagentic.com/sessions/concepts/security-and-credentials/) lets drive the agent. Nori also gates with admin approval is the automation itself: a member’s new automation, or a change to one, waits under **Review requests** until an admin approves it.

## Prerequisites

- A system that can send an HTTP POST with a JSON body: CI, Sentry, Grafana, Alertmanager, a form, or your own service.
- The [Nori Slack app](https://docs.noriagentic.com/sessions/guides/slack/) installed, the bot in the approval channel (for example `#deploy-approvals`), and that channel’s ID.
- The [GitHub App](https://docs.noriagentic.com/sessions/guides/github/) and your repositories under **Settings → Environment**, if the agent will change code.
- Branch protection on `main` that requires a review, so the agent’s pull requests cannot merge themselves.

## Steps

1. Open **Automations** → **New automation**, name it, and under **Starts when** choose **From a webhook**.
2. Write two-phase **Instructions** (see the example): phase one is read-only and ends with a plan; phase two runs only after a reply that says “approved”.
3. Under **Deliver to**, choose **Slack thread** and enter the channel ID. Keep **Channel post** on **Standard header** so the plan stays in the thread.
4. Save. Members see **Submit for approval**; the automation starts working once an admin approves it.
5. Open the automation and use **Copy webhook URL** (`https://<org>.norisessions.com/api/webhook/<automation-id>`). Treat it as a secret: anyone with it can start a run.
6. Configure your system to POST JSON to that URL. Nori appends the payload (up to 1 MB) to the instructions and marks it as untrusted data, so text inside the payload is not treated as a request.
7. When a run posts its plan, a person replies in the thread: `approved`, or new constraints. Plain thread replies reach the agent without a mention, unless your org uses [tag-only reply mode](https://docs.noriagentic.com/sessions/guides/slack/#conversation-reply-mode).

## Example

Instructions:

```text
A webhook fired; the payload is attached.

Phase 1 (read-only): work out what the payload asks for, inspect the
relevant repository, and post a short plan: what you would change, which
files, and the risk. Change nothing, push nothing, open nothing. End with
"Reply approved to proceed." and stop.

Phase 2: only after someone replies "approved" in this thread, carry out the
plan on a new branch, run the tests, and open a pull request. Never merge.
If the reply asks for changes, revise the plan and wait again.
```

A test delivery:

```bash
curl -X POST "https://<org>.norisessions.com/api/webhook/<automation-id>" \
  -H "Content-Type: application/json" \
  -d '{"service":"checkout","event":"error_rate_high","threshold":"5%"}'
```

The call answers with `{ "ok": true, "firingId": ... }` once the run is queued.

## Verify it works

1. Send the test delivery above, or choose **Run now** and paste a payload into **Optional JSON payload**.
2. A thread opens in the channel with the automation header, then the agent’s plan. Confirm that no branch or pull request exists yet.
3. Reply `approved`. The agent continues in the same session and posts the pull request link.
4. Check the automation’s **Recent activity** for the run and **Latest webhook payload**.

For delivery limits, retries, and running each firing in an existing thread, see [automations](https://docs.noriagentic.com/sessions/guides/triggers/).
