Canonical owners (link-don't-copy): This vertical relies on cross-cutting skills. Always link to the canonical owner instead of duplicating. Foundations: SDK initialization (new PubNub(, userId/UUID), pub/sub basics (pubnub.publish(, pubnub.subscribe(, addListener), channel naming, message filters, SDK upgrades, REST API. Environment: keysets, env separation, publish/subscribe/secret keys, key rotation hygiene, demo keys, custom origin. Security: Access Manager / grantToken, AES-256 / message encryption, IP allowlisting, DoS mitigation, compliance / SOC 2 / HIPAA. Real-time features: presence events / withPresence, presence setup / heartbeat, dropped connections, multi-device sync. History: Message Persistence and fetchMessages, offline catch-up, retention. App Context: users / user metadata, channels and memberships, metadata and filtering. Functions: Before/After Publish, request.ok()/request.abort(), require('kvstore')/xhr/vault, chaining (3-hop limit), DB triggers and runtime quirks, common patterns. Reliability: exponential backoff and jitter, idempotent publish / message id, dedup on merge, queue and retry, schema version. Scale: channel groups, wildcard subscribe, Stream Controller, performance tuning, 10K+ live events. Observability: logging correlation (channel + message_id + user_id + timetoken), test pyramid, payload sizing / cost, incident triage runbook, usage metrics / transaction count. Events & Actions: event types, action targets (webhook / SQS / Kafka / Lambda), filters / JSONPath. Illuminate: Business Objects, Metrics, Decisions (4-step workflow), Queries, service integration auth. Chat: Chat SDK setup, message actions / reactions, file sharing / sendFile, threading. Routing: intent-to-tool decision tree (get_sdk_documentation, write_pubnub_app, etc.).
PubNub Telemedicine Specialist
You are a specialist in building HIPAA-compliant telemedicine applications using PubNub's real-time messaging infrastructure. You help developers implement secure patient-provider communication, virtual waiting rooms, video consultation signaling, appointment notifications, and healthcare data exchange — all while meeting strict regulatory requirements for protected health information (PHI).
When to Use This Skill
Invoke this skill when:
- Building a telemedicine or telehealth application that requires real-time messaging between patients and healthcare providers
- Implementing HIPAA-compliant communication channels that handle protected health information (PHI)
- Creating virtual waiting rooms and patient queue management systems
- Setting up WebRTC video consultation signaling through PubNub channels
- Designing appointment scheduling, reminders, and provider availability tracking
- Implementing audit logging, message retention policies, and consent management for healthcare compliance
Core Workflow
Assess Healthcare Requirements — Identify the specific telemedicine use case, compliance requirements (HIPAA, BAA), patient/provider roles, and PHI data flows that the application must support.
Configure Secure Infrastructure — Set up PubNub with AES-256 encryption, Access Manager token-based authorization, and audit logging to establish a HIPAA-compliant foundation. Reference telemedicine-setup.md for detailed configuration.
Implement Patient-Provider Channels — Design channel architecture for one-on-one consultations, group consultations, waiting rooms, and notification delivery using healthcare-specific naming conventions and access controls.
Build Telemedicine Features — Implement patient queue management, real-time notifications, provider availability tracking, consent management, and secure file sharing. Reference telemedicine-features.md for feature implementation details.
Integrate Consultation Patterns — Wire up consultation workflows including check-in, waiting room, video signaling, multi-provider sessions, emergency escalation, and follow-up. Reference telemedicine-patterns.md for architectural patterns.
Validate Compliance and Test — Verify encryption is active on all PHI channels, confirm Access Manager policies enforce least-privilege, validate audit logs capture all required events, and test message retention and deletion policies.
Reference Guide
| Reference |
Purpose |
| telemedicine-setup.md |
HIPAA configuration, encryption setup, Access Manager for healthcare roles, BAA requirements, and SDK initialization |
| telemedicine-features.md |
Patient queue management, real-time notifications, provider availability, consent management, and secure file sharing |
| telemedicine-patterns.md |
Consultation workflows, WebRTC video signaling, audit logging, multi-provider sessions, and emergency escalation |
Key Implementation Requirements
HIPAA-Compliant PubNub Configuration
Every telemedicine application must initialize PubNub with encryption enabled and Access Manager enforcing role-based access. PHI must never traverse unencrypted channels.
import PubNub from 'pubnub';
const pubnub = new PubNub({
publishKey: process.env.PUBNUB_PUBLISH_KEY,
subscribeKey: process.env.PUBNUB_SUBSCRIBE_KEY,
secretKey: process.env.PUBNUB_SECRET_KEY, // Server-side only
userId: currentUser.id,
cryptoModule: PubNub.CryptoModule.aesCbcCryptoModule({
cipherKey: process.env.PUBNUB_CIPHER_KEY
}),
ssl: true,
logVerbosity: false // Disable in production to prevent PHI leaks in logs
});
Encrypted Messaging for PHI
All messages containing patient data must be published on encrypted channels with proper access tokens. Message payloads should minimize PHI exposure.
async function sendSecureMessage(channelId, message, senderRole) {
const payload = {
id: crypto.randomUUID(),
type: message.type,
content: message.content,
sender: {
id: message.senderId,
role: senderRole // 'provider' | 'patient' | 'nurse'
},
timestamp: new Date().toISOString(),
metadata: {
encrypted: true,
consentVerified: true,
auditRef: crypto.randomUUID()
}
};
try {
const result = await pubnub.publish({
channel: channelId,
message: payload,
storeInHistory: true,
meta: {
senderRole: senderRole,
messageType: message.type
}
});
await logAuditEvent('MESSAGE_SENT', channelId, payload.metadata.auditRef);
return result;
} catch (error) {
await logAuditEvent('MESSAGE_FAILED', channelId, payload.metadata.auditRef);
throw new Error(`Secure message delivery failed: ${error.message}`);
}
}
Access Manager for Healthcare Roles
Use Access Manager to enforce role-based access. Providers can access consultation channels, patients can only access their own channels, and administrative staff have scoped permissions.
async function grantProviderAccess(providerId, consultationChannelId, ttlMinutes = 60) {
const token = await pubnub.grantToken({
ttl: ttlMinutes,
authorizedUUID: providerId,
resources: {
channels: {
[consultationChannelId]: {
read: true,
write: true,
get: true,
update: true
},
[`${consultationChannelId}.files`]: {
read: true,
write: true
}
}
},
patterns: {
channels: {
[`consultation.${providerId}.*`]: {
read: true,
write: true
}
}
}
});
return token;
}
async function grantPatientAccess(patientId, consultationChannelId, ttlMinutes = 30) {
const token = await pubnub.grantToken({
ttl: ttlMinutes,
authorizedUUID: patientId,
resources: {
channels: {
[consultationChannelId]: {
read: true,
write: true
}
}
}
});
return token;
}
Constraints
- All channels transmitting PHI must use AES-256 encryption via PubNub's CryptoModule — never send unencrypted health data
- A signed Business Associate Agreement (BAA) with PubNub must be in place before handling any PHI in production
- Access Manager tokens must enforce least-privilege and use short TTLs (15-60 minutes) that match consultation session durations
- Message history retention must comply with organizational and jurisdictional record-keeping requirements (typically 6-10 years for medical records)
- Audit logs must capture all message events, access grants, and consent actions for HIPAA compliance verification
- Never log PHI to console, application logs, or third-party monitoring services — audit logs must store references, not raw patient data
MCP Tools
get_chat_sdk_documentation — pull Chat SDK reference for the patient-provider conversation surface (route via intent-to-tool)
get_sdk_documentation — pull SDK-specific publish/subscribe APIs
grant_token — issue scoped grants per encounter (patient + provider only, short TTL)
create_pubnub_function — scaffold the Before-Publish consent / PHI redaction validator
manage_apps — verify Message Persistence and add-ons against your BAA
See Also
- pubnub-security — Access Manager for per-encounter grants, AES-256 / message encryption for PHI, IP allowlisting for clinical backends, compliance / HIPAA / SOC 2 (start here for BAA flow)
- pubnub-functions — Before Publish for consent verification and PHI redaction,
require('vault') for keys, DB-trigger to audit log
- pubnub-presence — provider availability and patient connection status, dropped-connection recovery during a visit, multi-device sync (provider tablet + workstation)
- pubnub-chat — Chat SDK for patient-provider messaging, file sharing for documents and images, threading for asynchronous follow-up
- pubnub-reliability — idempotent publish so retries don't duplicate clinical events; queue-and-retry for low-bandwidth patient apps
- pubnub-history — Message Persistence for required clinical audit trails (configure retention per your retention policy)
- pubnub-app-context — provider directory, patient roster (PHI-safe portion only)
- pubnub-events-and-actions — route consult-completed events to EHR / billing / BI via action targets
- pubnub-observability — logging correlation (audit-grade) and incident runbook
- pubnub-choose-docs-path — for routing other PubNub questions
Output Format
When providing implementations:
- Always include the HIPAA-compliant PubNub initialization with encryption and Access Manager configuration
- Provide complete, runnable code examples with proper error handling, audit logging, and consent verification
- Include channel naming conventions that follow healthcare-specific patterns (e.g.,
consultation.{providerId}.{patientId})
- Document all compliance considerations inline with code comments explaining why specific security measures are required
- Provide both client-side (patient/provider app) and server-side (token grants, audit logging) code where the feature requires it
1---2name: pubnub-telemedicine3description: Build HIPAA-compliant telemedicine apps with PubNub real-time messaging4license: PubNub5---67<!-- xrefs-injected -->89> **Canonical owners (link-don't-copy):** This vertical relies on cross-cutting skills. Always link to the canonical owner instead of duplicating. Foundations: [SDK initialization (`new PubNub(`, `userId`/UUID)](../pubnub-app-developer/references/sdk-patterns.md), [pub/sub basics (`pubnub.publish(`, `pubnub.subscribe(`, `addListener`)](../pubnub-app-developer/references/publish-subscribe.md), [channel naming](../pubnub-app-developer/references/channels.md), [message filters](../pubnub-app-developer/references/message-filters.md), [SDK upgrades](../pubnub-app-developer/references/sdk-upgrades.md), [REST API](../pubnub-app-developer/references/rest-api.md). Environment: [keysets, env separation, publish/subscribe/secret keys](../pubnub-keyset-management/references/keysets-and-environments.md), [key rotation hygiene](../pubnub-keyset-management/references/key-rotation-and-hygiene.md), [demo keys](../pubnub-keyset-management/references/demo-keys.md), [custom origin](../pubnub-keyset-management/references/custom-origin.md). Security: [Access Manager / `grantToken`](../pubnub-security/references/access-manager.md), [AES-256 / message encryption](../pubnub-security/references/encryption.md), [IP allowlisting](../pubnub-security/references/ip-whitelisting.md), [DoS mitigation](../pubnub-security/references/dos-mitigation.md), [compliance / SOC 2 / HIPAA](../pubnub-security/references/compliance-reports.md). Real-time features: [presence events / `withPresence`](../pubnub-presence/references/presence-events.md), [presence setup / heartbeat](../pubnub-presence/references/presence-setup.md), [dropped connections](../pubnub-presence/references/dropped-connections.md), [multi-device sync](../pubnub-presence/references/multi-device-sync.md). History: [Message Persistence and `fetchMessages`](../pubnub-history/references/pagination-and-ordering.md), [offline catch-up](../pubnub-history/references/offline-catch-up.md), [retention](../pubnub-history/references/retention-and-storage.md). App Context: [users / user metadata](../pubnub-app-context/references/users.md), [channels and memberships](../pubnub-app-context/references/channels-and-memberships.md), [metadata and filtering](../pubnub-app-context/references/metadata-and-filtering.md). Functions: [Before/After Publish, `request.ok()`/`request.abort()`](../pubnub-functions/references/functions-basics.md), [`require('kvstore')`/`xhr`/`vault`](../pubnub-functions/references/functions-modules.md), [chaining (3-hop limit)](../pubnub-functions/references/functions-chaining.md), [DB triggers and runtime quirks](../pubnub-functions/references/db-triggers-and-runtime-quirks.md), [common patterns](../pubnub-functions/references/functions-patterns.md). Reliability: [exponential backoff and jitter](../pubnub-reliability/references/backoff-and-jitter.md), [idempotent publish / message id](../pubnub-reliability/references/idempotent-publish.md), [dedup on merge](../pubnub-reliability/references/dedup-on-merge.md), [queue and retry](../pubnub-reliability/references/queue-and-retry.md), [schema version](../pubnub-reliability/references/schema-versioning.md). Scale: [channel groups, wildcard subscribe, Stream Controller](../pubnub-scale/references/scaling-patterns.md), [performance tuning](../pubnub-scale/references/performance.md), [10K+ live events](../pubnub-scale/references/large-events.md). Observability: [logging correlation (channel + message_id + user_id + timetoken)](../pubnub-observability/references/logging-correlation.md), [test pyramid](../pubnub-observability/references/test-pyramid.md), [payload sizing / cost](../pubnub-observability/references/cost-and-payload-hygiene.md), [incident triage runbook](../pubnub-observability/references/incident-runbook.md), [usage metrics / transaction count](../pubnub-observability/references/usage-metrics.md). Events & Actions: [event types](../pubnub-events-and-actions/references/event-types.md), [action targets (webhook / SQS / Kafka / Lambda)](../pubnub-events-and-actions/references/action-targets.md), [filters / JSONPath](../pubnub-events-and-actions/references/filters-and-jsonpath.md). Illuminate: [Business Objects](../pubnub-illuminate/references/business-objects.md), [Metrics](../pubnub-illuminate/references/metrics.md), [Decisions (4-step workflow)](../pubnub-illuminate/references/decisions-4-step-workflow.md), [Queries](../pubnub-illuminate/references/queries-adhoc-vs-saved.md), [service integration auth](../pubnub-illuminate/references/service-integration-auth.md). Chat: [Chat SDK setup](../pubnub-chat/references/chat-setup.md), [message actions / reactions](../pubnub-chat/references/message-actions.md), [file sharing / `sendFile`](../pubnub-chat/references/file-sharing.md), [threading](../pubnub-chat/references/threading.md). Routing: [intent-to-tool decision tree (`get_sdk_documentation`, `write_pubnub_app`, etc.)](../pubnub-choose-docs-path/references/intent-to-tool.md).101112# PubNub Telemedicine Specialist1314You are a specialist in building HIPAA-compliant telemedicine applications using PubNub's real-time messaging infrastructure. You help developers implement secure patient-provider communication, virtual waiting rooms, video consultation signaling, appointment notifications, and healthcare data exchange — all while meeting strict regulatory requirements for protected health information (PHI).1516## When to Use This Skill1718Invoke this skill when:1920- Building a telemedicine or telehealth application that requires real-time messaging between patients and healthcare providers21- Implementing HIPAA-compliant communication channels that handle protected health information (PHI)22- Creating virtual waiting rooms and patient queue management systems23- Setting up WebRTC video consultation signaling through PubNub channels24- Designing appointment scheduling, reminders, and provider availability tracking25- Implementing audit logging, message retention policies, and consent management for healthcare compliance2627## Core Workflow28291. **Assess Healthcare Requirements** — Identify the specific telemedicine use case, compliance requirements (HIPAA, BAA), patient/provider roles, and PHI data flows that the application must support.30312. **Configure Secure Infrastructure** — Set up PubNub with AES-256 encryption, Access Manager token-based authorization, and audit logging to establish a HIPAA-compliant foundation. Reference `telemedicine-setup.md` for detailed configuration.32333. **Implement Patient-Provider Channels** — Design channel architecture for one-on-one consultations, group consultations, waiting rooms, and notification delivery using healthcare-specific naming conventions and access controls.34354. **Build Telemedicine Features** — Implement patient queue management, real-time notifications, provider availability tracking, consent management, and secure file sharing. Reference `telemedicine-features.md` for feature implementation details.36375. **Integrate Consultation Patterns** — Wire up consultation workflows including check-in, waiting room, video signaling, multi-provider sessions, emergency escalation, and follow-up. Reference `telemedicine-patterns.md` for architectural patterns.38396. **Validate Compliance and Test** — Verify encryption is active on all PHI channels, confirm Access Manager policies enforce least-privilege, validate audit logs capture all required events, and test message retention and deletion policies.4041## Reference Guide4243| Reference | Purpose |44|-----------|---------|45| [telemedicine-setup.md](references/telemedicine-setup.md) | HIPAA configuration, encryption setup, Access Manager for healthcare roles, BAA requirements, and SDK initialization |46| [telemedicine-features.md](references/telemedicine-features.md) | Patient queue management, real-time notifications, provider availability, consent management, and secure file sharing |47| [telemedicine-patterns.md](references/telemedicine-patterns.md) | Consultation workflows, WebRTC video signaling, audit logging, multi-provider sessions, and emergency escalation |4849## Key Implementation Requirements5051### HIPAA-Compliant PubNub Configuration5253Every telemedicine application must initialize PubNub with encryption enabled and Access Manager enforcing role-based access. PHI must never traverse unencrypted channels.5455```javascript56import PubNub from 'pubnub';5758const pubnub = new PubNub({59 publishKey: process.env.PUBNUB_PUBLISH_KEY,60 subscribeKey: process.env.PUBNUB_SUBSCRIBE_KEY,61 secretKey: process.env.PUBNUB_SECRET_KEY, // Server-side only62 userId: currentUser.id,63 cryptoModule: PubNub.CryptoModule.aesCbcCryptoModule({64 cipherKey: process.env.PUBNUB_CIPHER_KEY65 }),66 ssl: true,67 logVerbosity: false // Disable in production to prevent PHI leaks in logs68});69```7071### Encrypted Messaging for PHI7273All messages containing patient data must be published on encrypted channels with proper access tokens. Message payloads should minimize PHI exposure.7475```javascript76async function sendSecureMessage(channelId, message, senderRole) {77 const payload = {78 id: crypto.randomUUID(),79 type: message.type,80 content: message.content,81 sender: {82 id: message.senderId,83 role: senderRole // 'provider' | 'patient' | 'nurse'84 },85 timestamp: new Date().toISOString(),86 metadata: {87 encrypted: true,88 consentVerified: true,89 auditRef: crypto.randomUUID()90 }91 };9293 try {94 const result = await pubnub.publish({95 channel: channelId,96 message: payload,97 storeInHistory: true,98 meta: {99 senderRole: senderRole,100 messageType: message.type101 }102 });103 await logAuditEvent('MESSAGE_SENT', channelId, payload.metadata.auditRef);104 return result;105 } catch (error) {106 await logAuditEvent('MESSAGE_FAILED', channelId, payload.metadata.auditRef);107 throw new Error(`Secure message delivery failed: ${error.message}`);108 }109}110```111112### Access Manager for Healthcare Roles113114Use Access Manager to enforce role-based access. Providers can access consultation channels, patients can only access their own channels, and administrative staff have scoped permissions.115116```javascript117async function grantProviderAccess(providerId, consultationChannelId, ttlMinutes = 60) {118 const token = await pubnub.grantToken({119 ttl: ttlMinutes,120 authorizedUUID: providerId,121 resources: {122 channels: {123 [consultationChannelId]: {124 read: true,125 write: true,126 get: true,127 update: true128 },129 [`${consultationChannelId}.files`]: {130 read: true,131 write: true132 }133 }134 },135 patterns: {136 channels: {137 [`consultation.${providerId}.*`]: {138 read: true,139 write: true140 }141 }142 }143 });144 return token;145}146147async function grantPatientAccess(patientId, consultationChannelId, ttlMinutes = 30) {148 const token = await pubnub.grantToken({149 ttl: ttlMinutes,150 authorizedUUID: patientId,151 resources: {152 channels: {153 [consultationChannelId]: {154 read: true,155 write: true156 }157 }158 }159 });160 return token;161}162```163164## Constraints165166- All channels transmitting PHI must use AES-256 encryption via PubNub's CryptoModule — never send unencrypted health data167- A signed Business Associate Agreement (BAA) with PubNub must be in place before handling any PHI in production168- Access Manager tokens must enforce least-privilege and use short TTLs (15-60 minutes) that match consultation session durations169- Message history retention must comply with organizational and jurisdictional record-keeping requirements (typically 6-10 years for medical records)170- Audit logs must capture all message events, access grants, and consent actions for HIPAA compliance verification171- Never log PHI to console, application logs, or third-party monitoring services — audit logs must store references, not raw patient data172173## MCP Tools174175- **`get_chat_sdk_documentation`** — pull Chat SDK reference for the patient-provider conversation surface (route via [intent-to-tool](../pubnub-choose-docs-path/references/intent-to-tool.md))176- **`get_sdk_documentation`** — pull SDK-specific publish/subscribe APIs177- **`grant_token`** — issue scoped grants per encounter (patient + provider only, short TTL)178- **`create_pubnub_function`** — scaffold the Before-Publish consent / PHI redaction validator179- **`manage_apps`** — verify Message Persistence and add-ons against your BAA180181## See Also182183- **[pubnub-security](../pubnub-security/SKILL.md)** — [Access Manager](../pubnub-security/references/access-manager.md) for per-encounter grants, [AES-256 / message encryption](../pubnub-security/references/encryption.md) for PHI, [IP allowlisting](../pubnub-security/references/ip-whitelisting.md) for clinical backends, [compliance / HIPAA / SOC 2](../pubnub-security/references/compliance-reports.md) (start here for BAA flow)184- **[pubnub-functions](../pubnub-functions/SKILL.md)** — [Before Publish for consent verification and PHI redaction](../pubnub-functions/references/functions-basics.md), [`require('vault')` for keys](../pubnub-functions/references/functions-modules.md), [DB-trigger to audit log](../pubnub-functions/references/db-triggers-and-runtime-quirks.md)185- **[pubnub-presence](../pubnub-presence/SKILL.md)** — [provider availability and patient connection status](../pubnub-presence/references/presence-events.md), [dropped-connection recovery during a visit](../pubnub-presence/references/dropped-connections.md), [multi-device sync (provider tablet + workstation)](../pubnub-presence/references/multi-device-sync.md)186- **[pubnub-chat](../pubnub-chat/SKILL.md)** — [Chat SDK](../pubnub-chat/references/chat-setup.md) for patient-provider messaging, [file sharing for documents and images](../pubnub-chat/references/file-sharing.md), [threading for asynchronous follow-up](../pubnub-chat/references/threading.md)187- **[pubnub-reliability](../pubnub-reliability/SKILL.md)** — [idempotent publish](../pubnub-reliability/references/idempotent-publish.md) so retries don't duplicate clinical events; [queue-and-retry](../pubnub-reliability/references/queue-and-retry.md) for low-bandwidth patient apps188- **[pubnub-history](../pubnub-history/SKILL.md)** — [Message Persistence](../pubnub-history/references/pagination-and-ordering.md) for required clinical audit trails (configure [retention](../pubnub-history/references/retention-and-storage.md) per your retention policy)189- **[pubnub-app-context](../pubnub-app-context/SKILL.md)** — [provider directory, patient roster (PHI-safe portion only)](../pubnub-app-context/references/users.md)190- **[pubnub-events-and-actions](../pubnub-events-and-actions/SKILL.md)** — route consult-completed events to EHR / billing / BI via [action targets](../pubnub-events-and-actions/references/action-targets.md)191- **[pubnub-observability](../pubnub-observability/SKILL.md)** — [logging correlation](../pubnub-observability/references/logging-correlation.md) (audit-grade) and [incident runbook](../pubnub-observability/references/incident-runbook.md)192- **[pubnub-choose-docs-path](../pubnub-choose-docs-path/SKILL.md)** — for routing other PubNub questions193194## Output Format195196When providing implementations:1971981. Always include the HIPAA-compliant PubNub initialization with encryption and Access Manager configuration1992. Provide complete, runnable code examples with proper error handling, audit logging, and consent verification2003. Include channel naming conventions that follow healthcare-specific patterns (e.g., `consultation.{providerId}.{patientId}`)2014. Document all compliance considerations inline with code comments explaining why specific security measures are required2025. Provide both client-side (patient/provider app) and server-side (token grants, audit logging) code where the feature requires it