Add Webex booking webhook with occupancy tracking and utilization reports.
Track in-meeting occupancy via xAPI polling and workspaceMetrics, store Webex attendee counts for linked meetings, and surface under-utilized room bookings on the dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
a93a1194e6
8 changed files with 4283 additions and 0 deletions
9
.dockerignore
Normal file
9
.dockerignore
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
node_modules
|
||||
npm-debug.log
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
.git
|
||||
.gitignore
|
||||
README.md
|
||||
.env
|
||||
data/
|
||||
14
.env.example
Normal file
14
.env.example
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
PORT=3000
|
||||
|
||||
# Webex Bot Token (for sending NoShow messages)
|
||||
WEBEX_BOT_TOKEN=your_webex_bot_bearer_token_here
|
||||
|
||||
# OAuth2 credentials for the Operations / Workspace token (the one used in GET /workspaces)
|
||||
WEBEX_CLIENT_ID=your_client_id_here
|
||||
WEBEX_CLIENT_SECRET=your_client_secret_here
|
||||
WEBEX_REFRESH_TOKEN=your_initial_refresh_token_here # We'll populate this on first run
|
||||
|
||||
# Occupancy tracking (optional)
|
||||
OCCUPANCY_POLL_INTERVAL_MS=180000 # Poll xAPI every 3 minutes during active meetings
|
||||
UNDER_UTILIZED_THRESHOLD_PCT=25 # Flag meetings below 25% of room capacity
|
||||
WORKSPACE_METRICS_END_DELAY_MS=45000 # Wait before fetching workspaceMetrics at meeting end
|
||||
20
.gitignore
vendored
Normal file
20
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Dependencies
|
||||
node_modules/
|
||||
|
||||
# Secrets and local config
|
||||
.env
|
||||
tokens/
|
||||
|
||||
# Runtime data
|
||||
data/
|
||||
logs/
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
|
||||
# Editor
|
||||
.idea/
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
42
Dockerfile
Normal file
42
Dockerfile
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
# syntax=docker/dockerfile:1
|
||||
FROM node:20-alpine AS base
|
||||
|
||||
# Stage 1: Dependencies
|
||||
FROM base AS deps
|
||||
WORKDIR /app
|
||||
COPY package*.json ./
|
||||
RUN npm ci --only=production && \
|
||||
# Clean up to keep image small
|
||||
npm cache clean --force
|
||||
|
||||
# Stage 2: Production runtime
|
||||
FROM base AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Create non-root user for security
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 --ingroup nodejs expressuser
|
||||
|
||||
# Copy production dependencies
|
||||
COPY --from=deps /app/node_modules ./node_modules
|
||||
COPY --from=deps /app/package.json ./
|
||||
|
||||
# Copy application code
|
||||
COPY src/ ./src/
|
||||
COPY tokens/ ./tokens/
|
||||
|
||||
# Create data directory for SQLite and set permissions
|
||||
RUN mkdir -p /app/data && \
|
||||
chown -R expressuser:nodejs /app
|
||||
|
||||
USER expressuser
|
||||
|
||||
# Expose port
|
||||
EXPOSE 1867
|
||||
|
||||
# Healthcheck
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=5s --retries=3 \
|
||||
CMD node -e "require('http').get('http://localhost:1867/health', (res) => process.exit(res.statusCode === 200 ? 0 : 1))" || exit 1
|
||||
|
||||
ENV NODE_ENV=production
|
||||
CMD ["node", "src/server.js"]
|
||||
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
version: '3.9'
|
||||
|
||||
services:
|
||||
webhook:
|
||||
build: .
|
||||
container_name: webex-booking-webhook
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "1867:1867" # or whatever port you're using locally
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./data:/app/data # Persistent SQLite DB
|
||||
- ./tokens:/app/tokens # Read-only tokens
|
||||
healthcheck:
|
||||
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:1867/health"]
|
||||
interval: 30s
|
||||
timeout: 5s
|
||||
retries: 3
|
||||
1742
package-lock.json
generated
Normal file
1742
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
23
package.json
Normal file
23
package.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "webex-booking-webhook",
|
||||
"version": "1.0.0",
|
||||
"description": "Webex Booking Webhook → SQLite (NoShow handling + notifications)",
|
||||
"main": "src/server.js",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "node src/server.js",
|
||||
"dev": "nodemon src/server.js",
|
||||
"docker:build": "docker compose build",
|
||||
"docker:up": "docker compose up -d",
|
||||
"docker:logs": "docker compose logs -f"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.8.0",
|
||||
"better-sqlite3": "^11.0.0",
|
||||
"dotenv": "^16.4.0",
|
||||
"express": "^4.21.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^3.1.0"
|
||||
}
|
||||
}
|
||||
2414
src/server.js
Normal file
2414
src/server.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue