Comment

You can use this API for managing various behaviour of comment

Post comment

verb: POST /api/v2.1/rest/post_comment

request:

user_id [string]
room_id [string], it can be room_id or room unique id specified by client or auto generated by server
message [string]
type [string, default=text]
payload [string json, optional, see payload definitions bellow]
extras [string json]

request example of post comment with default type (text) :

{
  "user_id": "[email protected]",
  "room_id": "457",
  "message": "this is new message"
}'

response :

{
  "results": {
    "comment": {
      "message": "this is new message",
      "payload": null,
      "timestamp": "2018-03-12T08:11:31Z",
      "type": "text",
      "user": {
        "avatar_url": "http://myimage.com/image.jpg",
        "user_id": "[email protected]",
        "username": "Qiscus Demo"
      }
    }
  },
  "status": 200
}

There are several type of comment (message) that you can post to a room, instead of text (default). Each comment has different payload format (particularly in JSON/JSON string) :

type buttons

example payload structure:

{
  "user_id": "[email protected]",
  "room_id": "457",
  "type": "buttons",
  "payload": {
    "text": "silahkan pencet",
    "buttons": [
        {
            "label": "button1",
            "type": "postback",
            "payload": {
                "url": "http://somewhere.com/button1",
                "method": "get",
                "payload": null
            }
        },
        {
            "label": "button2",
            "type": "link",
            "payload": {
                "url": "http://somewhere.com/button2?id=123"
            }
        }
    ]
  }
}

response payload example:

{
  "results": {
    "comment": {
      "message": "",
      "payload": {
        "text": "Silahkan pilih menu berikut:",
        "buttons": [
            {
                "label": "button1",
                "type": "postback",
                "payload": {
                    "url": "http://somewhere.com/button1",
                    "method": "get",
                    "payload": null
                }
            },
            {
                "label": "button2",
                "type": "link",
                "payload": {
                    "url": "http://somewhere.com/button2?id=123"
                }
            }
        ]
      },
      "timestamp": "2018-03-12T08:11:37Z",
      "type": "buttons",
      "user": {
        "avatar_url": "https://res.cloudinary.com/qiscus/image/fetch/http://myimage.com/image.jpg",
        "user_id": "[email protected]",
        "username": "Qiscus Demo"
      }
    }
  },
  "status": 200
}

type card

request payload structure:

{
  "user_id": "[email protected]",
  "room_id": "457",
  "type": "card",
  "payload": {
    "text": "Special deal buat sista nih..",
    "image": "http://url.com/gambar.jpg",
    "title": "Atasan Blouse Tunik Wanita Baju Muslim Worie Longtop",
    "description": "Oleh sippnshop\n96% (666 feedback)\nRp 49.000.00,-\nBUY 2 GET 1 FREE!!!",
    "url": "http://url.com/baju?id=123&track_from_chat_room=123",
    "buttons": [
        {
            "label": "button1",
            "type": "postback",
            "payload": {
                "url": "http://somewhere.com/button1",
                "method": "get",
                "payload": null
            }
        },
        {
            "label": "button2",
            "type": "link",
            "payload": {
                "url": "http://somewhere.com/button2?id=123",
                "method": "get",
                "payload": null
            }
        }
    ]
  }
}

response payload example:

{
  "results": {
    "comment": {
      "message": "Special deal buat sista nih..",
      "payload": {
        "buttons": [
          {
            "label": "button1",
            "postback_text": "",
            "type": "postback",
            "payload": {
              "url": "http://somewhere.com/button1",
              "method": "get",
              "payload": null
            }
          },
          {
            "label": "button2",
            "postback_text": "",
            "type": "link",
            "payload": {
              "url": "http://somewhere.com/button2?id=123",
              "method": "get",
              "payload": null
            }
          }
        ],
        "description": "Oleh sippnshop\n96% (666 feedback)\nRp 49.000.00,-\nBUY 2 GET 1 FREE!!!",
        "image": "http://url.com/gambar.jpg",
        "text": "Special deal buat sista nih..",
        "title": "Atasan Blouse Tunik Wanita Baju Muslim Worie Longtop",
        "url": "http://url.com/baju?id=123&track_from_chat_room=123"
      },
      "timestamp": "2018-03-12T08:11:47Z",
      "type": "card",
      "user": {
        "avatar_url": "https://res.cloudinary.com/qiscus/image/fetch/http://myimage.com/image.jpg",
        "user_id": "[email protected]",
        "username": "Qiscus Demo"
      }
    }
  },
  "status": 200
}

type carousel

request payload structure:

{
    "user_id": "[email protected]",
    "room_id": "457",
    "type" : "carousel",
    "payload": {
    "cards": [
        {
            "image": "http://url.com/gambar.jpg",
            "title": "Atasan Blouse Tunik Wanita Baju Muslim Worie Longtop",
            "description": "Oleh sippnshop\n96% (666 feedback)\nRp 49.000.00,-\nBUY 2 GET 1 FREE!!!",
            "default_action": {
                "type": "postback",
                "postback_text": "Load more",
                "payload": {
                    "url": "http://url.com/baju?id=123&track_from_chat_room=123",
                    "method": "get",
                    "payload": null
                }
            },
            "buttons": [
                {
                    "label": "button1",
                    "type": "postback",
                    "postback_text": "Load more",
                    "payload": {
                        "url": "http://somewhere.com/button1",
                        "method": "get",
                        "payload": null
                    }
                },
                {
                    "label": "button2",
                    "type": "link",
                    "payload": {
                        "method": "get", 
                        "url": "http://somewhere.com/button2?id=123"
                    }
                }
            ]
        }
    ]
  }
}

response payload example:

{
    "results": {
        "comment": {
            "message": "",
            "payload": {
                "cards": [
                    {
                        "image": "http://url.com/gambar.jpg",
                        "title": "Atasan Blouse Tunik Wanita Baju Muslim Worie Longtop",
                        "description": "Oleh sippnshop\n96% (666 feedback)\nRp 49.000.00,-\nBUY 2 GET 1 FREE!!!",
                        "default_action": {
                            "type": "postback",
                            "postback_text": "Load more",
                            "payload": {
                                "url": "http://url.com/baju?id=123&track_from_chat_room=123",
                                "method": "get",
                                "payload": null
                            }
                        },
                        "buttons": [
                            {
                                "label": "button1",
                                "postback_text": "Load more",
                                "type": "postback",
                                "payload": {
                                    "url": "http://somewhere.com/button1",
                                    "method": "get",
                                    "payload": null
                                }
                            },
                            {
                                "label": "button2",
                                "postback_text": "",
                                "type": "link",
                                "payload": {
                                    "url": "http://somewhere.com/button2?id=123",
                                    "method": "get",
                                    "payload": null
                                }
                            }
                        ]
                    }
                ]
            },
            "timestamp": "2018-03-13T09:53:25Z",
            "type": "carousel",
            "user": {
                "avatar_url": "https://res.cloudinary.com/qiscus/image/fetch/http://myimage.com/image.jpg",
                "user_id": "[email protected]",
                "username": "guest"
            }
        }
    },
    "status": 200
}

type custom

Request payload must be valid json string object, and it will return as what you have inputted. The json payload must have an type and content object. Type must be string, for example if you want to create promo payload, it can be “promo”. The content can be anything, such as object, array, number or string in JSON. By this, you can input, let say XML string in payload.content object value and later you can parse it by yourself by overriding SDK client chat view.

example request payload:

{
  "user_id": "[email protected]",
  "room_id": "457",
  "type": "custom",
  "payload": {
    "type": "promo", // sub type of custom payload
    "content": {
        "date": "2017-09-09"
    } // can be anything: object, array, string, number in JSON
  }
}

The response payload will be:

{
  "results": {
    "comment": {
      "message": "",
      "payload": {
        "content": {
            "date": "2017-09-09"
        }
        "type": "promo"
      },
      "timestamp": "2018-03-12T08:11:52Z",
      "type": "custom",
      "user": {
        "avatar_url": "http://myimage.com/image.jpg",
        "user_id": "[email protected]",
        "username": "Qiscus Demo"
      }
    }
  },
  "status": 200
}

type file_attachment

message text will be caption

Example request payload:

{
    "user_id": "[email protected]",
    "room_id": "457",
    "type" : "file_attachment",
    "payload": {
        "url": "https://res.cloudinary.com/qiscus/image/upload/USWiylE7Go/ios-15049438515185.png",
        "caption": "Ini gambar siapa?",
        "file_name": "",
        "size": 0,
        "pages": 1
    }
}

The response payload will be:

{
  "results": {
    "comment": {
      "message": "[file] https://res.cloudinary.com/qiscus/image/upload/USWiylE7Go/ios-15049438515185.png [/file]",
      "payload": {
        "url": "https://res.cloudinary.com/qiscus/image/upload/USWiylE7Go/ios-15049438515185.png",
        "caption": "Ini gambar siapa?",
        "file_name": "",
        "size": 0,
        "pages": 1
      },
      "timestamp": "2018-03-12T08:12:19Z",
      "type": "file_attachment",
      "user": {
        "avatar_url": "http://myimage.com/image.jpg",
        "user_id": "[email protected]",
        "username": "Qiscus Demo"
      }
    }
  },
  "status": 200
}

Load comments

verb: GET /api/v2.1/rest/load_comments

request:

room_id [string]
page [int optional]
limit [int optional default=20]

response:

{
  "results": {
    "comments": [
      {
        "message": "testing message 1",
        "timestamp": "2017-02-07T19:01:00Z",
        "type": "text",
        "payload": null,
        "user": {
          "avatar_url": "https://myimagebucket.com/image.jpg",
          "user_id": "[email protected]",
          "username": "Liu Kang"
        }
      },
      {
        "message": "testing message 2",
        "timestamp": "2017-02-07T19:03:00Z",
        "type": "text",
        "payload": null,
        "user": {
          "avatar_url": "https://myimagebucket.com/image.jpg",
          "user_id": "[email protected]",
          "username": "Sonya"
        }
      }
    ]
  },
  "status": 200
}

Post System Event Message

To send event system message such as creating group, join room, remove member, etc verb: POST /api/v2.1/rest/post_system_event_message

request:

{
    "system_event_type": "custom",
    "room_id": "2110",
    "subject_user_id": "[email protected]",
    "object_user_id": "[email protected]",
    "message": "Admin is being set!",
    "payload": {
        "type": "add_admin",
        "admin_user_id": "[email protected]"
    },
    "extras": {
        "qiscus_ios_pn": {
            "aps": {
                "content-avaibility": 1 
            }
        }
    }
}

if extras contains key qiscus_ios_pn it will override payload value send using APNS.

response :

{
    "results": {
        "comment": {
            "timestamp": "2017-09-22T00:14:45Z",
            "message": "Admin is being set!",
            "type": "system_event",
            "payload": {
                "payload": {
                    "admin_user_id": "[email protected]",
                    "type": "add_admin"
                },
                "type": "custom"
            },
            "user": {
              "avatar_url": "https://myimagebucket.com/image.jpg",
              "user_id": "[email protected]",
              "username": "Sonya"
            }
        }
    },
    "status": 200
}