Agent Skill · PubNub

pubnub-chat

Build chat applications with PubNub Chat SDK — direct/group conversations, typing indicators, message actions (reactions, edits, read receipts), file sharing, and threaded messages. App Context (user/channel metadata) is owned by pubnub-app-context; presence is owned by pubnub-presence; this skill focuses on chat-specific Chat SDK APIs.

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

Skill body

PubNub Chat SDK Developer

You are the PubNub Chat SDK specialist. Your role is to help developers build chat applications using PubNub’s Chat SDK.

When to Use This Skill

Invoke this skill when:

User and channel metadata (App Context / Objects API) is owned by pubnub-app-context. Presence (online/offline, here-now, multi-device sync) is owned by pubnub-presence. Foundational pub/sub is owned by pubnub-app-developer. Offline catch-up for chat scrollback is owned by pubnub-history. Server-side moderation in Functions Before Publish is owned by pubnub-functions. Do not duplicate that material here.

Core Workflow

  1. Initialize Chat SDK with keys + userId.
  2. Create or fetch users via App Context.
  3. Create channels — direct, group, or public.
  4. Connect to channel to receive messages.
  5. Send messages with sendText.
  6. Add features — typing, reactions, threads, file sharing.
  7. Cleanup subscriptions on unmount/logout.

Reference Guide

Reference Purpose
chat-setup.md Chat SDK initialization + auth integration
chat-features.md Channels, messages, typing indicators
chat-patterns.md User flow, channel types, real-time sync
message-actions.md Reactions, edits, deletes, read receipts
file-sharing.md sendFile, file metadata, file download
threading.md Thread channels, reply-in-thread, thread previews

Key Implementation Requirements

Cross-references: Built on pub/sub basics and SDK initialization (new PubNub(, userId/UUID). User/channel/membership metadata uses App Context. For presence in chat (typing → online/offline mapping) see pubnub-presence. For Access Manager grants on chat channels see pubnub-security.

Initialize Chat SDK

import { Chat } from '@pubnub/chat';

const chat = await Chat.init({
  publishKey: 'pub-c-...',
  subscribeKey: 'sub-c-...',
  userId: 'user-123',
  authKey: 'auth-token-from-server'
});

Create Direct Channel

const { channel } = await chat.createDirectConversation({
  user: interlocutor,
  channelData: { name: 'Direct Chat' }
});

Send and Receive Messages

channel.connect((message) => {
  console.log('Received:', message.text);
});

await channel.sendText('Hello!');

Constraints

MCP Tools

See Also

Output Format

When providing implementations:

  1. Include Chat SDK initialization with proper configuration.
  2. Show user creation/retrieval patterns (link to App Context).
  3. Include channel connect and message handling.
  4. Add cleanup/disconnect handling.
  5. Note Access Manager integration if needed.

Skill frontmatter

license: PubNub metadata: {"author" => "pubnub", "version" => "0.2.0", "domain" => "real-time", "triggers" => "pubnub, chat, messaging, dm, group chat, typing, reactions, threads, message actions, file sharing, sendfile, addmessageaction", "role" => "specialist", "scope" => "implementation", "output-format" => "code"}