netanalyzer/server.js
Joseph McQueen 459301cc4d chore: Phase 0 initial hygiene
- Initialize git repository
- Add comprehensive .gitignore (protects .env and secrets)
- Fix package.json (correct main entry, add metadata)
- Expand .env.example with all required variables and comments
- Add README.md with architecture, setup, and commands
- Clean up empty scaffolding directories (logs removed, agents/models marked)
- Backup previous .env file locally

This establishes a safe foundation before further development.
2026-06-24 13:32:37 -04:00

51 lines
1.8 KiB
JavaScript

const Framework = require('webex-node-bot-framework');
const config = require('./config');
const { startWebSocketServer } = require('./services/websocket');
const { handleStoreCommand, handleAnalyzeCommand } = require('./bot/handlers');
const framework = new Framework({
token: config.webex.token,
removeWebhooksOnStart: true,
logLevel: 'debug'
});
console.log('🚀 Starting NetAnalyzer Framework...');
// Register command handlers
framework.hears(/store/i, handleStoreCommand, '**store <number>** - Analyze a store');
framework.hears(/analyze/i, handleAnalyzeCommand, '**analyze <number>** - High-level store health check');
// Catch-all handler for debugging (lowest priority)
framework.hears(/.*/, (bot, trigger) => {
// Only log and respond if this pattern matched
if (trigger.match && trigger.match[0].length > 0) {
const text = trigger.message.text.toLowerCase();
// Skip if message contains known commands already handled
if (!text.includes('store') && !text.includes('analyze')) {
console.log('📨 Received message:', trigger.message.text);
bot.say('I heard: ' + trigger.message.text + '\nTry: `store <number>` or `analyze <number>` for store analysis');
}
}
}, 99999); // lowest priority
// Framework events
framework.on('initialized', () => {
console.log('✅ Framework initialized and connected via WebSocket!');
});
framework.on('spawn', (bot, id, addedBy) => {
console.log(`🟢 Bot spawned in room: ${bot.room.title || 'Unknown'}`);
if (addedBy) {
bot.say('NetAnalyzer is ready! Try `store <number>` or `analyze <number>`');
}
});
// Start framework and WebSocket server sequentially
framework.start().then(() => {
console.log('WebSocket server for remote agent starting...');
startWebSocketServer();
}).catch(err => {
console.error('❌ Error starting framework:', err);
process.exit(1);
});