Presence Management
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.
Subscription with Presence
You must create a subscription with Presence enabled to receive Presence events. For more information, refer to each SDK's Publish and Subscribe documentation.
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.
To start managing presence rules, follow these steps:
-
Log into the Admin Portal.
-
Go to the BizOps Workspace section in the left navigation panel.
-
Select Presence Management.
-
Choose an app and a keyset on which you want to manage channels.
-
If you don't have Presence enabled on your keyset, you will be requested to enable it at this point by following on-screen instructions. You need to decide on the default setup - whether you want to track all Presence events on all channels (
*
pattern) or not.
If you decide on ALL ON at this point, you can still create channel- and event-specific Presence rules, which will take precedence over this generic setup.
Create Presence rules
-
Once in the Presence Management module of BizOps Workspace, click the Edit Rules button to switch to the configuration mode.
-
Choose the Create rule button, and a new rule placeholder will appear as a new row at the top of the rules list.
-
In the Pattern column, type in the channel name or the wildcard pattern for the channels you want to enable Presence on. For example, enter
personal-*
to track Presence on all channels with thepersonal
prefix.Rule limitations
If you want to include a few patterns, you must create additional rules as one rule can follow only one allowlist pattern.
-
In the Publish Events column, select the types of events you want to track on the previously defined channels or channel patterns.
Events Description Join
Fires when a user subscribes to a channel. Leave
Fires when a user unsubscribes from a channel. Timeout
Fires when a connection to a channel is lost and the subscriber hasn't been seen in 300 seconds. State-change
Fires whenever the user's state changes. Interval
Fires in interval mode to provide an occupancy count and optionally include delta changes. -
By default, a new rule is created at the bottom of the rules list with the lowest execution priority. To increase the rule priority, hover over it and move it up the list.
-
When you're done, click Save 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. Rules on top take precedence over the subsequent rules. If there are two mutually exclusive rules, the one higher on the list will be respected.
You can change the order of rules by clicking the Edit Rules button to switch to the configuration mode, hovering over a given rule, moving it up or down the list, and clicking Save.
Edit rules
To edit a rule, click the Edit Rules button, change the settings, and Save the configuration.
Copy rules
To easily create numerous rules with similar setups (publish events), you can use the "Copy" icon that creates a copy of the original rule underneath the original rule, with a place for a channel pattern you must fill in.
Click the Edit Rules button to switch to the configuration mode, copy a given rule, complete the rule setup, and Save the configuration.
If you create a new rule with a pattern already covered by another rule, you'll receive a warning that this rule doesn't apply.
Delete rules
To delete a rule, click the "Bin" icon next to the rule and Save the configuration.
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.