websocket-realtime

Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".

7 stars

Best use case

websocket-realtime is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".

Teams using websocket-realtime should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/websocket-realtime/SKILL.md --create-dirs "https://raw.githubusercontent.com/heldernoid/agentic-build-templates/main/projects/web-applications/poll-builder/skills/websocket-realtime/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/websocket-realtime/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How websocket-realtime Compares

Feature / Agentwebsocket-realtimeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Use the WebSocket connection in poll-builder to receive live vote updates. Use when you need to stream real-time poll results, monitor a poll for new votes, or build a live dashboard. Triggers include "live results", "real-time updates", "stream votes", "watch poll", or "WebSocket".

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

SKILL.md Source

# websocket-realtime

Receive live vote updates from poll-builder via WebSocket.

## Connection

```
ws://localhost:3000/ws
```

## Protocol

### Subscribe to a poll

After connecting, send a subscribe message with the poll slug:

```json
{ "type": "subscribe", "slug": "k9xm2q4r" }
```

### Receive updates

The server sends an update message after each successful vote:

```json
{
  "type": "update",
  "slug": "k9xm2q4r",
  "results": [
    { "optionId": 1, "text": "Mobile app",        "votes": 396, "pct": 48.1 },
    { "optionId": 2, "text": "API improvements",  "votes": 255, "pct": 31.0 },
    { "optionId": 3, "text": "Better docs",       "votes": 123, "pct": 14.9 },
    { "optionId": 4, "text": "Admin dashboard",   "votes": 50,  "pct": 6.1  }
  ],
  "totalVotes": 824
}
```

### Unsubscribe

Close the connection or send:

```json
{ "type": "unsubscribe", "slug": "k9xm2q4r" }
```

## Example (Node.js)

```javascript
import WebSocket from 'ws';

const ws = new WebSocket('ws://localhost:3000/ws');

ws.on('open', () => {
  ws.send(JSON.stringify({ type: 'subscribe', slug: 'k9xm2q4r' }));
});

ws.on('message', (data) => {
  const msg = JSON.parse(data.toString());
  if (msg.type === 'update') {
    console.log(`Total votes: ${msg.totalVotes}`);
    msg.results.forEach(r => {
      console.log(`  ${r.text}: ${r.votes} (${r.pct}%)`);
    });
  }
});
```

## Multiple subscriptions

A single WebSocket connection can subscribe to multiple polls:

```json
{ "type": "subscribe", "slug": "k9xm2q4r" }
{ "type": "subscribe", "slug": "7bwq1pz3" }
```

Each update message includes the `slug` field to identify which poll triggered it.

## Error handling

If the slug does not exist:
```json
{ "type": "error", "message": "poll_not_found", "slug": "k9xm2q4r" }
```

The connection remains open - you can subscribe to other slugs.

## Notes

- Updates are broadcast only to clients subscribed to the relevant slug
- Closed polls do not generate updates (no new votes accepted)
- The WebSocket server is part of the same Node.js process as the HTTP server
- No authentication required for public WebSocket connections