<!-- Generated from the canonical 99 Digital API documentation. Do not edit this file. -->

Canonical page: https://docs.99digital.co.il/facebook-api/webhooks/facebook-comment

# Facebook Comment

**Webhook.** Sent to the webhook URL you configure.

Facebook Comment allows you to receive a webhook whenever a comment on your Facebook Page is written, edited, deleted, hidden or unhidden (`event` "comment").

It is sent for a Facebook Pages connection (`facebook_type` 3), to the URL
you set with [Set Webhook](https://docs.99digital.co.il/facebook-api/webhooks/set-webhook) for that
connection. Delivery, retries and duplicates are explained on the
[Webhook Events](https://docs.99digital.co.il/facebook-api/webhooks/webhook-events) page.

The types of comment events (`action`) you can get are:

- **created** — a new comment on a post, or a reply to a comment
  (`parentId` is set on a reply).
- **edited** — the comment's text was changed. `text` is the new text.
- **deleted** — the comment was deleted. `text` is null and there is no
  `textFetched`: the comment no longer exists, so nothing is fetched.
  `actor` says who deleted it.
- **hidden** / **unhidden** — the comment was hidden from the public, or
  made visible again (for example with
  [Hide Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/hide-comment)). `actor` says
  who did it.

**The text of the comment.** Meta's webhook does not include the text of
Facebook comments, only their IDs. So when the event arrives, we fetch the
current text from Facebook, and add `textFetched`:

| `textFetched` | Meaning |
| --- | --- |
| `true` | `text` was fetched from Facebook: the comment's text as it is now (for `edited`, the new text). |
| `false` | We fetched and got no text. Either the comment has no text (for example, a photo only), or Facebook refused or did not answer (for example, the comment was deleted in the meantime). On `created` and `edited`, `text` is then null. On `hidden` and `unhidden` (we always fetch these), `text` may be null. The event is still sent and its IDs are valid: you can read the comment with [All Comments](https://docs.99digital.co.il/facebook-api/facebook-pages/all-comments). |
| (not in the event) | Nothing was fetched: a `deleted` comment (it no longer exists), or a created or edited comment whose text Facebook sent itself. |

**Hidden, unhidden and deleted comments.** Meta reports who hid, unhid or
deleted the comment, not who wrote it. So on these three actions:

- `actor` is who hid, unhid or deleted the comment — usually your own
  Page. A comment can also be deleted by the person who wrote it: then
  `actor` is that person. To know if your Page did it, check `actor.id` =
  `pageId`.
- `author` is the person who wrote the comment. We take it from that
  comment's `created` event, which we received earlier. When we never
  received it (the comment was written before your connection was made,
  more than a year ago, or it was hidden or deleted right after it was
  written — for example hidden by your Page's word filter), `author` is
  null, also when the writer deleted their own comment.
- `fromSelf` refers to the `author` only, never to the `actor`: it is
  `false` when `author` is null.

:::warning
Comments that your own Page writes — also replies you send with
[Create Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/create-comment) — arrive here
too, with `fromSelf` true. **If you reply automatically to comments, skip
every event with `fromSelf` true**, or your bot will answer itself in a
loop.
:::

**Settings:**

| Setting | Value |
| --- | --- |
| URL | Your URL — set it with [Set Webhook](https://docs.99digital.co.il/facebook-api/webhooks/set-webhook) |
| Method | JSON via POST |

**With every Facebook comment event, you will get some of the following:**

```json
{
  "event": "comment",
  "action": "created",
  "eventId": "fbw_4c1e9a7d2b8f30e6a5d9c1b7e2f4a608",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561029384",
  "parentId": null,
  "author": { "id": "8273645190283746", "name": "Dana Cohen" },
  "fromSelf": false,
  "text": "Do you deliver on Fridays?",
  "attachment": null,
  "timestamp": 1795600000,
  "textFetched": true
}
```

### Response explained

| Parameter | Description / Example |
| --- | --- |
| `event` | "comment" always, for comment webhooks. |
| `action` | What happened: "created", "edited", "deleted", "hidden" or "unhidden". |
| `eventId` | The unique ID of this event (`fbw_` and 32 characters). The same event always comes with the same `eventId`, so use it to ignore an event you already received. |
| `platform` | "facebook" always, for Facebook Pages. |
| `from` | The ID of your connection — the `from` you use to call our API. |
| `facebook_type` | 3 always (Facebook Pages). |
| `pageId` | Your Facebook Page ID. |
| `postId` | The post the comment is on. Use it with [All Comments](https://docs.99digital.co.il/facebook-api/facebook-pages/all-comments) or [Create Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/create-comment). |
| `commentId` | The comment ID. Use it with [Create Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/create-comment) (to reply), [Hide Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/hide-comment), [Delete Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/delete-comment), [Like Comment](https://docs.99digital.co.il/facebook-api/facebook-pages/like-comment) and [Private Reply](https://docs.99digital.co.il/facebook-api/facebook-pages/private-reply). |
| `parentId` | On a reply: the comment it answers. null for a comment on the post itself. |
| `author` | Who wrote the comment: `id` and `name` (`name` can be null). null when it is not known. On hidden, unhidden and deleted, see "Hidden, unhidden and deleted comments" above. |
| `actor` | Only on hidden, unhidden and deleted (and always there): who hid, unhid or deleted the comment, `id` and `name` — usually your own Page. |
| `fromSelf` | true when the comment was written by your own Page (the `author`, never the `actor`). |
| `text` | The text of the comment, or null (a deleted comment, a comment without text, or `textFetched` false). |
| `attachment` | When the comment has a photo or a video: `type` ("photo" or "video") and `url`. null otherwise. |
| `timestamp` | When it happened, as Facebook reports it (Unix time in seconds, UTC). For an edit: the time of the edit when Facebook reports it, otherwise the time the comment was written. |
| `textFetched` | Whether we fetched the text from Facebook — see the table above. Not in a `deleted` event. |

## Webhook payload

Content type: `application/json`

| Field | Type | Description |
| --- | --- | --- |
| `event` | string | "comment" always, for comment webhooks. Always `comment`. |
| `action` | string | What happened to the comment. One of: `created` — A new comment on a post, or a reply to a comment; `edited` — The comment's text was changed. `text` is the new text; `deleted` — The comment was deleted. `text` is null and there is no `textFetched`. `actor` says who deleted it; `hidden` — The comment was hidden from the public. `actor` says who hid it; `unhidden` — The comment was made visible again. `actor` says who did it. Example: `created`. |
| `eventId` | string | The unique ID of this event (`fbw_` and 32 characters). The same event always comes with the same `eventId`, so use it to ignore an event you already received. Example: `fbw_4c1e9a7d2b8f30e6a5d9c1b7e2f4a608`. |
| `platform` | string | "facebook" always, for Facebook Pages. Always `facebook`. |
| `from` | string | The ID of your connection — the `from` you use to call our API. Example: `463745743546345`. |
| `facebook_type` | integer | 3 always (Facebook Pages). Always `3`. |
| `pageId` | string | Your Facebook Page ID. Example: `104857362910483`. |
| `postId` | string \| null | The post the comment is on. Use it with All Comments or Create Comment. Example: `104857362910483_122110934857201`. |
| `commentId` | string | The comment ID. Use it with Create Comment (to reply), Hide Comment, Delete Comment, Like Comment and Private Reply. Example: `122110934857201_1093847561029384`. |
| `parentId` | string \| null | On a reply: the comment it answers. null for a comment on the post itself. Example: `null`. |
| `author` | object \| null | Who wrote the comment, or null when it is not known. On hidden, unhidden and deleted it is taken from the comment's `created` event we received earlier, and is null when we never received it. |
| `author.id` | string | The writer's Facebook ID (for your Page, the Page ID). Example: `8273645190283746`. |
| `author.name` | string \| null | The writer's name, or null when Facebook does not give it. Example: `Dana Cohen`. |
| `actor` | object \| null | Only on hidden, unhidden and deleted (and always there): who hid, unhid or deleted the comment — usually your own Page. Check `actor.id` = `pageId` to know if your Page did it. |
| `actor.id` | string | The Facebook ID of who hid, unhid or deleted the comment. Example: `104857362910483`. |
| `actor.name` | string \| null | Their name, or null when Facebook does not give it. Example: `My Flowers Shop`. |
| `fromSelf` | boolean | true when the comment was written by your own Page (the `author`, never the `actor`). false when `author` is null. Example: `false`. |
| `text` | string \| null | The text of the comment, or null (a deleted comment, a comment without text, or `textFetched` false). Example: `Do you deliver on Fridays?`. |
| `attachment` | object \| null | When the comment has a photo or a video: its `type` and `url`. null otherwise. |
| `attachment.type` | string | The kind of media. One of: `photo` — A photo; `video` — A video. |
| `attachment.url` | string | A link to the photo or video on Facebook. |
| `timestamp` | integer | When it happened, as Facebook reports it (Unix time in seconds, UTC). For an edit: the time of the edit when Facebook reports it, otherwise the time the comment was written. Example: `1795600000`. |
| `textFetched` | boolean | true — `text` was fetched from Facebook (the text as it is now). false — we fetched and got no text (a comment without text, or Facebook refused or did not answer): on created and edited `text` is then null, on hidden and unhidden it may be null. The IDs are still valid. Not in a `deleted` event, or when Facebook sent the text itself. Example: `true`. |

### Example: Created

A visitor wrote a comment on one of your posts.

```json
{
  "event": "comment",
  "action": "created",
  "eventId": "fbw_4c1e9a7d2b8f30e6a5d9c1b7e2f4a608",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561029384",
  "parentId": null,
  "author": {
    "id": "8273645190283746",
    "name": "Dana Cohen"
  },
  "fromSelf": false,
  "text": "Do you deliver on Fridays?",
  "attachment": null,
  "timestamp": 1795600000,
  "textFetched": true
}
```

### Example: Reply by your Page

Your Page replied to the comment — `fromSelf` is true. Skip it in a bot that replies automatically.

```json
{
  "event": "comment",
  "action": "created",
  "eventId": "fbw_9d2a6e1c7b3f48a0e5c2d9b6a1f7e304",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561077215",
  "parentId": "122110934857201_1093847561029384",
  "author": {
    "id": "104857362910483",
    "name": "My Flowers Shop"
  },
  "fromSelf": true,
  "text": "Yes, every Friday until 1 PM!",
  "attachment": null,
  "timestamp": 1795600420,
  "textFetched": true
}
```

### Example: Comment with a photo

A comment with a photo and no text — `text` is null and `textFetched` is false.

```json
{
  "event": "comment",
  "action": "created",
  "eventId": "fbw_2b7f0c9e4a1d56b3c8e7f2a9d0b4c615",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561104472",
  "parentId": null,
  "author": {
    "id": "7364519028374651",
    "name": "Yossi Levi"
  },
  "fromSelf": false,
  "text": null,
  "attachment": {
    "type": "photo",
    "url": "https://scontent.example.com/v/comment-photo.jpg"
  },
  "timestamp": 1795601100,
  "textFetched": false
}
```

### Example: Edited

The writer changed the comment's text — `text` is the new text.

```json
{
  "event": "comment",
  "action": "edited",
  "eventId": "fbw_7e3b9a0d5c2f41e8b6a3d0c9f5e2a817",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561029384",
  "parentId": null,
  "author": {
    "id": "8273645190283746",
    "name": "Dana Cohen"
  },
  "fromSelf": false,
  "text": "Do you deliver on Fridays and Saturdays?",
  "attachment": null,
  "timestamp": 1795600900,
  "textFetched": true
}
```

### Example: Hidden

Your Page hid the comment — `actor` is your Page, `author` is who wrote it.

```json
{
  "event": "comment",
  "action": "hidden",
  "eventId": "fbw_0f8c2d6a9e4b37c1a5f0e8d3b9c6a142",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561029384",
  "parentId": null,
  "author": {
    "id": "8273645190283746",
    "name": "Dana Cohen"
  },
  "actor": {
    "id": "104857362910483",
    "name": "My Flowers Shop"
  },
  "fromSelf": false,
  "text": "Do you deliver on Fridays and Saturdays?",
  "attachment": null,
  "timestamp": 1795601500,
  "textFetched": true
}
```

### Example: Unhidden, author unknown

The comment was made visible again. We never saw it being created, so `author` is null and `fromSelf` is false.

```json
{
  "event": "comment",
  "action": "unhidden",
  "eventId": "fbw_6a1d4f9b2e7c50a3d8b1f6e4c0a9d527",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122108475610293",
  "commentId": "122108475610293_2048573619203847",
  "parentId": null,
  "author": null,
  "actor": {
    "id": "104857362910483",
    "name": "My Flowers Shop"
  },
  "fromSelf": false,
  "text": "Great service, thank you!",
  "attachment": null,
  "timestamp": 1795602000,
  "textFetched": true
}
```

### Example: Deleted by your Page

Your Page deleted a visitor's comment — `author` is the visitor who wrote it, `actor` is your Page, and `fromSelf` is false. `text` is null and there is no `textFetched`.

```json
{
  "event": "comment",
  "action": "deleted",
  "eventId": "fbw_3c9e7a2f0d5b48e1c6a9f3d7b2e0c851",
  "platform": "facebook",
  "from": "463745743546345",
  "facebook_type": 3,
  "pageId": "104857362910483",
  "postId": "104857362910483_122110934857201",
  "commentId": "122110934857201_1093847561130958",
  "parentId": null,
  "author": {
    "id": "7364519028374651",
    "name": "Yossi Levi"
  },
  "actor": {
    "id": "104857362910483",
    "name": "My Flowers Shop"
  },
  "fromSelf": false,
  "text": null,
  "attachment": null,
  "timestamp": 1795602600
}
```

## Responses

### 200 — Received. Answer with any 2xx status (200, 201, 204 …) — we wait up to 5 seconds to connect and up to 15 seconds for your answer. The body of your answer is ignored.

### default — Any other status, or no answer in time, counts as a failed delivery. We try again: immediately, then 5 minutes, 20 minutes, 1 hour, 4 hours and 24 hours after the previous failure. After that, the event is not sent again.
