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.

If you are using Qiscus Chat Multichannel, and need to post message as bot, you can find the base URL in this link.

You cannot using this BASE URL to send message to Multichannel, your message won't be passed to respective channels (WhatsApp, Facebook Messenger, Line Messenger, etc)

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 payload 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 messages 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 is 20 messages, max 100, more than 100 will return 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

Delete messages

Delete message with unique Ids of the messages, once it successful delete the message it will send realtime delete event to client-side hence client able to handle respectively

Request:

HTTP
Copy

Headers:

Bash
Copy

Endpoints:

[DELETE] /delete_messages

Params:

KeyTypeDescription
unique_ids[]string[]unique_ids of the messages, you can get unique id from comment object, max 3 unique Ids

Example request:

Bash
Copy

Response:

Bash
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard