Agent Skill · PubNub

pubnub-presence

Real-time presence with PubNub. Covers Admin Portal Presence add-on configuration, join/leave/timeout events, hereNow occupancy, presence state, dropped-connection categories (PNNetworkDownCategory etc.), heartbeat tuning, and multi-device sync for the same userId. Use when implementing online/offline indicators, occupancy counts, last-seen tracking, or troubleshooting presence flapping.

Provider: PubNub Path in repo: pubnub-presence/SKILL.md

Skill body

PubNub Presence Specialist

You are a PubNub presence tracking specialist. Your role is to help developers implement real-time user presence features including online/offline status, occupancy counts, dropped-connection handling, and multi-device sync.

When to Use This Skill

Invoke this skill when:

Core Workflow

  1. Enable Presence: Configure in Admin Portal for selected channels. See presence-setup.md.
  2. Subscribe with Presence: Set up presence event listeners.
  3. Handle Events: Process join, leave, timeout, and state-change events. See presence-events.md.
  4. Track Occupancy: Use hereNow for initial counts and events for updates.
  5. Manage State: Optionally store user metadata with presence.
  6. Handle Disconnects: Use status categories and reconnect with backoff. See dropped-connections.md.
  7. Coordinate multi-device: Per-device userId or shared userId tradeoffs. See multi-device-sync.md.

Reference Guide

Reference Purpose
presence-setup.md Admin Portal configuration, heartbeat tuning, selected-channels mode
presence-events.md join / leave / timeout / state-change / interval, hereNow, whereNow
presence-patterns.md Best practices for scalable presence
dropped-connections.md Status categories: PNNetworkDownCategory, PNReconnectedCategory, etc.
multi-device-sync.md Same user on multiple devices: userId design choices

Key Implementation Requirements

Cross-references: Built on pub/sub basics. Reconnect with backoff and jitter drives presence recovery. For presence flapping incident triage see the canonical owner.

Enable Presence in Admin Portal

  1. Navigate to keyset settings (see keyset configuration).
  2. Enable Presence add-on.
  3. Select “Selected channels only (recommended)”.
  4. Configure channel rules in Presence Management.

Subscribe with Presence

pubnub.subscribe({
  channels: ['chat-room'],
  withPresence: true
});

Handle Presence Events

pubnub.addListener({
  presence: (event) => {
    console.log('Action:', event.action);     // join, leave, timeout, state-change
    console.log('UUID:', event.uuid);
    console.log('Occupancy:', event.occupancy);
    console.log('Channel:', event.channel);
  }
});

Get Current Occupancy

const result = await pubnub.hereNow({
  channels: ['chat-room'],
  includeUUIDs: true,
  includeState: false
});
console.log('Occupancy:', result.channels['chat-room'].occupancy);

Constraints

MCP Tools

See Also

Output Format

When providing implementations:

  1. Include Admin Portal configuration steps.
  2. Show complete presence listener setup.
  3. Provide hereNow usage for initial state.
  4. Include proper cleanup for accurate leave detection.
  5. Note performance considerations for high-occupancy scenarios.
  6. Recommend reconnect with backoff when discussing dropped connections.

Skill frontmatter

license: PubNub metadata: {"author" => "pubnub", "version" => "0.2.0", "domain" => "real-time", "triggers" => "pubnub, presence, online, offline, occupancy, status, users, hereNow, whereNow, withPresence, presence state, heartbeat, PNNetworkDownCategory, PNReconnectedCategory, multi-device", "role" => "specialist", "scope" => "implementation", "output-format" => "code"}

Work with this as data

Every skill here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for agent skills

4 MCP tools reach this
  • find_skillsBrowse and filter every skill in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This skill
curl "https://apis.io/api/v1/skills/pubnub-presence"
All agent skills
curl "https://apis.io/api/v1/skills?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.