Message

AI Tools

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:

HTTP
Copy

Headers:

Bash
Copy

Endpoint:

[POST] /post_comment

Params:

KeyTypeDescription
user_id (required)stringUser id in Qiscus Server
room_id (required)stringit can be room id or room unique id specified by client or auto generated by server
message (required)stringMax message content is 4000 chars
type (optional)string

default: text,
and there are predefined that Qiscus provides

[account_linking|button_postback_response|buttons|card|carousel|contact_person| custom|file_attachment|location|reply|text]

payload (optional)jsonpayload for specified type
extras (optional)jsonMeta data in message

An example request of send a message with default type (text):

Bash
Copy

And the response from above request will be:

JSON
Copy

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:

JSON
Copy

Response with button's payload example :

JSON
Copy
  • card type

Here's an example request payload:

JSON
Copy

Response with card's palyoad example:

JSON
Copy
  • carousel type

Here's an example request payload:

JSON
Copy

Response with carousel's payload example:

JSON
Copy
  • file_attachment type

Message text will be the caption. An request file_attachment payload:

JSON
Copy

Response with file_attachment's payload example:

JSON
Copy
  • 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:

JSON
Copy

Response with custom's payload example:

JSON
Copy

Load Message

To retrieve the message data.

Request:

HTTP
Copy

Headers:

Bash
Copy

Endpoint:

[GET] /load_comments

Params:

KeyTypeDescription
room_id (required)intChat Room Id
page (optional)intNumber of page
limit (optional)intDefault, 20 messages

Example request:

Bash
Copy

Response:

JSON
Copy

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:

HTTP
Copy

Headers:

Bash
Copy

Endpoint:

[POST] /post_system_event_message

Params:

KeyTypeDescription
system_event_typestringset "custom" value, to able to use this system event
room_idstringit can be room id or room unique id specified by client or auto generated by server
messagestringMax message content is 4000 chars
payloadjsonDesired payload that you can define based on your needs
extrasjsonMeta data in message

An example request system event:

JSON
Copy

if extras contains key qiscus_ios_pn, it will override payload value that for APNS PN.

Response:

JSON
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard