---
sidebar:
  hidden: true
title: roboto.domain.comments.comment
---
## Module Contents

### Comment

```python
class roboto.domain.comments.comment.Comment(
    record: roboto.domain.comments.record.CommentRecord,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
)
```

`from roboto import Comment`

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L23-L496)

A comment attached to a Roboto platform entity.

Comments provide a way to add contextual information, feedback, or discussion to various Roboto platform resources including datasets, files, actions, invocations, triggers, and collections. Comments support @mention syntax using the format `@[display_name](user_id)` to notify specific users.

Comments are created through the [`create()`](/reference/python-sdk/roboto/domain/comments/comment#roboto.domain.comments.comment.Comment.create) class method and cannot be instantiated directly. They can be retrieved by entity, entity type, user, or organization using the various class methods provided.

Each comment tracks creation and modification metadata, including timestamps and user information. Comments can be updated or deleted by authorized users.

> **Note**
>
> Comments cannot be instantiated directly through the constructor. Use [`create()`](/reference/python-sdk/roboto/domain/comments/comment#roboto.domain.comments.comment.Comment.create) to create new comments or the various retrieval methods to access existing comments.

**Parameters**

- **record** (`roboto.domain.comments.record.CommentRecord`)
- **roboto_client** (`Optional[roboto.http.RobotoClient]`)

**Properties**

- **Comment.comment_id** (`str`): Unique identifier for this comment.
- **Comment.created** (`datetime.datetime`): Timestamp when the comment was created.
- **Comment.created_by** (`str`): User ID of the comment author.
- **Comment.modified** (`datetime.datetime`): Timestamp when the comment was last modified.
- **Comment.modified_by** (`str`): User ID of the user who last modified this comment.
- **Comment.record** (`roboto.domain.comments.record.CommentRecord`): The underlying CommentRecord data structure.

#### Comment.create()

```python
@classmethod
def create(
    comment_text: str,
    entity_id: str,
    entity_type: roboto.domain.comments.record.CommentEntityType,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
    caller_org_id: Optional[str] = None,
) -> Comment
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L48-L109)

Create a new comment on a Roboto platform entity.

Creates a comment attached to the specified entity. The comment text can include @mention syntax to notify users using the format `@[display_name](user_id)`.

**Parameters**

- **comment_text** (`str`): The text content of the comment. May include @mention syntax to notify users.
- **entity_id** (`str`): Unique identifier of the entity to attach the comment to.
- **entity_type** (`roboto.domain.comments.record.CommentEntityType`): Type of entity being commented on.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.
- **caller_org_id** (`Optional[str]`): Optional organization ID of the caller. If not provided, uses the organization from the client context.

**Returns**

- `Comment`: A new Comment instance representing the created comment.

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to comment on the specified entity.
- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): If the specified entity does not exist.
- [`RobotoIllegalArgumentException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): If the provided arguments are invalid.

**Usage**

```python
from roboto.domain import comments
# Create a comment on a dataset
comment = comments.Comment.create(
    comment_text="This dataset looks good!",
    entity_id="ds_1234567890abcdef",
    entity_type=comments.CommentEntityType.Dataset,
)
print(comment.comment_id)
# cm_abcdef1234567890
```

```python
# Create a comment with user mentions
comment = comments.Comment.create(
    comment_text="@[John Doe](john.doe@example.com) please review this",
    entity_id="fl_9876543210fedcba",
    entity_type=comments.CommentEntityType.File,
)
```

#### Comment.delete_comment()

```python
def delete_comment() -> None
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L438-L456)

Delete this comment permanently.

Removes the comment from the platform. This action cannot be undone. Only the comment author or users with appropriate permissions can delete a comment.

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to delete this comment.
- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): If the comment no longer exists.

**Returns**

- `None`

**Usage**

```python
from roboto.domain import comments
comment = comments.Comment.from_id("cm_1234567890abcdef")
comment.delete_comment()
# # Comment is now permanently deleted
```

#### Comment.for_entity()

```python
@classmethod
def for_entity(
    entity_type: roboto.domain.comments.record.CommentEntityType,
    entity_id: str,
    owner_org_id: Optional[str] = None,
    page_token: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> tuple[collections.abc.Sequence[Comment], Optional[str]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L154-L223)

Retrieve all comments for a specific entity.

Fetches all comments attached to a particular entity, such as a dataset, file, action, invocation, trigger, or collection. Results are paginated and returned in chronological order.

**Parameters**

- **entity_type** (`roboto.domain.comments.record.CommentEntityType`): Type of entity to retrieve comments for.
- **entity_id** (`str`): Unique identifier of the entity.
- **owner_org_id** (`Optional[str]`): Optional organization ID that owns the entity. If not provided, uses the organization from the client context.
- **page_token** (`Optional[str]`): Optional pagination token to retrieve the next page of results. Use None to start from the beginning.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.

**Returns**

- `tuple[collections.abc.Sequence[Comment], Optional[str]]`: A tuple containing:

  - A sequence of Comment instances for the entity
  - An optional pagination token for the next page, or None if no more pages are available

**Raises**

- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): If the entity does not exist.
- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to access the entity or its comments.

**Usage**

```python
from roboto.domain import comments
# Get all comments for a dataset
comments_list, next_token = comments.Comment.for_entity(
    entity_type=comments.CommentEntityType.Dataset, entity_id="ds_1234567890abcdef"
)
print(f"Found {len(comments_list)} comments")
# Found 5 comments
```

```python
# Paginate through comments
all_comments = []
page_token = None
while True:
    comments_page, page_token = comments.Comment.for_entity(
        entity_type=comments.CommentEntityType.File,
        entity_id="fl_9876543210fedcba",
        page_token=page_token,
    )
    all_comments.extend(comments_page)
    if page_token is None:
        break
```

#### Comment.for_entity_type()

```python
@classmethod
def for_entity_type(
    entity_type: roboto.domain.comments.record.CommentEntityType,
    owner_org_id: Optional[str] = None,
    page_token: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> tuple[collections.abc.Sequence[Comment], Optional[str]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L226-L285)

Retrieve all comments for a specific entity type.

Fetches all comments attached to entities of a particular type within an organization. For example, retrieve all comments on datasets or all comments on files. Results are paginated and returned in chronological order.

**Parameters**

- **entity_type** (`roboto.domain.comments.record.CommentEntityType`): Type of entities to retrieve comments for.
- **owner_org_id** (`Optional[str]`): Optional organization ID to scope the search to. If not provided, uses the organization from the client context.
- **page_token** (`Optional[str]`): Optional pagination token to retrieve the next page of results. Use None to start from the beginning.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.

**Returns**

- `tuple[collections.abc.Sequence[Comment], Optional[str]]`: A tuple containing:

  - A sequence of Comment instances for the entity type
  - An optional pagination token for the next page, or None if no more pages are available

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to access comments for the specified entity type.

**Usage**

```python
from roboto.domain import comments
# Get all comments on datasets in the organization
dataset_comments, next_token = comments.Comment.for_entity_type(
    entity_type=comments.CommentEntityType.Dataset
)
print(f"Found {len(dataset_comments)} dataset comments")
# Found 12 dataset comments
```

```python
# Get all comments on action invocations
invocation_comments, _ = comments.Comment.for_entity_type(
    entity_type=comments.CommentEntityType.Invocation, owner_org_id="og_1234567890abcdef"
)
```

#### Comment.for_user()

```python
@classmethod
def for_user(
    user_id: str,
    owner_org_id: Optional[str] = None,
    page_token: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> tuple[collections.abc.Sequence[Comment], Optional[str]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L288-L344)

Retrieve all comments created by a specific user.

Fetches all comments authored by the specified user within an organization. Results are paginated and returned in chronological order.

**Parameters**

- **user_id** (`str`): Unique identifier of the user whose comments to retrieve.
- **owner_org_id** (`Optional[str]`): Optional organization ID to scope the search to. If not provided, uses the organization from the client context.
- **page_token** (`Optional[str]`): Optional pagination token to retrieve the next page of results. Use None to start from the beginning.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.

**Returns**

- `tuple[collections.abc.Sequence[Comment], Optional[str]]`: A tuple containing:

  - A sequence of Comment instances created by the user
  - An optional pagination token for the next page, or None if no more pages are available

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to access comments by the specified user.

**Usage**

```python
from roboto.domain import comments
# Get all comments by a specific user
user_comments, next_token = comments.Comment.for_user(user_id="john.doe@example.com")
print(f"User has created {len(user_comments)} comments")
# User has created 8 comments
```

```python
# Get comments by user in a specific organization
org_user_comments, _ = comments.Comment.for_user(
    user_id="jane.smith@example.com", owner_org_id="og_1234567890abcdef"
)
```

#### Comment.from_id()

```python
@classmethod
def from_id(
    comment_id: str,
    owner_org_id: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> Comment
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L112-L151)

Retrieve a comment by its unique identifier.

Fetches a specific comment using its comment ID. The caller must have permission to access the comment and its associated entity.

**Parameters**

- **comment_id** (`str`): Unique identifier of the comment to retrieve.
- **owner_org_id** (`Optional[str]`): Optional organization ID that owns the comment. If not provided, uses the organization from the client context.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.

**Returns**

- `Comment`: A Comment instance representing the retrieved comment.

**Raises**

- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): If the comment does not exist or the caller lacks permission to access it.
- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to access the comment.

**Usage**

```python
from roboto.domain import comments
# Retrieve a specific comment
comment = comments.Comment.from_id("cm_1234567890abcdef")
print(comment.record.comment_text)
# This is the comment text
```

```python
# Retrieve a comment from a specific organization
comment = comments.Comment.from_id(comment_id="cm_abcdef1234567890", owner_org_id="og_fedcba0987654321")
```

#### Comment.recent_for_org()

```python
@classmethod
def recent_for_org(
    owner_org_id: Optional[str] = None,
    page_token: Optional[str] = None,
    roboto_client: Optional[roboto.http.RobotoClient] = None,
) -> tuple[collections.abc.Sequence[Comment], Optional[str]]
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L347-L399)

Retrieve recent comments for an organization.

Fetches the most recently created or modified comments within an organization, across all entity types. Results are paginated and returned in reverse chronological order (most recent first).

**Parameters**

- **owner_org_id** (`Optional[str]`): Optional organization ID to retrieve comments for. If not provided, uses the organization from the client context.
- **page_token** (`Optional[str]`): Optional pagination token to retrieve the next page of results. Use None to start from the beginning.
- **roboto_client** (`Optional[roboto.http.RobotoClient]`): Optional Roboto client instance. If not provided, uses the default client.

**Returns**

- `tuple[collections.abc.Sequence[Comment], Optional[str]]`: A tuple containing:

  - A sequence of Comment instances ordered by recency
  - An optional pagination token for the next page, or None if no more pages are available

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to access comments in the organization.

**Usage**

```python
from roboto.domain import comments
# Get recent comments in the organization
recent_comments, next_token = comments.Comment.recent_for_org()
print(f"Found {len(recent_comments)} recent comments")
# Found 10 recent comments
```

```python
# Get recent comments for a specific organization
org_comments, _ = comments.Comment.recent_for_org(owner_org_id="og_1234567890abcdef")
if org_comments:
    print(f"Most recent comment: {org_comments[0].record.comment_text}")
```

#### Comment.update_comment()

```python
def update_comment(comment_text: str) -> Comment
```

[Source](https://github.com/roboto-ai/roboto-python-sdk/blob/main/src/roboto/domain/comments/comment.py#L458-L496)

Update the text content of this comment.

Modifies the comment text and updates the modification timestamp. The updated comment text can include @mention syntax to notify users. Only the comment author or users with appropriate permissions can update a comment.

**Parameters**

- **comment_text** (`str`): New text content for the comment. May include @mention syntax to notify users.

**Returns**

- `Comment`: This Comment instance with updated content.

**Raises**

- [`RobotoUnauthorizedException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoUnauthorizedException): If the user lacks permission to update this comment.
- [`RobotoNotFoundException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoNotFoundException): If the comment no longer exists.
- [`RobotoIllegalArgumentException`](/reference/python-sdk/roboto/exceptions/domain#roboto.exceptions.domain.RobotoIllegalArgumentException): If the comment text is invalid.

**Usage**

```python
from roboto.domain import comments
comment = comments.Comment.from_id("cm_1234567890abcdef")
updated_comment = comment.update_comment("Updated text content")
print(updated_comment.record.comment_text)
# Updated text content
```

```python
# Update with mentions
comment.update_comment("@[Jane Doe](jane.doe@example.com) please check this")
```
