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.

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

Requires Presence

To create Presence rules for channels, you must enable Presence for your app's keyset in the Admin Portal.

  1. Log into the Admin Portal, go to the Presence Management section in the left navigation panel.

  2. Select an App and a Keyset.

  3. Click the Create Rule button.

    Create rule

  4. Select the Publish Client Events you want to track. When you're done, click Next.

    EventsUI representationDescription
    joinJFires when a user subscribes to a channel.
    leaveLFires when a user unsubscribes from a channel.
    timeoutTFires when a connection to a channel is lost and the subscriber hasn't been seen in 300 seconds.
    state-changeSFires whenever the user's state changes.
    intervalIFires in interval mode to provide an occupancy count and optionally include delta changes.
  5. 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 personal prefix. 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.

    Rule limitations

    If you want to include a few patterns, you must create additional rules as one rule can follow only one allowlist pattern.

  6. At the end, you'll see the rule configuration summary. Click Create to finish.

    The new rule will appear on the rules list.

    Presence rule

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.

Rules order

Edit rules

To edit a rule, click the "More" option next to the rule, select Edit, and confirm your choice.

Edit rule

Delete rules

To delete a rule, click the "More" option next to the rule, select Delete, and confirm your choice.

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