Loudvoice API \ Comments \ Create a comment

Resource/URI - Discussions GET POST PUT DELETE
Discussions /loudvoice/discussions.json List all discussions Create a discussion
Discussion /loudvoice/discussions/<discussion_token>.json /loudvoice/discussions/discussion.json?
discussion_reference=<discussion_reference>
Read a discussion Update a discussion Delete a discussion
Discussion messages /loudvoice/comments/<discussion_token>/comments.json /loudvoice/discussions/discussion/comments.json?
discussion_reference=<discussion_reference>
Read discussion comments
Resource/URI - Authors GET POST PUT DELETE
Authors /loudvoice/authors.json List all authors Create an author
Author /loudvoice/authors/<author_token>.json /loudvoice/authors/author.json?
author_reference=<author_reference>
Read an author Update an author Delete an author
Resource/URI - Author Sessions GET POST PUT DELETE
Author Sessions /loudvoice/authors/sessions.json Create/Update a session
Author Session /loudvoice/authors/sessions/<session_token>.json Delete a session
Resource/URI - Comments GET POST PUT DELETE
Comments /loudvoice/comments.json List all comments Create a comment
Comment /loudvoice/comments/<comment_token>.json Read a comment Update a comment Delete a comment

Workflow

Request: the code to send to the API

Send a POST request with the data below to the endpoint /loudvoice/comments.json to create a new comment.

POST data that can be included in the request

{
    "request":{
        "do_moderation": "#do_moderation#",
        "comment":{
            "comment_reference": "#comment_reference#",
            "parent_comment_token": "#parent_comment_token#",            
            "parent_comment_reference": "#parent_comment_reference#",   
            "text": "#text#",
            "ip_address": "#ip_address#",
            "has_been_approved": #has_been_approved#,
            "is_spam": #is_spam#,
            "is_trashed": #is_trashed#,
            "author": {
                "author_token": "#author_token#",
                "author_reference": "#author_reference#"                
            },
            "discussion":{
                "discussion_token": "#discussion_token#",
                "discussion_reference": "#discussion_reference#"                
            }
        }
    }
}
Key Description
do_moderation
boolean
If enabled, the value for has_been_approved will be set based on the settings in your OneAll account and trying to create a comment that contains blacklisted keywords will return an error.
Default: false
Reference
comment_reference
string
Your custom reference for this comment.
This value is unique amongst all comments of the same discussion.
Example: POST-1234
Comment Parent
Optionally use one of these fields to indicate the parent comment.
parent_comment_token
string, uuid-v4
The comment_token of and existing comment.
Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d
parent_comment_reference
string
The comment_reference of and existing comment.
Example: POST-1234
Comment Metadata
* text
string
The comment contents.
Example: Hello world! This is my first comment.
ip_address
string, IPv4
The IP address that was used to publish the comment.
Example: 127.0.0.1
has_been_approved
boolean
Indicates whether the comment has been approved or not. The LoudVoice widget displays comments that have not been approved only to it's author.
Default: true
is_spam
boolean
Indicates whether the comment has been flagged as spam or not. The LoudVoice widget does not display comments that have been flagged as spam.
Default: false
is_trashed
boolean
Indicates whether the comment has been trashed or not. The LoudVoice widget does not display comments that have been trashed.
Default: false
* Comment Author
One of these fields is required to indicate the comment author.
author_token
string, uuid-v4
The token indicating the author of the comment.
Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d
author_reference
string
Your custom reference indicating the author of the comment.
Example: USER-1234
* Comment Discussion
One of these fields is required to indicate the discussion the comment is part of.
discussion_token
string, uuid-v4
The token indicating the discussion the comment is part of.
Example: f7cab4f8-43ae-4e1a-97e8-63e22f94923d
discussion_reference
string
Your custom reference indicating the discussion the comment is part of.
Example: PAGE-1234

Result: the code returned by the API

The API will either return a HTTP status code 201 if the comment was created or an appropriate message body with further details on the error that occured.

Resultset Example

{
  "response": {
    "request": {
      "date": "Fri, 01 Apr 2018 11:30:02  0200",
      "resource": "/loudvoice/comments.json",
      "status": {
        "flag": "created",
        "code": 201,
        "info": "Your request has been processed successfully and resulted in a new resource being created"
      }
    },
    "result": {
      "data": {
        "comment": {
            "comment_token": "919c030f-c63b-4f64-8a89-8eff90bcbc86",
            "comment_reference": "COMMENT-ABC123",
            "parent_comment_token": null,
            "parent_comment_reference": null,
            "date_creation": "Fri, 01 Apr 2018 11:30:02  0200",
            "date_last_update": null,
            "post_order": 39,
            "has_been_approved": true,
            "is_spam": false,
            "is_trashed": false,
            "ip_address": "127.0.0.1",
            "text": "Hello World! This is my first comment.",
            "votes": {
              "num_votes_up": 0,
              "num_votes_down": 0,
              "date_last_vote": null
            },
            "reports": {
              "num_reports": 0,
              "date_last_report": null
            },
            "author": {
              "author_token": "71e944f8-394e-4808-9c00-163928c59ba8",
              "author_reference": "USER-46435",
              "name": "John Smith",
              "email": "john-smith@example.com",
              "description": null,
              "picture_url": "https://www.example.com/john-smith/avatar.png",
              "website_url": "https://www.example.com/john-smith/",
              "num_comments": 13,
              "date_last_comment": "Fri, 01 Apr 2018 11:30:02  0200",
              "date_creation": "Tue, 27 Mar 2018 11:19:52  0200",
              "date_last_update": "Fri, 01 Apr 2018 11:30:02  0200"
            },
            "discussion":{
              "discussion_token": "b0ad71f8-0323-486c-916f-0c3f767f6174",
              "discussion_reference": "PAGE-32423",
              "date_creation": "Tue, 27 Mar 2018 10:58:21  0200",
              "title": "Loudvoice Documentation",
              "url":"http:s//docs.oneall.com/",
              "is_closed": false,
              "is_trashed": false,
              "num_comments": 39,
              "date_last_comment": "Fri, 01 Apr 2018 11:30:02  0200",
              "date_last_update": "Tue, 27 Mar 2018 10:58:24  0200"
           }
        }
      }
    }
  }
}    

User Contributed Notes