When you enable Presence on your app's keyset in the Admin Portal, you start tracking Presence for all channels on your keyset. This means that you can monitor channel members' subscription status, track any Presence-related events, for example, when users join or leave the channel, or when their presence state changes.
If you don't want to track Presence events on all your channels but only on the selected ones, you can do that using Presence Management.
Presence Management is a self-service tool that lets you create rules defining which Presence events you want to track on which channel patterns.
Existing Presence rules
If you already have Presence rules created by PubNub support, they remain valid and will be visible on the Admin Portal.
Create Presence rules
Log into the Admin Portal, go to the Presence Management section in the left navigation panel.
Select an App and a Keyset.
Click the Create Rule button.
Select the Publish Client Events you want to track. When you're done, click Next.
Events UI representation Description
Fires when a user subscribes to a channel.
Fires when a user unsubscribes from a channel.
Fires when a connection to a channel is lost and the subscriber hasn't been seen in 300 seconds.
Fires whenever the user's state changes.
Fires in interval mode to provide an occupancy count and optionally include delta changes.
Type in the wildcard pattern for the channels you want to enable Presence on. For example, enter
personal-*to track Presence on all channels with the
personalprefix. Mark the This pattern is for channel groups checkbox if you also want to apply the rule to the channel groups. When you're ready, click Next.
If you want to include a few patterns, you must create additional rules as one rule can follow only one allowlist pattern.
At the end, you'll see the rule configuration summary. Click Create to finish.
The new rule will appear on the rules list.
Change rules order
Each rule created through Presence Management gets a unique number that denotes the rule execution sequence, with new rules taking precedence over the older rules.
You can change the order of rules by hovering over a given rule and moving it up or down the list.
To edit a rule, click the "More" option next to the rule, select Edit, and confirm your choice.
To delete a rule, click the "More" option next to the rule, select Delete, and confirm your choice.
Configure webhooks for rules
Once you have created Presence rules, you can configure webhooks for them using Events & Actions. This way, you can decide what will happen when chosen Presence events occur. For example, you can configure Events & Actions to send e-mail notifications each time a new member joins a channel.