ChatifyPHP

Events & Real-Time

All broadcast events, channels, payloads, and how to listen for them

Chatify dispatches broadcast events for every real-time interaction. All events implement ShouldBroadcastNow (dispatched synchronously, no queue needed).

Channels

Events are sent on two types of private channels:

ChannelFormatScope
Conversationprivate-chatify.conversation.{conversationId}Events for all participants of a conversation
Userprivate-chatify.user.{userId}Events targeted at a specific user

Event reference

MessageSent

Dispatched when a new message is sent.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameMessageSent
PayloadFull MessageResource (id, conversation_id, body, attachment, sender, reply_to, forwarded_from, created_at)

MessageUpdated

Dispatched when a message is edited.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameMessageUpdated
PayloadFull MessageResource with updated body and edited_at

MessageDeleted

Dispatched when a message is deleted.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameMessageDeleted
Payload{ id, conversation_id }

ConversationRead

Dispatched when a user marks a conversation as read.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameConversationRead
Payload{ conversation_id, user_id, read_at }

ConversationInboxUpdated

Dispatched to update a user's inbox (new message arrived, conversation updated, etc.).

PropertyValue
Channelchatify.user.{userId}
Event nameInboxUpdated
PayloadFull ConversationResource with last message and unread count

UserTyping

Dispatched when a user starts or stops typing.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameUserTyping
Payload{ conversation_id, user_id, is_typing }

UserPresenceChanged

Dispatched when a user comes online or goes offline. Sent to each user who shares a conversation with them.

PropertyValue
Channelchatify.user.{audienceUserId}
Event nameUserPresenceChanged
Payload{ user_id, is_online }

UserBlockChanged

Dispatched when a user blocks or unblocks another user. Sent to both parties.

PropertyValue
Channelchatify.user.{audienceUserId}
Event nameUserBlockChanged
Payload{ blocker_id, blocked_user_id, blocked, messaging_blocked_user_ids }

GroupParticipantsChanged

Dispatched when participants are added, removed, or their roles change in a group.

PropertyValue
Channelchatify.conversation.{conversationId}
Event nameGroupParticipantsChanged
Payload{ conversation_id, change_type, actor_user_id, target_user_ids, participant_count, participants_preview }

GroupMembershipRevoked

Dispatched to a user who has been removed from a group. Sent only to the removed user.

PropertyValue
Channelchatify.user.{userId}
Event nameGroupMembershipRevoked
Payload{ conversation_id, user_id, reason }

Listening on the frontend

The bundled UI handles all events automatically. If you are building a custom frontend, subscribe to channels using Laravel Echo:

import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

const echo = new Echo({
    broadcaster: 'pusher',
    key: 'your-pusher-key',
    cluster: 'mt1',
    forceTLS: true,
    authEndpoint: '/api/chatify/v1/broadcasting/auth',
});

// Listen for new messages in a conversation
echo.private(`chatify.conversation.${conversationId}`)
    .listen('.MessageSent', (data) => {
        console.log('New message:', data);
    })
    .listen('.UserTyping', (data) => {
        console.log('Typing:', data);
    })
    .listen('.ConversationRead', (data) => {
        console.log('Read receipt:', data);
    });

// Listen for user-specific events
echo.private(`chatify.user.${userId}`)
    .listen('.InboxUpdated', (data) => {
        console.log('Inbox updated:', data);
    })
    .listen('.UserPresenceChanged', (data) => {
        console.log('Presence:', data);
    });

Note the . prefix before event names -- this tells Echo to use the broadcastAs name rather than the fully-qualified class name.

Presence heartbeat

The frontend sends periodic heartbeat requests to track online status:

POST /api/chatify/v1/presence/heartbeat

When a user closes the tab or navigates away, an offline signal is sent:

POST /api/chatify/v1/presence/offline

The server then dispatches UserPresenceChanged events to all users who share conversations with the user.

Event summary

EventChannel typeEvent nameWhen dispatched
MessageSentConversationMessageSentNew message sent
MessageUpdatedConversationMessageUpdatedMessage edited
MessageDeletedConversationMessageDeletedMessage deleted
ConversationReadConversationConversationReadConversation marked as read
UserTypingConversationUserTypingUser starts/stops typing
GroupParticipantsChangedConversationGroupParticipantsChangedGroup members added/removed/role changed
ConversationInboxUpdatedUserInboxUpdatedInbox entry needs refresh
UserPresenceChangedUserUserPresenceChangedUser comes online/goes offline
UserBlockChangedUserUserBlockChangedUser blocked/unblocked
GroupMembershipRevokedUserGroupMembershipRevokedUser removed from group

On this page