Picture of the author

Notion Comments

Fetch Notion Comments

List Comments from Blocks or Pages

Comments can be retreived from a block or a page.

$comments = Notion::comments()->ofBlock('cbf6b0af6eaa45ca97159fa147ef6b17');

$commentsAsCollection = $comments->asCollection();
$commentsAsJsonString = $comments->asJson();

Comment Information

The comments id and discussion_id can be accessed by getters.

$comment->getId();
$comment->getDiscussionId();

Comment Text

To access the comments content as simple text, the getText() method can be used. For the RichText::class of the content, the getRichText() can be used.

$comment->getText();
$comment->getRichText();

Raw Comment

This is an example of a Notion comment raw structure. Please check Handling Results on how to retreive raw data.

{
  "object": "comment",
  "id": "94cc56ab-9f02-409d-9f99-1037e9fe502f",
  "parent": {
    "type": "page_id",
    "page_id": "5c6a2821-6bb1-4a7e-b6e1-c50111515c3d"
  },
  "discussion_id": "f1407351-36f5-4c49-a13c-49f8ba11776d",
  "created_time": "2022-07-15T16:52:00.000Z",
  "last_edited_time": "2022-07-15T19:16:00.000Z",
  "created_by": {
    "object": "user",
    "id": "9b15170a-9941-4297-8ee6-83fa7649a87a"
  },
  "rich_text": [
    {
      "type": "text",
      "text": {
        "content": "Single comment",
        "link": null
      },
      "annotations": {
        "bold": false,
        "italic": false,
        "strikethrough": false,
        "underline": false,
        "code": false,
        "color": "default"
      },
      "plain_text": "Single comment",
      "href": null
    }
  ]
}

Source: Example from Notion API Docs (in parts) ( Retrieve a comment )

List Comments by Discussion

Not supported by Notion

At the moment, Notion does not provide a way to list comments by its discussion_id. You can only list comments by block_id.

Previous
Add Blocks