On this page

Pinned messages

Using Unity Chat SDK methods, you can implement UI features allowing users to "pin" a message to a channel by selecting a sent message and placing it on top of the channel for everyone to see and access it easily.

They can also "unpin" the message if it's no longer important or "pin" another one to replace an already pinned message (there can be only one pinned message on a channel at a time).

Additionally, they can check which message is pinned to the selected channel since the Unity Chat SDK uses the channel metadata to store information on such messages in Message Persistence.

Pinned Messages let users highlight messages in channels for:

  • Essential information - pin critical updates or announcements, ensuring important information remains easily accessible to all participants and reducing the chance of missing key details.

  • Action items and reminders - by pinning action items or reminders, users and their teams can have a centralized location for reference, making it easier to stay organized, prioritize tasks, and ensure accountability.

  • Polling - pin a poll to a channel, allowing a pollster to persist their questions and not have them lost in a chat flow.

Requires App Context and Message Persistence

To store modified data about messages, you must enable App Context and Message Persistence for your app's keyset in the Admin Portal.

Pin

Pin() and PinMessage() attach a message to the channel.

Both of these methods give the same result. The only difference between them is that you may or may not be required to provide input parameters, and you call them on different objects: message (Pin()) or channel (PinMessage()).

Alternatively, you can also use other Unity Chat SDK methods to pin a message in a thread (thread message) to the thread channel or the parent channel.

Method signature

These methods take the following parameters:

  • Pin()

    1message.Pin()
  • PinMessage()

    1channel.PinMessage(Message message)

Input

ParameterRequired in Pin()Required in PinMessage()Description
message
Type: Message
Default:
n/a
No
Yes
Message object that you want to pin to the selected channel.

Output

An awaitable Task<ChatOperationResult>.

Sample code

Pin the last message on the incident-management channel.

  • Pin()

    1
    
  • PinMessage()

    1
    

Get

GetPinnedMessage() fetches the message that is currently pinned to the channel.

Method signature

1channel.GetPinnedMessage()

Input

This method doesn't take any parameters.

Output

ParameterDescription
Task<ChatOperationResult<Message>>
Type: out Message
An awaitable Task with the Message object if a pinned message exists, otherwise the Error property on the result will be true.

Sample code

Get the message pinned to the incident-management channel.

1

Unpin

UnpinMessage() unpins a message from the channel.

Alternatively, you can also use other Unity Chat SDK methods to unpin a message in a thread (thread message) from the thread channel or the parent channel.

Method signature

This method has the following signature:

1channel.UnpinMessage()

Input

This method doesn't take any parameters.

Output

An awaitable Task<ChatOperationResult>.

Sample code

Unpin the message from the incident-management channel.

1

Last updated on