pubnub-order-delivery-driver/SKILL.md
Build real-time order tracking and delivery driver systems with PubNub
npx skillsauth add pubnub/skills pubnub-order-delivery-driverInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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 andfetchMessages, 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.).
You are a specialist in building real-time order tracking and delivery driver systems using PubNub. You help developers implement end-to-end delivery experiences including GPS location streaming, order status management, dispatch coordination, ETA calculations, and fleet visibility. You produce production-ready code that handles the full delivery lifecycle from order placement through proof of delivery.
Invoke this skill when:
| Reference | Purpose | |-----------|---------| | delivery-setup.md | Channel design, GPS publishing, SDK initialization, and tracking page setup | | delivery-status.md | Order lifecycle states, ETA calculation, geofencing, push notifications, and status validation | | delivery-patterns.md | Dispatch coordination, driver-customer chat, fleet dashboards, privacy controls, and proof of delivery |
Driver apps must publish location updates to a dedicated driver channel. Use adaptive frequency -- publish more often when the driver is moving and less often when stationary.
import PubNub from 'pubnub';
const pubnub = new PubNub({
publishKey: 'pub-key',
subscribeKey: 'sub-key',
userId: 'driver-1234'
});
let lastPublishedLocation = null;
function publishDriverLocation(latitude, longitude, heading, speed) {
const location = {
lat: latitude,
lng: longitude,
heading: heading,
speed: speed,
timestamp: Date.now(),
driverId: 'driver-1234'
};
// Adaptive publishing: skip if driver hasn't moved significantly
if (lastPublishedLocation) {
const distance = haversineDistance(lastPublishedLocation, location);
if (distance < 5 && speed < 1) {
return; // Skip publish if moved less than 5 meters and nearly stationary
}
}
pubnub.publish({
channel: 'driver.driver-1234.location',
message: location
});
lastPublishedLocation = location;
}
Each order gets its own channel for status updates. Customers subscribe to their order channel and the assigned driver's location channel.
function subscribeToOrderTracking(orderId, driverId) {
pubnub.subscribe({
channels: [
`order.${orderId}.status`,
`driver.${driverId}.location`
]
});
pubnub.addListener({
message: (event) => {
if (event.channel.includes('.status')) {
updateOrderStatusUI(event.message);
} else if (event.channel.includes('.location')) {
updateDriverMarkerOnMap(event.message);
recalculateETA(event.message);
}
}
});
}
Publish order status transitions with metadata. Use PubNub Functions to validate that transitions follow the allowed state machine.
async function updateOrderStatus(orderId, newStatus, metadata = {}) {
const statusUpdate = {
orderId: orderId,
status: newStatus,
timestamp: Date.now(),
...metadata
};
await pubnub.publish({
channel: `order.${orderId}.status`,
message: statusUpdate
});
// Also update the dispatch channel so fleet managers see the change
await pubnub.publish({
channel: 'dispatch.status-updates',
message: statusUpdate
});
}
// Example transitions
await updateOrderStatus('order-5678', 'dispatched', {
driverId: 'driver-1234',
estimatedDelivery: Date.now() + 25 * 60 * 1000
});
get_sdk_documentation — pull SDK-specific publish/subscribe APIs (route via intent-to-tool)create_pubnub_function — scaffold the After-Publish geofence trigger / dispatch logicgrant_token — issue scoped grants per order (driver, customer, dispatcher)manage_apps — verify Stream Controller for fleet dashboard fan-inrequire('kvstore') for last-known-location, DB-trigger pattern to mirror to your warehousesignal for high-frequency GPS via payload hygieneWhen providing implementations:
tools
Builds real-time analytics and automation with PubNub Illuminate. Covers Business Objects (schema), Metrics (aggregations), Decisions (threshold-triggered actions with the 4-step PUT workflow), Queries (ad-hoc vs saved pipelines), and Dashboards. Use when tracking KPIs, building threshold alerts, automating mute/publish/App-Context-update actions, detecting spam or anomalies, or visualizing live activity.
testing
Scale PubNub applications for high-volume real-time events using channel groups, wildcard subscriptions, sharding, and large-event readiness. Covers Stream Controller add-on, hard caps, payload coalescing referenced into pubnub-observability, and the engagement model for 10K+ concurrent live events. Persistence/history is owned by pubnub-history.
tools
Deliver real-time sports scores, play-by-play, and scoreboards with PubNub
development
Create, configure, and deploy PubNub Functions 2.0 event handlers, triggers, and serverless endpoints. Covers Before/After Publish, On Request, On Interval; built-in modules (kvstore, xhr, vault, pubnub, crypto, jwt, ugc, jsonpath, advanced_math, codec/*); chaining (3 hops, 5 consecutive, Chaining vs Forking, kvstore state sharing); runtime quirks (3-call external cap, 10-call vault cap, cold start, request.path normalization, vault availability, sendFile message); DB-trigger patterns; and bundling/TypeScript workflow (esbuild externals, 64KB guard, __require shim stripping, default-export shape). Use when building real-time message transformations, edge data processing, REST endpoints backed by PubNub, webhook integrations, or shipping bundled/transpiled TypeScript Functions from inside the message pipeline.