Message
You can use this API for managing various behaviour of message.
Send Message
After succeed creating Chat Room in Qiscus Server, now you can send message to the Chat Room. There are several type of message that you can post to a chat room, instead of text (default). Each message has different payload format (particularly in JSON/JSON string). You also you can build your own type using custom type in a message.
Request:
Headers:
Endpoint:
[POST] /post_comment
Params:
Key | Type | Description<br> |
|---|---|---|
user_id (required) | string | User id in Qiscus Server |
room_id (required) | string | it can be room id or room unique id specified by client or auto generated by server |
message (required) | string | Max message content is 4000 chars |
type (optional) | string | <p>default: text, <br>and there are predefined that Qiscus provides</p><p>[account_linking|button_postback_response|buttons|card|carousel|contact_person| <span>custom|file_attachment|location|reply|text]</span></p> |
payload (optional) | json | payload for specified type |
extras (optional) | json | Meta data in message |
An example request of send a message with default type (text):
And the response from above request will be:
Message type's payload and response:
The predefined message type have its payload, you can see for each message type's payload below:
buttons type
Here's an example request payload:
Response with button's payload example :
card type
Here's an example request payload:
Response with card's palyoad example:
carousel type
Here's an example request payload:
Response with carousel's payload example:
file_attachment type
Message text will be the caption. An request file_attachment payload:
Response with file_attachment's payload example:
custom type
Request payload must be valid JSON string object, and it will return as what you have inputted. The JSON payload must have any 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 Qiscus Chat SDK client chat view.
Example request payload:
Response with custom's payload example:
Load Message
To retrieve the message data.
Request:
Headers:
Endpoint:
[GET] /load_comments
Params:
Key | Type | Description |
|---|---|---|
room_id (required) | int | Chat Room Id |
page (optional) | int | Number of page |
limit (optional) | int | Default, 20 messages |
Example request:
Response:
Post System Event Message
To send event system message such as creating group, join room, remove member, and other use case that need to notify an event to participants in a Chat Room.
Request:
Headers:
Endpoint:
[POST] /post_system_event_message
Params:
Key | Type | Description |
|---|---|---|
system_event_type | string | set "custom" value, to able to use this system event |
room_id | string | it can be room id or room unique id specified by client or auto generated by server<br> |
message | string | Max message content is 4000 chars |
payload | json | Desired payload that you can define based on your needs |
extras | json | Meta data in message<br> |
An example request system event:
if extras contains key qiscus_ios_pn, it will override payload value that for APNS PN.
Response:
Qiscus Technology