# How to get live messages from ts-sdk

**URL:** <https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654>\
**Category:** Web\
**Created:** [February 28, 2023, 11:55am UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654 "2023-02-28T11:55:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sarathdixit](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sarathdixit](https://forum.social.plus/u/sarathdixit)\
**Post date:** [February 28, 2023, 11:55am UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/1 "2023-02-28T11:55:54Z")

</div>

I’m facing an issue with getting real-time message in typescript sdk. Please provide me with an example of this.

---

<div class="post-metadata">

**Author:** ![SocialPlus\_Support](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.social.plus/socialplus_support/32/798_2.png) [@SocialPlus\_Support](https://forum.social.plus/u/SocialPlus_Support)\
**Post date:** [February 28, 2023, 2:38pm UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/2 "2023-02-28T14:38:48Z")

</div>

Hi @sarathdixit please find all info & samples here:

> **[TypeScript Live Messages](https://docs.amity.co/core-concepts/live-messages/typescript-live-messages)**

Amity Support

---

<div class="post-metadata">

**Author:** ![sarathdixit](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sarathdixit](https://forum.social.plus/u/sarathdixit)\
**Post date:** [February 28, 2023, 3:14pm UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/4 "2023-02-28T15:14:00Z")

</div>

@SocialPlus_Support I’m not seeing any examples of live messages that automatically display new messages in a particular channel without requiring a manual refresh

---

<div class="post-metadata">

**Author:** ![cijin](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cijin](https://forum.social.plus/u/cijin)\
**Post date:** [March 1, 2023, 6:23am UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/5 "2023-03-01T06:23:14Z")

</div>

@sarathdixit

If you subscribe to sub channel topic, like the example here; You should get automatic updates to RTE and live Messages will be update the collection of messages for you.

```auto
export async function subscribeSubChannel(
  subChannelId: string,
): Promise<Amity.Unsubscriber> {
  const subChannel = (await fetch(
    createQuery(getSubChannel, subChannelId),
  )) as Amity.SubChannel;

  return subscribeTopic(getSubChannelTopic(subChannel));
}

```

---

<div class="post-metadata">

**Author:** ![sarathdixit](https://avatars.discourse-cdn.com/v4/letter/s/35a633/32.png) [@sarathdixit](https://forum.social.plus/u/sarathdixit)\
**Post date:** [March 1, 2023, 1:17pm UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/6 "2023-03-01T13:17:51Z")

</div>

@cijin Thanks for the solution. I’m facing another issue the observeMessage function fires multiple times for a single message and also I’m not getting the creator object like name and avatar in the messages data. How can I achieve those creator data?

---

<div class="post-metadata">

**Author:** ![cijin](https://avatars.discourse-cdn.com/v4/letter/c/49beb7/32.png) [@cijin](https://forum.social.plus/u/cijin)\
**Post date:** [March 2, 2023, 9:41am UTC](https://forum.social.plus/t/how-to-get-live-messages-from-ts-sdk/654/7 "2023-03-02T09:41:54Z")

</div>

@sarathdixit

Hey, there’s two ways around it.

1. You can use `liveMessage` instead. It will handle any updates to a message. Also, will always only return you the latest message, when multiple updates are recieved.

2. You could compare the the updated payload’s `updatedAt` time with the current objects `updatedAt` time and use the latest one

As, for creator name and avatar, it kind of does not make sense to make it part of the `messagePayload`. There is however the `creatorId` which you could use to retrieve the required info.
