# Messages

You can use the methods from the **TapCoreMessageManager** class to manage chat messages.

| Method Name                                                                                   | Description                                                                                             |
| --------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| [Send Text Message](#sendtextmessage)                                                         | Send a new text message to the selected chat room.                                                      |
| [Send Image Message](#sendimagemessage)                                                       | Send a new image message to the selected chat room.                                                     |
| [Send Video Message](#sendvideomessage)                                                       | Send a new video message to the selected chat room.                                                     |
| [Send File Message](#sendfilemessage)                                                         | Send a new file message to the selected chat room.                                                      |
| [Send Location Message](#sendlocationmessage)                                                 | Send a new message with location to the selected chat room.                                             |
| [Send Voice Message](#authenticate-to-taptalk-io-server-with-an-authentication-ticket)        | Send a new voice message to the selected chat room.                                                     |
| [Send Link Message](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-1)       | Send a new link message to the selected chat room.                                                      |
| [Forward a Message](#send-forward-messages)                                                   | Forward an existing message to the selected chat room.                                                  |
| [Construct Message Model](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-2) | Construct a customized TapTalk.io message model.                                                        |
| [Send a Custom Message](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-4)   | Send a new custom message to the room defined in the message model.                                     |
| [Edit Message](#edit-message)                                                                 | Edit the contents of the selected message                                                               |
| [Search Local Messages](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-5)   | Call this method to search messages from the device's local storage with a keyword                      |
| [Star/Unstar Message](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-7)     | Set message as starred or remove star from message for the active user.                                 |
| [Get Starred Messages](#authenticate-to-taptalk-io-server-with-an-authentication-ticket-9)    | Retrieve list of messages marked as starred in a chat room.                                             |
| [Pin/Unpin Message](#pin-message)                                                             | Set message as pinned or remove pin from message for all room participants.                             |
| [Get Pinned Messages](#fetch-pinned-messages)                                                 | Retrieve list of pinned messages in a chat room.                                                        |
| [Get Shared Content Messages](#fetch-shared-content-messages)                                 | Retrieve image, video, file, and link messages from a chat room.                                        |
| [Download Message File](#download-message-file)                                               | Start a file download from the selected file, image, or video message.                                  |
| [Mark Message as Read](#mark-message-as-read)                                                 | Mark message as read by the active user.                                                                |
| [Mark Message as Delivered](#mark-message-as-read-1)                                          | Mark message as delivered by the active user.                                                           |
| [Get Older Messages from Chat Room](#get-older-messages-from-chat-room)                       | Retrieve messages that are older than the provided timestamp from the server to the selected chat room. |
| [Get Newer Messages from Chat Room](#get-newer-messages-from-chat-room)                       | Retrieve newer messages from the server to the selected chat room                                       |
| [Get Room Media](#get-newer-messages-from-chat-room-1)                                        | Retrieve existing media messages from a chat room                                                       |

### DeleteMessage <a href="#mark-message-as-deleted" id="mark-message-as-deleted"></a>

```javascript
tapCoreMessageManager.markMessageAsDeleted(
    ROOM_ID, 
    MESSAGE_IDs, 
    FOR_EVERYONE
);
```

{% hint style="info" %}
**ROOM\_ID:** (String) room ID value\
**MESSAGE\_IDs**:  (Arrray) array of messageID\
**FOR\_EVERYONE:** (boolean) message model of message you want to quoted
{% endhint %}

### SendTextMessage

<pre class="language-javascript"><code class="lang-javascript">tapCoreMessageManager.sendTextMessage(
    MESSAGE_BODY, 
    ROOM, 
    (message) => {
        // do action here
<strong>    },
</strong>    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);
</code></pre>

{% hint style="info" %}
**MESSAGE\_BODY:** (String) message body for message model\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendImageMessage

```javascript
tapCoreMessageManager.sendImageMessage(
    FILE, 
    CAPTION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);
```

{% hint style="info" %}
**FILE**: (Object) the image file to be uploaded\
**CAPTION:** (String) the image's caption to be displayed in message bubble\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendVideoMessage

```javascript
tapCoreMessageManager.sendVideoMessage(
    FILE, 
    CAPTION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);
```

{% hint style="info" %}
**FILE**: (Object) the video file to be uploaded\
**CAPTION:** (String) the image's caption to be displayed in message bubble\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendFileMessage

```javascript
tapCoreMessageManager.sendFileMessage(
    FILE, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);
```

{% hint style="info" %}
**FILE**: (Object) the file to be uploaded\
**CAPTION:** (String) the image's caption to be displayed in message bubble\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendLocationMessage

```javascript
tapCoreMessageManager.sendLocationMessage(
    LATITUDE,
    LONGITUDE,
    ADDRESS, 
    ROOM, 
    (message) => {
        // do action here
    },
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);
```

{% hint style="info" %}
**LATITUDE**: (Number) latitude of the shared location\
**LONGITUDE**: (Number) longitude of the shared location\
**ADDRESS:** (String) text data containing the location address\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendVoiceMessage <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

```javascript
tapCoreMessageManager.sendVoiceMessage(
    FILE, 
    DURATION, 
    ROOM, 
    {
      onStart: (message) => {
          // Message model was generated
      },
      onProgress: (localID, percentage, bytes) => {
          // File upload progress
      },
      onSuccess: (message) => {
          // do action here
      },
      onError: (errorCode, errorMessage) => {
          // do action here
      }
    }, 
    QUOTED_MESSAGE, 
    FORWARD_MESSAGE,
    FORWARD_ONLY,
    QUOTE_TITLE
);
```

{% hint style="info" %}
**FILE**: (Object) the voice note file to be uploaded\
**DURATION:** (Number) the playback duration of the voice note file\
**ROOM**:  (Object) room model for message model\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### SendLinkMessage <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

<pre class="language-javascript"><code class="lang-javascript">tapCoreMessageManager.sendLinkMessage(
    MESSAGE_BODY, 
    ROOM, 
    (message) => {
        // do action here
<strong>    },
</strong><strong>    URLS,
</strong><strong>    TITLE,
</strong><strong>    DESCRIPTION,
</strong><strong>    IMAGE,
</strong><strong>    SITE_NAME,
</strong><strong>    TYPE,
</strong>    QUOTED_MESSAGE, 
    FORWARD_MESSAGE, 
    FORWARD_ONLY, 
    QUOTE_TITLE
);
</code></pre>

{% hint style="info" %}
**MESSAGE\_BODY:** (String) message body for message model\
**ROOM**:  (Object) room model for message model\
**URLS**: (NSArray\<String>) list of URLs contained in the message\
**TITLE**: (String) `og:title` metadata of the specified URL\
**DESCRIPTION**: (String) `og:description` metadata of the specified URL\
**IMAGE**: (String) `og:image` metadata of the specified URL\
**SITE\_NAME**: (String) `og:site_name` metadata of the specified URL\
**TYPE**: (String) `og:type` metadata of the specified URL\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward\
**FORWARD\_ONLY**: (boolean) set to true when you only need to forward an existing message without sending a new message\
**QUOTE\_TITLE**: (String) custom text for message.quote.title
{% endhint %}

### Send Forwarded Messages <a href="#send-forward-messages" id="send-forward-messages"></a>

To send a forwarded message to a chat room, use the `sendForwardMessage()` method from the **TapCoreMessageManager** class.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.sendForwardMessage(ROOM_MODEL, (message) => {
   // do action here
}, FORWARD_MESSAGES)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`ROOM_MODEL`**: (TAPRoomModel) the destination room where the message will be sent\
\&#xNAN;**`CALLBACK`**: (Method) callback method\
\&#xNAN;**`FORWARD_MESSAGES`**: (Array) array of forward messages
{% endhint %}

### Send Forwarded Messages to Multiple Rooms <a href="#send-forward-messages-multiple-rooms" id="send-forward-messages-multiple-rooms"></a>

To send multiple forwarded message to multiple chat room, use the `sendForwardMessagesOnMultipleRooms()` method from the **TapCoreMessageManager** class.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
let DATA = [{
   room: {
      ...ROOM_MODEL
   },
   messages: [
      {
         ...MESSAGE_MODEL
      }
   ]
}]

tapCoreMessageManager.sendForwardMessagesOnMultipleRooms(DATA, (message) => {
   // do action here
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`DATA`**: (Array) array of room and forward messages\
\&#xNAN;**`CALLBACK`**: (Method) callback method
{% endhint %}

### ConstructTapTalkMessageModel <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

```javascript
tapCoreMessageManager.constructTapTalkMessageModel(MESSAGE_BODY, ROOM, MESSAGE_TYPE, MESSAGE_DATA, LOCAL_ID = null, forwardMessage = false);
```

{% hint style="info" %}
**MESSAGE\_BODY:** (String) message body for message model\
**ROOM**:  (Object) room model for message model\
**MESSAGE\_TYPE:** (Number) message type for message model\
**MESSAGE\_DATA:** (Object) data object for message model\
**LOCAL\_ID:** (String) custom value for preference local id default is null\
**FORWARD\_MESSAGE:** (Object) message model of message you want to forward
{% endhint %}

### ConstructTapTalkMessageModelWithQuote <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

```javascript
tapCoreMessageManager.constructTapTalkMessageModelWithQuote(MESSAGE_BODY, ROOM, MESSAGE_TYPE, MESSAGE_DATA, QUOTED_MESSAGE = false, LOCAL_ID = null, QUOTE_TITLE= false, QUOTE_CONTENT = false, QUOTED_IMAGE_URL = false);
```

{% hint style="info" %}
**MESSAGE\_BODY:** (String) message body for message model\
**ROOM**:  (Object) room model for message model\
**MESSAGE\_TYPE:** (Number) message type for message model\
**MESSAGE\_DATA:** (Object) data object for message model\
**LOCAL\_ID:** (String) custom value for preference local id default is null\
**QUOTED\_MESSAGE:** (Object) message model of message you want to quoted\
**QUOTE\_TITLE:** (String) title for your  quoted message default is false\
**QUOTE\_CONTENT**: (String) content for your  quoted message default is false\
**QUOTED\_IMAGE\_URL:** (String) image url for your quoted message default is false
{% endhint %}

### SendCustomMessage <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

```javascript
tapCoreMessageManager.sendCustomMessage(MESSAGE_MODEL, (message) => {
    // do action here
});
```

{% hint style="info" %}
**MESSAGE\_MODEL:** (Object) message model for your message
{% endhint %}

### Edit Message

To edit  amessage in a chat room, use the `sendEmitWithEditedMessage()` method from the **TapCoreMessageManager** class.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.sendEmitWithEditedMessage(MESSAGE, NEW_MESSAGE, (message) => {
   // do action here
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**\
\&#xNAN;**`MESSAGE`**: (Object) message model of the edit message\
\&#xNAN;**`NEW_MESSAGE`**: (String) new message value\
\&#xNAN;**`CALLBACK`**: (Method) callback method
{% endhint %}

### SearchLocalRoomMessageWithKeyword <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

Call this method to search messages from the chat room with a keyword.

```javascript
tapCoreMessageManager.searchLocalRoomMessageWithKeyword(KEYWORD, ROOM_ID, {
 onSuccess: (response) => {
   // do action here
 }, 
 onError: (message) => {
   // do action here
 }
});
```

{% hint style="info" %}
**KEYWORD:** (String) message keyword\
**ROOM\_ID:** (number) room id\
**CALLBACK:** (Object) callback method
{% endhint %}

### SearchLocalMessageWithKeyword <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

Call this method to search messages from all chat room with a keyword.

```javascript
tapCoreMessageManager.searchLocalMessageWithKeyword(KEYWORD, {
 onSuccess: (response) => {
   // do action here
 }, 
 onError: (message) => {
   // do action here
 }
});
```

{% hint style="info" %}
**KEYWORD:** (String) message keyword\
**CALLBACK:** (Object) callback method
{% endhint %}

### StarMessage <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

You may use these methods to mark a message or multiple messages as starred.

```javascript
tapCoreMessageManager.starMessage(ROOM_ID, MESSAGE_IDs, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
);
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**MESSAGE\_IDs:** (Array) array of message id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### UnstarMessage <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

You may use these methods to remove messages from the starred list.&#x20;

```javascript
tapCoreMessageManager.unstarMessage(ROOM_ID, MESSAGE_IDs, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
);
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**MESSAGE\_IDs:** (Array) array of message id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### GetStarredMessageIds <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

You can use the method below get a list of message IDs marked as starred by the user.

```javascript
tapCoreMessageManager.getStarredMessageIds(roomID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### FetchStarredMessages <a href="#authenticate-to-taptalk-io-server-with-an-authentication-ticket" id="authenticate-to-taptalk-io-server-with-an-authentication-ticket"></a>

You can use the method below get a list of message IDs marked as starred by the user.

```javascript
tapCoreMessageManager.fetchStarredMessages(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### FetchSharedContentMessages <a href="#fetch-shared-content-messages" id="fetch-shared-content-messages"></a>

You may use this method to fetch shared content messages from the server. This currently includes image, video, file, and link messages.

```javascript
tapCoreMessageManager.fetchSharedContentMessages(ROOM_ID MAX_CREATED, MIN_CREATED, SORT, {
    onSuccess: (mediasResponse, filesResponse, linksResponse) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**CALLBACK:** (Object) object of callback methods\
**MAX\_CREATED:** (Number) the highest created time of the shared content to be retrieved\
**MIN\_CREATED:** (Number) the lowest created time of the shared content to be retrieved\
**SORT:** (String) sorting order (fill with "ASC" or "DESC"), default value is "ASC"
{% endhint %}

### FetchPinnedMessages <a href="#fetch-pinned-messages" id="fetch-pinned-messages"></a>

You can fetch pinned messages list with this method below.

```javascript
tapCoreChatRoomManager.fetchPinnedMessages(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### GetPinnedMessageIds <a href="#get-pinned-message-ids" id="get-pinned-message-ids"></a>

You can fetch all pinned messages ID list with this method below.

```javascript
tapCoreChatRoomManager.getPinnedMessageIds(ROOM_ID, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### PinMessage <a href="#pin-message" id="pin-message"></a>

You can set pin messages with this method below.

```javascript
tapCoreChatRoomManager.pinMessage(ROOM_ID, MESSAGES, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**MESSAGES**: (Array) arrays of message model\
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### UnpinMessage <a href="#unpin-message" id="unpin-message"></a>

You can set pin messages with this method below.

```javascript
tapCoreChatRoomManager.unpinMessage(ROOM_ID, MESSAGES_IDs, IS_UNPIN_ALL, {
    onSuccess: (res) => {
        // do action here
    },
    onError: (errCode, errMessage) => {
        // do action here
    }
});
```

{% hint style="info" %}
**ROOM\_ID:** (Number) room id\
**MESSAGES\_IDs**: (Array) arrays of message ID\
**IS\_UNPIN\_ALL**: (Boolean) set true if unpin all message \
**CALLBACK:** (Object) object of callback methods
{% endhint %}

### Download Message File <a href="#download-message-file" id="download-message-file"></a>

To start a file download from a **File**, **Image**, or **Video** message, you can use the `downloadMessageFile()` method.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreChatRoomManager.downloadMessageFile(messageModel, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**&#x20;

**`MESSAGE`**: (TAPMessageModel) pending message with ongoing file upload
{% endhint %}

### Mark Message as Read <a href="#mark-message-as-read" id="mark-message-as-read"></a>

To manually mark a message as read, call the `markMessageAsRead()` method.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.markMessageAsRead(ARRAY_OF_MESSAGE_ID)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**&#x20;

**ARRAY\_OF\_MESSAGE\_ID**: (TAPMessageModel) existing message to be marked as read
{% endhint %}

### Mark Message as Delivered <a href="#mark-message-as-read" id="mark-message-as-read"></a>

To manually mark a message as delivered, call the `markMessageAsDelivered()` method.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.markMessageAsDelivered(ARRAY_OF_MESSAGE_ID)
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**&#x20;

**ARRAY\_OF\_MESSAGE\_ID**: (TAPMessageModel) existing message to be marked as read
{% endhint %}

### Get Older Messages from Chat Room <a href="#get-older-messages-from-chat-room" id="get-older-messages-from-chat-room"></a>

To retrieve older messages in a chat room from the server, use the `getOlderMessagesBeforeTimestamp()` method.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.getOlderMessagesBeforeTimestamp(ROOM_ID, NUMBER_OF_ITEMS, {
   onSuccess: (messages, hasMore) => {
          // do action here
    },
    onError: (errorCode, errorMessage) => {
          // do action here
    }
})
```

{% endtab %}
{% endtabs %}

### Get Newer Messages from Chat Room <a href="#get-newer-messages-from-chat-room" id="get-newer-messages-from-chat-room"></a>

To retrieve newer messages in a chat room from the server, use the `getNewerMessagesAfterTimestamp()` method.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreMessageManager.getNewerMessagesAfterTimestamp(ROOM_ID, {
   onSuccess: (messages) => {
          // do action here
    },
    onError: (errorCode, errorMessage) => {
          // do action here
    }
})
```

{% endtab %}
{% endtabs %}

### Get Total  Read Count <a href="#get-total-read-count" id="get-total-read-count"></a>

Get total read count of a message

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreChatRoomManager.getTotalReadCount(MESSAGE_ID, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**&#x20;

**`MESSAGE_ID`**: (Number) message id\
\&#xNAN;**`CALLBACK`**: (Object) object of callback method
{% endhint %}

### Fetch Message Info <a href="#fetch-message-info" id="fetch-message-info"></a>

Fetch message info (read by and delivere to).

{% tabs %}
{% tab title="JavaScript" %}

```javascript
tapCoreChatRoomManager.fetchMessageInfo(MESSAGE_ID, {
      onSuccess : (response) => {
         // do action here
      },
      onError: (errorCode, errorMessage) => {
         // do action here     
      }
})
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Parameters**&#x20;

**`MESSAGE_ID`**: (Number) message id\
\&#xNAN;**`CALLBACK`**: (Object) object of callback method
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.taptalk.io/powertalk-chat-sdk-documentation/powertalk-javascript-sdk/messages.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
