Presence Management

When you create a new keyset in the Admin Portal, Presence is enabled by default.

You must decide, however, how you want to configure Presence:

  • Selected channels only (recommended) — turns off all Presence events.

    You won't monitor members' subscription status or track Presence events, such as joins, leaves, or presence state changes, until you add rules in Presence Management.

  • All channels — tracks all Presence events. Consider costs.

Presence events

Subscription with Presence

To receive Presence events, you subscribe with Presence and have Presence enabled on your keyset. Make sure you configure Presence to track Presence-related events for all or selected channels (through Presence Management rules).

If you track Presence only on selected channels, you can use Presence Management to create rules defining which events 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 in to the Admin Portal.

  2. In the left sidebar, go to BizOps Workspace.

  3. Select Presence Management.

  4. Choose an app and keyset.

  5. If Presence isn't enabled on your keyset, enable it when prompted.

    Choose the default setup: track all Presence events on all channels (* pattern) or disable all by default.

    Presence configuration

    If you choose ALL OFF, this general setup appears as a row on the Presence rules list.

    Disabled Presence events

    You can change this setting at any time. Click Edit Rules and toggle the slider.

    You can also create channel‑ and event‑specific Presence rules. These rules take precedence over the generic setup.

Create Presence rules

Presence rules let you define which channels trigger Presence events. Follow these steps to create rules.

  1. In Presence Management, click Edit Rules to switch to configuration mode.

    Edit rules

  2. Click the Create rule button.

    Create rule

    A new rule placeholder will appear as a row at the top of the list.

    Create rule - fields

  3. In the Channel pattern column, enter the channel name or a wildcard pattern. For example, enter personal-* to track Presence on all channels with the personal prefix.

    Rule pattern scope

    Create one rule per allowlist pattern. To include multiple patterns, add additional rules.

  4. In Publish Events, select event types to track on the channels or patterns you defined.

    EventsDescription
    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.
  5. For Subscribe heartbeats and Presence heartbeats, choose how often the client announces its presence to PubNub.

    By default, both settings are enabled. Only one is required to track events for a rule.

    Timeout eventsDescriptionRequired client configurationCost efficiency
    Subscribe heartbeats
    Periodic requests that keep the client active on subscribed channels. The default interval varies by SDK (for example, 300 seconds). If no heartbeat arrives within the timeout, a timeout event fires.
    Enabled by default. Configure during client initialization (parameter name varies by SDK, for example, presenceTimeout).
    Billed separately from Presence heartbeats.
    Presence heartbeats
    Finer control than subscribe heartbeats. Use when you need a shorter Presence timeout. Set the interval during client initialization. Recommended: (presenceHeartbeatValue / 2) - 1.
    Configure during client initialization (parameter name varies by SDK, for example, heartbeatInterval).
    Billed separately from subscribe heartbeats.
  6. By default, a new rule is created at the bottom of the list with the lowest priority. To increase priority, hover and move it up.

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

    The new rule will appear on the rules list.

    Rules list

Change rules order

Each rule has a unique number that defines execution order. Rules at the top take precedence. If rules conflict, the higher rule applies.

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 create similar rules quickly, click the Copy icon. It creates a copy under the original with a blank channel pattern.

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

If a new rule uses a pattern already covered by another, you'll see a note about an overlapping pattern.

Colliding rules

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