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:

  1. Log into the Admin Portal.

  2. Go to the BizOps Workspace section in the left navigation panel.

  3. Select Presence Management.

  4. Choose an app and a keyset on which you want to manage channels.

  5. 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.

    Presence configuration

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

  1. Once in the Presence Management module of BizOps Workspace, click the Edit Rules button to switch to the configuration mode.

    Edit rules

  2. Choose the Create rule button, and a new rule placeholder will appear as a new row at the top of the rules list.

    Create rule

  3. 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 the personal 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.

  4. In the Publish Events column, select the types of events you want to track on the previously defined channels or channel patterns.

    JoinFires when a user subscribes to a channel.
    LeaveFires when a user unsubscribes from a channel.
    TimeoutFires when a connection to a channel is lost and the subscriber hasn't been seen in 300 seconds.
    State-changeFires whenever the user's state changes.
    IntervalFires in interval mode to provide an occupancy count and optionally include delta changes.
  5. 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.

  6. When you're done, click Save to finish.

    The new rule will appear on the rules list.

    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.

Rules order

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.

Copy rule

Delete rules

To delete a rule, click the "Bin" icon next to the rule and Save the configuration.

Delete rule

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.

Last updated on