Event object

Event represents a single piece of information emitted during chat operations: typing indicators, message receipts, mentions, or reports.

Unlike other Chat SDK entities, Event provides no methods - it only passes payloads emitted during chat operations.

Properties​

ChatEvent has the following properties:

1public struct ChatEvent
2{
3 public string TimeToken;
4 public PubnubChatEventType Type;
5 public string ChannelId;
6 public string UserId;
7 public string Payload;
8}
ParameterDescription
TimeToken
Type: string
Timetoken of the message that triggered an event.
Type
Type: PubnubChatEventType
Type of action that emits an event: Typing, Report, Receipt, Mention, Invite, Custom, and Moderation.
ChannelId
Type: string
Target channel where this event is delivered.
UserId
Type: string
Unique ID of the user that triggered the event.
Payload
Type: string
Data passed in an event that differ depending on the event type.

For details, refer to the chat events documentation.

Typed event data​

Streaming methods on entities deliver typed data structs instead of raw ChatEvent objects. The following typed event structs are available:

1public struct Invite
2{
3 public string ChannelId;
4 public string ChannelType;
5 public string InvitedByUserId;
6 public string Timetoken;
7}
8
9public struct Mention
10{
11 public string Text;
12 public string MessageTimetoken;
13 public string ChannelId;
14 public string? ParentChannelId;
15 public string MentionedByUserId;
show all 32 lines
StructUsed byDescription
InviteUser.OnInvitedDelivered when a user is invited to a channel. Contains the channel ID, channel type, inviter user ID, and timetoken.
MentionUser.OnMentionedDelivered when a user is mentioned. Contains the message text, timetoken, channel, optional parent channel (for threads), and the mentioner's user ID.
MessageReportChannel.OnMessageReportedDelivered when a message is reported. Contains the reason, text, timetoken, channel, reported user, and optional auto-moderation ID.
ReadReceiptChannel.OnReadReceiptEventDelivered when a read receipt is received. Contains the user ID and last read timetoken.

Use case​

Events enable:

  • Collecting historical chat events
  • Creating custom events
  • Building moderation dashboards for flagged messages
  • Triggering business logic with Functions

Was this page useful?

Last updated on