createComment( )
Creates a new comment.
Description
The appId
, contextId
, and resourceId
are all required and associate the created comment with the specific
resource it responds to. See Integrations for a list of integrated scopes for these fields.
If the created comment is a direct response to another comment, the commentId
of the parent comment should be passed
as parentComment.id
in this comment's request. See Terminology for additional information on parent comments and replies.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function createComment(comment: Comment): Promise<Comment>
createComment Parameters
NAME
TYPE
DESCRIPTION
Comment to create.
Returns
Created comment.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the comment was created.
Comment ID.
Date and time the comment was last updated.
ID of the app that the comment is added to.
Comment's author.
Published comment content.
ID of the specific context the comment is in response to.
Within some Wix apps, the contextId
will be the same as the resourceId
. For example in Wix Forum,
the forumPostId
is used as both the contextId
and the resourceId
.
Reserved for internal use.
Whether the comment is marked.
Parent comment information.
See Terminology for more information about parent comments.
Comment rating.
Summary of reactions.
Amount of comments that reply to this comment.
ID of the specific resource that the comment is in response to.
Within some Wix apps, the resourceId
will be the same as the contextId
. For example in Wix Forum,
the forumPostId
is used as both the resourceId
and the contextId
.
Revision number, which increments by 1 each time the comment is updated.
To prevent conflicting changes, the current revision
must be passed when updating the comment.
Comment status.
Supported values:
"PUBLISHED"
: This comment is published and publicly visible."DELETED"
: This comment is deleted."PENDING"
: This comment is pending moderation. Moderation is not currently supported."HIDDEN"
: This comment has been hidden by a site moderator.
Summary of votes.
Was this helpful?
createComment example
1import { comments } from 'wix-comments.v2';23 async function createComment(comment, options) {4 try {5 const result = await comments.createComment(comment, options);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13