# n8n (/integrations/n8n)

Send new feedback anywhere n8n reaches. A [webhook](/integrations/webhooks/) starts the workflow; the REST API lets it reply to a comment or resolve it. This works on n8n Cloud and on your own n8n, as long as Annoty can reach it over `https://` on a public host.

## Start a workflow from new comments [#start-a-workflow-from-new-comments]

<Steps>

1. In n8n, add a **Webhook** node. Set **HTTP Method** to `POST` and copy its **Test URL**.

2. In the Annoty dashboard, open the project → **Integrations** → **Add** → **Webhook**. Paste the URL, name it "n8n" and pick its events.

3. In n8n, click **Listen for test event**. In Annoty, open the webhook's **⋯** menu → **Send test event**. The sample comment arrives in the Webhook node.

4. Add an **If** node that continues only when `{{ $json.body.test }}` is false, then the nodes for what you want done.

5. Activate the workflow, then in Annoty, **Edit** the webhook and paste the node's **Production URL** in place of the test one. Its URL then reads `/webhook/…` instead of `/webhook-test/…`.

</Steps>

<Callout>
  n8n only listens on the Test URL while you're listening for a test event.
  Deliveries to it fail otherwise; Annoty retries them for about a day, and the
  webhook's page shows what happened under **Deliveries**.
</Callout>

The event is under `body` in the Webhook node's output:

- `body.data.comment.body`: the comment
- `body.data.comment.number`: its pin number
- `body.feedbackSession.label`: the feedback session

[Webhooks](/integrations/webhooks/) lists every event and field, and how to check the signature.

## Reply or resolve from a workflow [#reply-or-resolve-from-a-workflow]

Create an API key in the dashboard (**Settings → API keys**) with **View**, **Reply** and **Resolve** under **Comments**. In n8n, add a **Header Auth** credential with the name `Authorization` and the value `Bearer your_api_key_here`, then an **HTTP Request** node that uses it:

| To      | Method  | URL                                                                                                                                | Body                        |
| ------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------- | --------------------------- |
| Reply   | `POST`  | `https://api.annoty.app/v1/feedback-sessions/{{ $json.body.feedbackSessionId }}/comments/{{ $json.body.data.comment.id }}/replies` | `{"body": "Thanks, on it"}` |
| Resolve | `PATCH` | `https://api.annoty.app/v1/feedback-sessions/{{ $json.body.feedbackSessionId }}/comments/{{ $json.body.data.comment.id }}`         | `{"status": "resolved"}`    |

Send the body as JSON. The reply shows up on the reviewer's page right away, under the key's name.
