MCPcopy Create free account
hub / github.com/adcontextprotocol/adcp / main

Function main

scripts/test-slack-sync.ts:19–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17dotenv.config({ path: path.join(__dirname, '..', '.env.local') });
18
19async function main() {
20 console.log('🔍 Testing Slack Integration\n');
21
22 // Dynamic import after env is loaded
23 const { testSlackConnection, getSlackUsers, isSlackConfigured } = await import('../server/src/slack/client.js');
24
25 // Check if configured
26 if (!isSlackConfigured()) {
27 console.log('❌ SLACK_BOT_TOKEN is not set in environment');
28 console.log(' Add it to .env.local and try again');
29 process.exit(1);
30 }
31
32 console.log('✅ SLACK_BOT_TOKEN is configured\n');
33
34 // Test connection
35 console.log('🔗 Testing Slack connection...');
36 const connection = await testSlackConnection();
37
38 if (!connection.ok) {
39 console.log(`❌ Connection failed: ${connection.error}`);
40 process.exit(1);
41 }
42
43 console.log(`✅ Connected to workspace: ${connection.team}`);
44 console.log(` Bot user: ${connection.user} (${connection.user_id})`);
45 console.log(` Bot ID: ${connection.bot_id}\n`);
46
47 // Fetch users
48 console.log('👥 Fetching Slack users...');
49 const users = await getSlackUsers();
50
51 const realUsers = users.filter(u => !u.is_bot && !u.deleted);
52 const bots = users.filter(u => u.is_bot);
53 const deleted = users.filter(u => u.deleted);
54
55 console.log(`✅ Found ${users.length} total users:`);
56 console.log(` - ${realUsers.length} active users`);
57 console.log(` - ${bots.length} bots`);
58 console.log(` - ${deleted.length} deleted/deactivated\n`);
59
60 // Show sample of users
61 console.log('📋 Sample users (first 10 active):');
62 realUsers.slice(0, 10).forEach(user => {
63 const email = user.profile?.email || '(no email)';
64 const name = user.profile?.real_name || user.name;
65 console.log(` - ${name} <${email}>`);
66 });
67
68 if (realUsers.length > 10) {
69 console.log(` ... and ${realUsers.length - 10} more`);
70 }
71
72 console.log('\n✅ Slack integration is working!');
73 console.log('\nNext steps:');
74 console.log('1. Start the server: npm run dev');
75 console.log('2. Run migrations: npm run db:migrate (or restart Docker)');
76 console.log('3. Call POST /api/admin/slack/sync to sync users to database');

Callers 1

test-slack-sync.tsFile · 0.70

Calls 3

isSlackConfiguredFunction · 0.85
testSlackConnectionFunction · 0.85
getSlackUsersFunction · 0.85

Tested by

no test coverage detected