|
|
|
|
@@ -10,6 +10,7 @@ This guide explains how to integrate your bot with the Jackbox Game Picker API f
|
|
|
|
|
- [Webhook Integration](#webhook-integration)
|
|
|
|
|
3. [Webhook Management](#webhook-management)
|
|
|
|
|
4. [Testing](#testing)
|
|
|
|
|
5. [Available Events](#available-events)
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
@@ -219,11 +220,64 @@ All messages are JSON-formatted.
|
|
|
|
|
"pack_name": "The Jackbox Party Pack 9",
|
|
|
|
|
"min_players": 2,
|
|
|
|
|
"max_players": 8,
|
|
|
|
|
"manually_added": false
|
|
|
|
|
"manually_added": false,
|
|
|
|
|
"room_code": "JYET"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Session started event (broadcast to all authenticated clients)
|
|
|
|
|
{
|
|
|
|
|
"type": "session.started",
|
|
|
|
|
"timestamp": "2025-11-01T20:00:00Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"session": {
|
|
|
|
|
"id": 123,
|
|
|
|
|
"is_active": true,
|
|
|
|
|
"created_at": "2025-11-01T20:00:00Z",
|
|
|
|
|
"notes": "Friday game night"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Session ended event (broadcast to session subscribers)
|
|
|
|
|
{
|
|
|
|
|
"type": "session.ended",
|
|
|
|
|
"timestamp": "2025-11-01T23:00:00Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"session": {
|
|
|
|
|
"id": 123,
|
|
|
|
|
"is_active": false,
|
|
|
|
|
"games_played": 8
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Game started event (broadcast to session subscribers)
|
|
|
|
|
// Fired when the Jackbox room becomes locked, meaning gameplay has begun
|
|
|
|
|
{
|
|
|
|
|
"type": "game.started",
|
|
|
|
|
"timestamp": "2025-11-01T20:31:00Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"sessionId": 123,
|
|
|
|
|
"gameId": 456,
|
|
|
|
|
"roomCode": "JYET",
|
|
|
|
|
"maxPlayers": 8
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Audience joined event (broadcast to session subscribers)
|
|
|
|
|
// Confirms the app successfully joined a Jackbox room as an audience member
|
|
|
|
|
{
|
|
|
|
|
"type": "audience.joined",
|
|
|
|
|
"timestamp": "2025-11-01T20:31:05Z",
|
|
|
|
|
"data": {
|
|
|
|
|
"sessionId": 123,
|
|
|
|
|
"gameId": 456,
|
|
|
|
|
"roomCode": "JYET"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Heartbeat response
|
|
|
|
|
{
|
|
|
|
|
"type": "pong"
|
|
|
|
|
@@ -319,9 +373,14 @@ class JackboxWebSocketClient {
|
|
|
|
|
|
|
|
|
|
handleGameAdded(data) {
|
|
|
|
|
const { game } = data;
|
|
|
|
|
const announcement = `🎮 Coming up next: ${game.title}!`;
|
|
|
|
|
|
|
|
|
|
// Send to your chat platform
|
|
|
|
|
// Build announcement with room code if available
|
|
|
|
|
let announcement = `🎮 Coming up next: ${game.title}!`;
|
|
|
|
|
if (game.room_code) {
|
|
|
|
|
announcement += ` Join at jackbox.tv with code: ${game.room_code}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Send to your chat platform (e.g., Kosmi chat)
|
|
|
|
|
this.broadcastToChat(announcement);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -395,12 +454,15 @@ Triggered whenever a game is added to an active session (either via picker or ma
|
|
|
|
|
"pack_name": "The Jackbox Party Pack 9",
|
|
|
|
|
"min_players": 2,
|
|
|
|
|
"max_players": 8,
|
|
|
|
|
"manually_added": false
|
|
|
|
|
"manually_added": false,
|
|
|
|
|
"room_code": "JYET"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
> **Note:** `room_code` is the 4-character Jackbox room code (e.g. `"JYET"`). It will be `null` if no room code was provided when the game was added.
|
|
|
|
|
|
|
|
|
|
### Webhook Headers
|
|
|
|
|
|
|
|
|
|
The API sends the following headers with each webhook:
|
|
|
|
|
@@ -481,10 +543,16 @@ app.post('/webhook/jackbox', (req, res) => {
|
|
|
|
|
if (req.body.event === 'game.added') {
|
|
|
|
|
const game = req.body.data.game;
|
|
|
|
|
|
|
|
|
|
// Send message to Kosmi chat
|
|
|
|
|
sendKosmiMessage(`🎮 Coming up next: ${game.title}!`);
|
|
|
|
|
// Build announcement with room code if available
|
|
|
|
|
let message = `🎮 Coming up next: ${game.title}!`;
|
|
|
|
|
if (game.room_code) {
|
|
|
|
|
message += ` Join at jackbox.tv with code: ${game.room_code}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(`Announced game: ${game.title} from ${game.pack_name}`);
|
|
|
|
|
// Send message to Kosmi chat
|
|
|
|
|
sendKosmiMessage(message);
|
|
|
|
|
|
|
|
|
|
console.log(`Announced game: ${game.title} from ${game.pack_name} (code: ${game.room_code || 'N/A'})`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Always respond with 200 OK
|
|
|
|
|
@@ -616,11 +684,22 @@ curl -X GET "http://localhost:5000/api/webhooks/1/logs" \
|
|
|
|
|
|
|
|
|
|
## Available Events
|
|
|
|
|
|
|
|
|
|
Currently supported webhook events:
|
|
|
|
|
### Webhook Events
|
|
|
|
|
|
|
|
|
|
- `game.added` - Triggered when a game is added to an active session
|
|
|
|
|
- `game.added` - Triggered when a game is added to an active session. Includes `room_code` (the 4-character Jackbox join code) if one was provided.
|
|
|
|
|
|
|
|
|
|
More events may be added in the future (e.g., `session.started`, `session.ended`, `vote.recorded`).
|
|
|
|
|
### WebSocket Events
|
|
|
|
|
|
|
|
|
|
- `game.added` - Triggered when a game is added to an active session. Sent to clients subscribed to that session. Includes `room_code`.
|
|
|
|
|
- `session.started` - Triggered when a new session is created. Broadcast to **all** authenticated clients (no subscription required).
|
|
|
|
|
- `session.ended` - Triggered when a session is closed. Sent to clients subscribed to that session.
|
|
|
|
|
- `game.started` - Triggered when the Jackbox room becomes locked (gameplay has begun). Detected by polling the Jackbox REST API every 10 seconds. Sent to clients subscribed to that session. Includes `roomCode` and `maxPlayers`.
|
|
|
|
|
- `audience.joined` - Triggered when the app successfully joins a Jackbox room as an audience member. Sent to clients subscribed to that session. This confirms the room code is valid and the game is being monitored.
|
|
|
|
|
- `player-count.updated` - Triggered when the player count for a game is updated. Sent to clients subscribed to that session.
|
|
|
|
|
|
|
|
|
|
> **Tip:** To receive `session.started` events, your bot only needs to authenticate — no subscription is needed. Once you receive a `session.started` event, subscribe to the new session ID to receive `game.added` and `session.ended` events for it.
|
|
|
|
|
|
|
|
|
|
More events may be added in the future (e.g., `vote.recorded`).
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|