Skip to main content

Slack Integration

The Slack provider gives your applications governed access to Slack credentials — bot tokens, app-level tokens, user tokens, and webhook URLs — with automatic token type detection and audit logging.

Setup

import { WisperaSlackProvider } from '@anthropics/id-wispera';

const slack = new WisperaSlackProvider({ vaultPath: '~/.id-wispera' });

Bot Token

Retrieve a bot token (xoxb-...).
const botToken = await slack.getBotToken('slack-bot');

App-Level Token

Retrieve an app-level token (xapp-...) for Socket Mode or Events API.
const appToken = await slack.getAppToken('slack-app');

User Token

Retrieve a user token (xoxp-...).
const userToken = await slack.getUserToken('slack-user');

Webhook URL

Retrieve a Slack webhook URL.
const webhookUrl = await slack.getWebhookUrl('slack-webhook');

Typed Credential (Auto-Detection)

Retrieve a credential with automatic token type detection based on prefix:
PrefixDetected Type
xoxb-bot
xoxp-user
xapp-app-level
hooks.slack.comwebhook
The result also extracts team_id from passport tags.
const typed = await slack.getSlackCredential('slack-bot');
console.log(typed.tokenType); // 'bot' | 'user' | 'app-level' | 'webhook'
console.log(typed.teamId);    // extracted from tags
console.log(typed.value);     // the actual token

List Slack Credentials

List all Slack-related credentials in the vault.
const creds = await slack.listSlackCredentials();
for (const c of creds) {
  console.log(c.name, c.tokenType);
}

Socket Mode

Retrieve both bot and app-level tokens together for Socket Mode connections.
const socketTokens = await slack.getSocketModeTokens('slack-bot', 'slack-app');
console.log(socketTokens.botToken);  // xoxb-...
console.log(socketTokens.appToken);  // xapp-...

Full Example

import { WisperaSlackProvider } from '@anthropics/id-wispera';

const slack = new WisperaSlackProvider({ vaultPath: '~/.id-wispera' });

// Get tokens for Socket Mode
const socketTokens = await slack.getSocketModeTokens('slack-bot', 'slack-app');

// Auto-detect token type
const typed = await slack.getSlackCredential('slack-bot');
console.log('Token type:', typed.tokenType);
console.log('Team:', typed.teamId);

// List all Slack credentials
const allCreds = await slack.listSlackCredentials();
console.log('Slack credentials in vault:', allCreds.length);

Next Steps