HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket


In the Optimizely Community API, a comment is represented with the `Comment` class.

An instance of the `Comment` class is constructed with:

  • `Author` – The user submitting the comment, identified with an instance of the Reference class. If an empty Reference is provided, the author is assumed to be anonymous.

  • `Body` – The content of the comment, represented as a string

  • `Parent` – The entity to which the comment is related, identified with an instance of the Reference class. This parent may identify a resource, such as content or a product in your application, or another comment.

  • `IsVisible` – Indicates whether this comment is intended to be presented within the application, represented as a Boolean.

An instance of the `Comment` class, contributed by an anonymous user, can be constructed as shown below:



An instance of the `Comment` class, contributed by a known user, can be constructed as shown below:



If an instance of a comment is intended to be a reply to an existing comment, it can be constructed as shown below:



### Parents and ancestors

Comments are hierarchical in nature, so share relationships with resources and other comments.



A comment has a parental relationship. The parent of a comment is the entity to which the comment replies. That entity may be a resource, such as content or a product, or another comment. In the diagram above:

  • The parent of _Comment 1_ is _Resource_.

  • The parent of _Comment 3a_ is _Comment 3_.

A comment also has ancestral relationships. A comment's ancestor is any entity appearing in the comment's hierarchical lineage. As with the parental relationship, ancestors may include a resource, such as content or a product, and other comments.

In the diagram above:

  • The ancestors of _Comment 1a_ include _Resource_ and _Comment 1_. Conversely, _Comment 1a_ may be referred to as a descendant of _Resource_ and _Comment 1_.

  • The ancestors of _Comment 3_ include only _Resource_.

The Optimizely Community API supports the retrieval of comments according to parent and ancestral relationships. For more information on retrieving comments, _Retrieving a Comment_ in [Managing comments](🔗).

### Identify the parent of a comment

The parent of a comment may identify one of two things:

  • A resource, such as content or a product in your application

  • Another comment

A comment that is directly attributed to a particular application resource identifies that resource as its parent. In such a case, an instance of the Reference class is constructed to identify that resource and is specified through the Comment class's constructor. (For more information about references, see _References and IDs_ in [Discovering the platform](🔗).

A comment that represents a reply to an existing comment identifies the original comment as its parent. In these cases, an instance of the Reference class is constructed with the ID of the parent comment and specified through the `Comment` class's constructor.