# Webhooks

answerable can post to your URL when tickets change, or when help center articles go live, so your tools hear about them without asking. Add answerable to a Slack channel to get messages with buttons, or paste a Slack incoming webhook for plain messages; any other URL receives signed JSON.

## Slack

Admins choose **Add a webhook → Add to Slack** under **Integrations → Webhooks**, pick a channel in Slack, and allow answerable. Tickets that need attention show up in the channel with one green button for the likely next step, and the other actions under **⋯**:

- **Review and send** opens the reply answerable proposed, under the customer's latest message, to edit and send. It's the green button when a reply waits for approval.
- **Mark spam** is the green button when answerable thinks a message is spam; **Not spam** is under ⋯.
- **Assign to me** is the green button otherwise. **Mark spam** and **Close** are under ⋯.
- A closed ticket shows **Reopen**, and one marked as spam **Not spam**.

After a tap, the message says who did what, for everyone in the channel. The first time someone taps, answerable asks them to connect their Slack account to their answerable account, once. Their taps then act as them: with their access, in the workspaces they connected, and shown as "via Slack" in the ticket's history. They can disconnect it under **Your account → Connected apps**; leaving the workspace ends it too.

A pasted incoming webhook URL still works, without buttons.

## Setting up

Admins add webhooks under **Integrations → Webhooks**, with the URL and the events it gets. A workspace can have up to 10. The URL must be `https` and reachable from the internet. **Send test** posts a `webhook.test` event right away.

Each webhook lists its latest deliveries, and its switch pauses and resumes it.

## Events

| Event | In settings | Sent when |
| --- | --- | --- |
| `ticket.needs_attention` | Needs attention | A ticket starts waiting for a person: a reply to approve, a handoff, a failed investigation, or a reply that wasn't delivered. |
| `ticket.answered` | Answered by the agent | The agent replied on its own, and resolved the ticket or asked the customer something. |
| `message.received` | Customer wrote | A customer's message arrives, new ticket or reply, before the agent looks at it. Spam and automatic email are left out. |
| `message.sent` | Reply sent | A reply goes out to the customer, from the agent, a teammate, or an app. |
| `message.failed` | Reply not delivered | A reply to a customer couldn't be sent, or bounced. |
| `article.published` | Article published | A help center article goes live, for the first time or with changes. |
| `article.unpublished` | Article taken down | A help center article is unpublished, or deleted while it was live. |

Events come in three groups:

- **Ticket events** say what the agent decided, for people to follow: `ticket.needs_attention` when a ticket starts waiting for someone, and `ticket.answered` when the agent replied on its own. Each customer message sets off one of them at most. There's no event for a new ticket: the event about its first message has `new: true`.
- **Message events** report every message in and out, for apps that keep their own copy: `message.received`, `message.sent`, and `message.failed`.
- **Help center events** say what's live on the help center, for keeping a copy of it elsewhere: `article.published` when an article goes live, for the first time or with changes, and `article.unpublished` when it's taken off, or deleted while it was live.

A moment can belong to more than one group. A reply that bounces sends `message.failed`, and `ticket.needs_attention` too when the ticket goes back to the team. So a destination usually takes one group. Slack webhooks take ticket events only.

New webhooks get `ticket.needs_attention` until you choose others. Replies held back in test mode aren't sent, so they don't send `message.sent`.

The [OpenAPI description](https://staging.preview.answerable.co/docs/developers/api.md) describes every event's payload under `webhooks`.

## Payload

```json
{
  "type": "ticket.needs_attention",
  "timestamp": "2026-10-16T09:30:00.000Z",
  "data": {
    "workspace": "acme",
    "ticket": {
      "number": 42,
      "subject": "Can't export my report as a PDF",
      "url": "https://staging.preview.answerable.co/acme/inbox?view=all&ticket=42",
      "state": "Awaiting approval",
      "type": "Technical problems",
      "customer": "Pat Lee",
      "summary": "Exporting a 90-page report to PDF times out.",
      "new": true,
      "revision": 1,
      "status": "OPEN",
      "waiting": { "kind": "APPROVAL", "reason": null },
      "assignee": null,
      "apiUrl": "https://staging.preview.answerable.co/api/v1/workspaces/acme/tickets/42"
    }
  }
}
```

| Field | Meaning |
| --- | --- |
| `type` | The event: `ticket.needs_attention`, `ticket.answered`, `message.received`, `message.sent`, `message.failed`, `article.published`, `article.unpublished`, or `webhook.test` |
| `timestamp` | When it happened, in ISO 8601 |
| `data.workspace` | The workspace's address |
| `data.ticket.number` | The ticket's number |
| `data.ticket.subject` | Its subject |
| `data.ticket.url` | The ticket in answerable |
| `data.ticket.state` | Where it stands, as the inbox shows it: "Awaiting approval", "Needs a person"… |
| `data.ticket.type` | Its type, such as "Billing and subscriptions", or `null` when it has none |
| `data.ticket.customer` | The customer's name, or their address when there's no name |
| `data.ticket.summary` | The agent's one-line summary, or why the ticket needs a person, or `null` |
| `data.ticket.new` | `true` when the event is about the ticket's first message |
| `data.ticket.revision` | Increases with each customer message; pass it when replying through the [API](https://staging.preview.answerable.co/docs/developers/api.md) |
| `data.ticket.status` | `OPEN`, `WAITING` (on the customer), or `CLOSED` |
| `data.ticket.waiting` | What it waits on a person for (`APPROVAL`, `PERSON`, `SPAM_REVIEW`, or `FAILED`) and why, or `null` |
| `data.ticket.assignee` | The teammate it's assigned to (`name`, `email`), or `null` |
| `data.ticket.apiUrl` | The ticket in the REST API, to read it with a key |
| `data.message` | For message events: the message's `id`, `channel` (`EMAIL`, `WIDGET`, or `API`), `sentAt`; for `message.sent`, the `author` ("answerable's agent", or a teammate and the app they used); for `message.failed`, the `error` |
| `data.article` | For help center events, in place of `data.ticket`: the article's `id`, `title`, `category` (or `null`), `url` on the help site (`null` when it's not on it), and `apiUrl`, to read its text with the [API](https://staging.preview.answerable.co/docs/developers/api.md) |

A payload never includes what the customer wrote: read the ticket through the API for that. A test has only `type`, `timestamp`, and `data.workspace`.

## Verifying signatures

Each webhook has a signing secret, shown in its settings (`whsec_…`). answerable signs every delivery the [Standard Webhooks](https://www.standardwebhooks.com) way, like the requests it sends to [your product](https://staging.preview.answerable.co/docs/integrations/your-product.md), with three headers:

```http
webhook-id: 019a0c8e-5b3e-7c41-9a2f-3d6b1e0f4a27
webhook-timestamp: 1792143000
webhook-signature: v1,K5oZfzN95Z9UVu1EsfQmfVNQhnkZ2pj9o9NDN/H/pI4=
```

To check a delivery:

1. Take the secret after `whsec_` and base64-decode it: that's the key.
2. Compute HMAC-SHA256 over `"<webhook-id>.<webhook-timestamp>.<raw request body>"` with the key, and base64-encode it.
3. Compare it, in constant time, with the part after `v1,` in `webhook-signature`.
4. Reject timestamps more than 5 minutes from now.

With a library (`npm install standardwebhooks`):

```js
import { Webhook } from "standardwebhooks";

const wh = new Webhook(process.env.ANSWERABLE_WEBHOOK_SECRET); // "whsec_…"

export async function POST(request) {
  const body = await request.text(); // the raw body, before parsing
  try {
    wh.verify(body, Object.fromEntries(request.headers));
  } catch {
    return new Response("Invalid signature", { status: 401 });
  }
  const event = JSON.parse(body);
  if (event.type === "ticket.needs_attention") {
    // Tell someone about event.data.ticket.
  }
  return new Response(null, { status: 204 });
}
```

## Delivery and retries

- Deliveries are `POST` requests with `Content-Type: application/json` and `User-Agent: answerable-webhooks/1.0`.
- Answer with a `2xx` status within 10 seconds. A redirect counts as a failure, so answer at the URL you gave.
- A failed delivery is tried again after 1 minute, 5 minutes, 30 minutes, 2 hours, 6 hours, and 12 hours. If it still fails, about a day after the first try, the webhook is paused and its waiting deliveries are cancelled until someone resumes it.
- `webhook-id` stays the same when a delivery is retried, so you can use it to skip one you already handled.
- **Integrations → Webhooks** shows each webhook's 10 latest deliveries. Deliveries are kept for 30 days.

## Slack incoming webhooks

A Slack incoming webhook (`https://hooks.slack.com/services/…`) gets a message in Slack's format instead of JSON, laid out to scan down a channel: the ticket's subject as a bold link, a small line with where it stands ("Needs a person", "Resolved by the agent"), "New ticket" for a first message, and who wrote, then the agent's summary. Slack webhooks take ticket events only. Slack doesn't check signatures, so its secret isn't shown.
