mcpField
P
pubnub-order-delivery-driver

pubnub-order-delivery-driver

github.com/pubnubDevelopment641 installsUpdated 6w ago
Repository

About pubnub-order-delivery-driver

pubnub-order-delivery-driver is a PubNub-focused skill for developers designing real-time order tracking and delivery systems. It covers location streams, order states, dispatch, and ETAs, with guidance on channel separation, access control, and failure handling.

Key features

  1. 01Design order and driver channel structures
  2. 02Implement GPS location streaming
  3. 03Build validated order status flows
  4. 04Assign drivers by proximity and availability
  5. 05Handle ETAs, reconnection, and proof of delivery

Use cases

  1. 01Develop a customer-facing live delivery tracker
  2. 02Implement driver location updates and order status broadcasts
  3. 03Build fleet dashboards and dispatch workflows

MCP support

The skill uses PubNub MCP to retrieve SDK documentation and provides tools for managing Functions, access tokens, and app configuration. Without MCP tools, it cautions against guessing API shapes, limits, or configuration values.

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/pubnub/skills --skill pubnub-order-delivery-driver

After installing, type/pubnub-order-delivery-driverin Claude Code to confirm it loaded.

Bundled files

References and scripts installed along with SKILL.md.

tile.json
evals/
instructions.json
summary_infeasible.json
summary.json
evals/scenario-0/
capability.txt
criteria.json
task.md
evals/scenario-1/
capability.txt
criteria.json
task.md
evals/scenario-2/
capability.txt
criteria.json
task.md
evals/scenario-3/
capability.txt
criteria.json
task.md
evals/scenario-4/
capability.txt
criteria.json
task.md
references/
delivery-patterns.md
delivery-setup.md
delivery-status.md

Details

From the project README

PubNub Order & Delivery Driver Specialist

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.

Precedence: PubNub MCP tools and pubnub.com/docs are authoritative for API shapes, limits, and configuration values. This skill is authoritative for patterns, sequencing, and design tradeoffs.

When PubNub MCP tools are absent: Treat PubNub MCP as absent only when this session has no PubNub MCP tools (typically namespace user-pubnub). Do not ask the user to check MCP if those tools are already listed. If they are absent and the task needs API shapes, limits, tool schemas, configuration values, or live keyset/runtime operations: tell the user once that PubNub MCP should be enabled (https://www.pubnub.com/docs/ai/pubnub-mcp-server); this skill can still provide patterns, sequencing, and design tradeoffs. Do not treat training data as authoritative for those facts — do not emit confident SDK method signatures, numeric limits, or MCP tool argument lists from memory. Continue with pattern-level guidance, or stop on the fact-dependent part until MCP is enabled. Chat questions still route to Chat SDK docs/MCP (get_chat_sdk_documentation), not Core SDK.

When to Use This Skill

Invoke this skill when:

  • Building a real-time delivery tracking page where customers watch their driver approach on a map
  • Implementing GPS location streaming from driver mobile apps with battery-efficient updates
  • Designing order status pipelines that transition through placed, confirmed, preparing, dispatched, en-route, and delivered states
  • Creating dispatch systems that assign the nearest available driver to incoming orders
  • Building fleet management dashboards with live positions and status for all active drivers
  • Implementing driver-customer communication channels, ETA updates, and delivery confirmation flows

Core Workflow

  1. Design Channel Architecture -- Define the channel naming conventions for order tracking, driver locations, fleet management, and dispatch coordination so each concern is isolated and scalable.
  2. Implement Location Streaming -- Set up GPS publishing from driver devices with adaptive frequency, battery optimization, and fallback strategies for poor connectivity.
  3. Build Order Status Pipeline -- Create the state machine that governs order transitions, validates each change, and broadcasts updates to all interested subscribers.
  4. Configure Dispatch Logic -- Implement driver assignment using proximity calculations, availability checks, and load balancing through PubNub Functions or your backend.
  5. Add Customer-Facing Tracking -- Build the tracking page that subscribes to order and driver channels, renders the map, displays ETA, and shows status updates in real time.
  6. Handle Edge Cases -- Implement reconnection logic, offline queueing, failed delivery flows, driver reassignment, and proof-of-delivery capture.

Reference Guide

ReferencePurpose
delivery-setup.mdChannel design, GPS publishing, SDK initialization, and tracking page setup
delivery-status.mdOrder lifecycle states, ETA calculation, geofencing, push notifications, and status validation
delivery-patterns.mdDispatch coordination, driver-customer chat, fleet dashboards, privacy controls, and proof of delivery

Key Implementation Requirements

GPS Location Publishing

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;
}
Order Tracking Channels

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);
      }
    }
  });
}
Status Updates with Validation

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
});

Constraints

  • Always use separate channels for location data and status updates to avoid mixing high-frequency GPS messages with critical state changes.
  • Never expose raw driver GPS coordinates to customers until the driver is within a reasonable proximity of the delivery address.
  • Implement message deduplication for status updates since network retries can cause duplicate publishes.
  • Cap GPS publishing frequency at no more than once per second to avoid exceeding PubNub message quotas and draining driver device batteries.
  • Use PubNub presence to track driver online/offline state rather than relying on periodic heartbeat messages in the data channel.
  • Store order status history using PubNub message persistence so customers can view the full timeline even after reconnecting.

MCP Tools

  • get_sdk_documentation — pull SDK-specific publish/subscribe APIs (route via intent-to-tool)
  • manage_functions (resource=package, operation=create) — create the After-Publish geofence trigger / dispatch logic package
  • grant_token — issue scoped grants per order (driver, customer, dispatcher)
  • manage_apps — verify Stream Controller for fleet dashboard fan-in

See Also

Output Format

When providing implementations:

  1. Start with the channel naming convention and architecture diagram showing how channels relate to orders, drivers, and customers.
  2. Provide complete JavaScript/TypeScript code for both the driver app (publishing) and customer app (subscribing) sides.
  3. Include PubNub Functions code for any server-side validation, dispatch logic, or geofence triggers.
  4. Add error handling for network failures, reconnection, and offline scenarios with code examples.
  5. Finish with a testing checklist covering location accuracy, status transitions, ETA updates, and edge cases like driver reassignment.

Comments

Markdown supported