Topic Based Chat
Topic based chat lets you to group the chat by topic. You can create the topic , send all types of messages with topic information and thus you can receive the messages by topic.
Create Topic#
You can use the below given method to create a new topic.
| Argument | Type | Description |
|---|---|---|
| TOPIC_NAME | String | Name of the topic (cannot be null or empty) |
| META_DATA | List<MetaData> | META_DATA is an optional parameter to provide additional information about the topic. You can pass it as a List of MetaData Maximum Size is 3 |
Get Topics#
You can use the below given method to get the topics details.
| Argument | Type | Description |
|---|---|---|
| TOPIC_IDS | List<String> | List of topic ids |
Send Message#
To send the message to the user, use the below methods. Different messages such as text, image, audio, video & document type messages can be sent using the below methods.
Text message#
To send your text message, you need to add the below arguments to the parameter in the sendTextMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| TEXT | String | text message to be sent |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Image message#
To send your image message, you need to add the below arguments to the parameter in the sendImageMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| IMAGE_FILE | String | image File path which needs to be sent |
| CAPTION | String | additional text which can be sent along with the image message |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Video message#
To send your video message, you need to add the below arguments to the parameter in the sendVideoMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| LOCAL_FILE_PATH | String | video File path object |
| VIDEO_CAPTION | String | caption text for video file |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Audio message#
To send your audio message, you need to add the below arguments to the parameter in the sendAudioMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| AUDIO_FILE | String | audio File path we are sending |
| AUDIO_DURATION | int | duration of the audio file |
| IS_RECORDED | bool | true, if audio file is recorded.false, if audio file is attached. |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Document message#
To send your document message, you need to add the below arguments to the parameter in the sendDocumentMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| LOCAL_FILE_PATH | String | Local document File path of the document |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Location message#
To send your location message, you need to add the below arguments to the parameter in the sendLocationMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| LATITUDE | double | location latitude which needs to be sent |
| LONGITUDE | double | location longitude which needs to be sent |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Contact message#
To send your contact message, you need to add the below arguments to the parameter in the sendContactMessage() method.
| Argument | Type | Description |
|---|---|---|
| TO_JID | String | jid of the end user |
| CONTACT_NAME | String | contact name |
| CONTACT_NUMBERS | List<String> | list of numbers in that contact |
| REPLY_MESSAGE_ID | String | if it is a reply message for message A, then message A's messageId otherwise empty string |
| TOPIC_ID | String | topic id to be used |
Send Reply message#
To send reply message to the original message, you need to pass the additional parameter original message-id in replyMessageId.TextMessage object as an argument to the parameter in the sendTextMessage() method.
Receive Message#
To receive a Topic related message from another user you must implement the onMessageReceived function. It's a function that will be triggered whenever you receive a new message or related event in the chat.
Get Chats By TopicId#
To get all the list of TopicId related chats, send a request to the server as described below.
Load Initial Topic Based Chat List#
To fetch initial Topic based recent chat list, call the below method.
| Argument | Type | Description |
|---|---|---|
| topicId | String | topic id to be used |
| firstSet | bool | set true to get initial recent chat list otherwise get next set of data |
| limit | int | The maximum number of chat items to retrieve is specified by limit with a default value of 15 if not provided. |
Get messages#
To get the chat and media messages, use the below methods
Load Initial Messages#
To fetch initial conversations between you and a single chat user or group, call the below method.
| Argument | Type | Description |
|---|---|---|
| TOPIC_ID | String | topic id to be used |
Load Previous Messages#
To fetch previous conversations between you and a single chat user or group, call the below method.
Load Next Messages#
To fetch next conversations between you and a single chat user or group, call the below method.