# How do you get a singular message from the chat?

**URL:** https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506
**Category:** Development
**Tags:** chat, rest-api
**Created:** [September 1, 2023, 3:55pm UTC](https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506 "2023-09-01T15:55:39Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [September 1, 2023, 3:55pm UTC](https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506/1 "2023-09-01T15:55:39Z")

</div>

One of our forum members is building a chat-based statistics bot, and we’ve gotten almost everything working so far, _except_ for reading the content of the message in which it was mentioned. Is there any way for us to pull the specific message it was mentioned in?

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [September 2, 2023, 7:11am UTC](https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506/2 "2023-09-02T07:11:54Z")

</div>

Haven’t tested, but since each chat entry has a specific `data-id`, one could maybe use the `textContent` property of the specific chat entry `data-id` in javascript 🤔

Assuming the `chat-message-id` is the indentifier:

```javascript
const chat_text = document.querySelector('[data-id="$chat-message-id"]');

if (chat_text) {
    const content = chat_text.textContent;
    console.log(`content of specific chat data-id text: ${content}`);
} else {
    console.log('no content found');
}

```

---

<div class="post-metadata">

### Author: ![Firepup650](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/firepup650/32/465200_2.png) [@Firepup650](https://meta.discourse.org/u/Firepup650)
#### Post date: [September 2, 2023, 3:06pm UTC](https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506/3 "2023-09-02T15:06:25Z")

</div>

That seems like it’d work from browser console, but that wouldn’t work from the API side of things, right?

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [September 2, 2023, 3:14pm UTC](https://meta.discourse.org/t/how-do-you-get-a-singular-message-from-the-chat/277506/4 "2023-09-02T15:14:24Z")

</div>

Yea I’m not sure how you would get the content via API. but I’d probably be looking at some of the functions of the flagging system because if it would seem to do this already. There might be some re-usable functions in a related js file somewhere. 🤷🏻‍♀️
