Manage message updates
Edit messages and receive real-time update events.
Requires Message Persistence
Enable Message Persistence in the Admin Portal.
Edit messages
EditMessageText() replaces an existing message's content.
Method signature
This method takes the following parameters:
1message.EditMessageText(string newText)
Input
| Parameter | Description |
|---|---|
newText *Type: stringDefault: n/a | New/updated text that you want to add in place of the existing message. |
Output
An awaitable Task<ChatOperationResult>.
Sample code
Correct the number of the support ticket you sent to 78398.
1
Get message updates
Receive real-time updates when messages or reactions change:
StreamUpdates()- updates for a singleMessageobjectStreamUpdatesOn()- updates for multipleMessageobjects
Both return updates through event handlers or callbacks.
Change types
For details on ChatEntityChangeType values (Updated and Deleted) and their meaning, see Change types. Note that messages always return ChatEntityChangeType.Updated (even for soft deletes).
Stream update behavior
StreamUpdates()enables listening for updates on a single message. Use theOnMessageUpdatedevent to handle changes.StreamUpdatesOn()has two overloads:StreamUpdatesOn(List<Message>, Action<List<Message>>)returns the complete list of messages you're monitoring each time any change occurs to any of them.StreamUpdatesOn(List<Message>, Action<Message, ChatEntityChangeType>)returns only the specific message that was updated along with the type of change.
Hard deletion callbacks
Messages currently don't receive hard deletion callbacks. Only soft deletes (using Delete(soft: true)) will yield a callback with ChatEntityChangeType.Updated. Hard deletes remove the message entirely without triggering update events.
Method naming
Earlier versions used SetListeningForUpdates() to enable streaming. This method has been superseded by StreamUpdates(), though it remains available for backward compatibility.
Method signature
These methods take the following parameters:
-
StreamUpdates()1message.StreamUpdates(bool stream) -
OnMessageUpdated1// event on the Message entity
2public event Action<Message> OnMessageUpdated;
3// needs a corresponding event handler
4void EventHandler(Message message) -
StreamUpdatesOn()(static) - returns all messages1Message.StreamUpdatesOn(
2 List<Message> messages,
3 Action<List<Message>> listener
4) -
StreamUpdatesOn()(static) - returns individual message with change type1Message.StreamUpdatesOn(
2 List<Message> messages,
3 Action<Message, ChatEntityChangeType> listener
4)
Input
| Parameter | Required in StreamUpdates() | Required in OnMessageUpdated | Required in StreamUpdatesOn() | Description |
|---|---|---|---|---|
streamType: boolDefault: n/a | Yes | n/a | n/a | Whether to start (true) or stop (false) listening to Message object updates. |
messagesType: List<Message>Default: n/a | No | No | Yes | List of Message objects for which you want to get updates. |
listenerType: Action<List<Message>>Default: n/a | No | No | Yes (first overload) | Callback that receives the complete list of all messages being monitored each time any change occurs. |
listenerType: Action<Message, ChatEntityChangeType>Default: n/a | No | No | Yes (second overload) | Callback that receives the specific message that was updated. Note: The change type is currently always ChatEntityChangeType.Updated for messages. |
Output
These methods don't return a value. Updates are delivered through event handlers or callback functions.
Sample code
-
StreamUpdates()andOnMessageUpdatedGet message and message reaction-related updates for all messages published on the
supportchannel.1 -
StreamUpdatesOn()with individual message updatesGet message and message reaction-related updates for messages from the
supportchannel. The callback receives each updated message individually along with the change type.1