manual-test.js•1.81 kB
// Manual test to verify bot access
import dotenv from 'dotenv';
dotenv.config();
import { conversationsHistory, channelsList } from '../dist/tools.js';
const TEST_TOKEN = process.env.SLACK_TEST_TOKEN;
async function runManualTests() {
console.log('=== Manual Testing ===\n');
// Test 1: List all channels to find one the bot has access to
console.log('1. Listing all channels...');
const channelsResult = await channelsList({
accessToken: TEST_TOKEN,
channel_types: 'public_channel,private_channel',
limit: 100
});
if (channelsResult.success) {
console.log(`Found ${channelsResult.data.channels.length} channels`);
console.log('\nChannels the bot might have access to:');
channelsResult.data.channels.forEach(ch => {
console.log(` - #${ch.name} (${ch.id}) - ${ch.member_count} members`);
});
// Try the general channel or first available
const testChannel = channelsResult.data.channels.find(ch => ch.name === 'general')
|| channelsResult.data.channels[0];
if (testChannel) {
console.log(`\n2. Testing conversations_history on #${testChannel.name}...`);
const historyResult = await conversationsHistory({
accessToken: TEST_TOKEN,
channel_id: testChannel.id,
limit: 5
});
if (historyResult.success) {
console.log(`✅ SUCCESS! Retrieved ${historyResult.data.messages.length} messages`);
console.log('Sample message:', JSON.stringify(historyResult.data.messages[0], null, 2));
} else {
console.log(`❌ Error: ${historyResult.error}`);
console.log('Bot may need to be added to this channel too.');
}
}
} else {
console.log(`Error listing channels: ${channelsResult.error}`);
}
}
runManualTests().catch(console.error);