collabSupport/commands/vcProvision.js
jmcqueen 351f89a9a4 Initial commit: CollabFinder Webex bot
Multi-integration Webex chat/HTTP bot that unifies phone, AV, and
network status for retail store support. Consolidates data from
Webex Calling, Meraki, Workspace ONE (MDM), Atlas AMP, RED digital
signage, and OptiSigns into rich per-store status commands.

Key surfaces:
- /phonestatus, /avstatus — per-store phone & AV device reports with
  clickable Meraki deep-links and per-port detail.
- /webexhost — check/assign Webex Meetings host licenses via the
  Service App; adaptive-card confirmation flow, HTTP-API-gated.
- /offboarduser — full Webex Admin offboarding (auth revoke, device
  wipe, license removal); adaptive-card confirmation.
- /jirapoll — on-demand trigger for the hourly Jira poller.
- /bulkavstatuscsv — bulk store CSV export with concurrency limits.

Automation:
- Hourly Jira poller (node-cron) with an X.AI (Grok) ticket classifier
  that categorizes unassigned tickets as phone/av/skip, extracts store
  numbers from free-text, and enriches Jira with the same detailed
  markdown the chat commands emit (converted to Jira ADF, preserves
  bold + Meraki links). Idempotent via a `bot-enriched` Jira label.

Architecture:
- Node.js 20+, ESM, Express 5, webex-node-bot-framework.
- Layered integrations (integrations/*), services (services/*),
  commands (commands/*), utils (utils/*).
- Shared markdown renderers (services/renderers/*) feed both chat
  handlers and the Jira poller so the two surfaces stay in sync.
- Hand-rolled markdown-to-ADF converter (utils/markdownToAdf.js) —
  no new npm dependency.
- Node built-in test runner (`node --test tests/*.test.js`), 30 tests
  covering the converter, renderers, and poller ADF assembly.

Docker + docker-compose deployment. Config via .env
(see .env.example for the full option surface).
2026-07-01 16:55:03 -04:00

44 lines
No EOL
1.6 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// src/commands/vcProvision.js
// Command: /provision-vc (supports org selection for multi-org)
import { provisionVideoDevice } from '../services/vcProvisionService.js';
import { logger } from '../utils/logger.js';
export async function handleProvisionVc(bot, trigger) {
logger('vc-provision', 'Handler entered');
const args = trigger.args || [];
const serialNumber = args[0]?.trim();
const orgIdentifier = args[1]?.trim();
if (!serialNumber) {
logger('vc-provision', 'No serial number provided showing usage', 'warn');
await bot.say('markdown',
'**Usage:** `/provision-vc <serialNumber> [org]`\n\n' +
'Example: `/provision-vc FOC2419NTN2`\n' +
'Example (specific org): `/provision-vc FOC2419NTN2 todd`\n\n' +
'org can be a partial name ("american", "todd", "snyder") or full org ID.\n\n' +
'This will:\n' +
'• Apply standard configuration\n' +
'• Generate and install a new certificate from DigiCert\n' +
'• Add backdoor admin account (`monitor`)\n' +
'• Reboot the device'
);
return;
}
logger('vc-provision', `Starting provisioning for serial: ${serialNumber}${orgIdentifier ? ` (org: ${orgIdentifier})` : ''}`);
try {
// Pass the bot instance so the service can send live progress updates
await provisionVideoDevice(bot, serialNumber, orgIdentifier);
} catch (error) {
logger('vc-provision', `Provisioning failed for ${serialNumber}: ${error.message}`, 'error');
// Fallback error message to user
await bot.say('markdown',
`❌ **Provisioning failed for ${serialNumber}**\n\n` +
`${error.message}`
);
}
}