Skip to content

Slack Adapter

The Slack adapter is fully implemented and supports connecting to onebots service through Slack Bot API.

Status

Implemented and Available

Features

  • Message Sending/Receiving
    • Channel message sending/receiving
    • One-to-one and multi-person direct messages (MPIM)
    • Text, files, threads, Block Kit, and streaming messages
    • Streaming chunks, task timeline/plan views, Agent Session status, and authorship
  • Message Management
    • Message editing
    • Message deletion
  • Channel Management
    • Get channel list and information
    • Leave channel
    • Get channel member list
  • User Management
    • Get user information
  • Event Subscription
    • Socket Mode, HTTP Events, and manual ingestion
    • Acknowledgement only after synchronous and asynchronous listeners succeed
  • Extended Features
    • App commands (Slash Commands, requires additional configuration)
    • Interactive components, Canvas, Modal, and App Home
    • Slack Lists, Calls, and remote-file indexing/sharing

Installation

Open Extensions in the Web console and select the adapter, or run:

bash
onebots ui --data-dir <workspace> --setup

The manager installs the adapter and its required peer dependencies into a verified immutable runtime generation. Do not run package-manager install commands directly in the OneBots runtime directory.

Configuration

Configure Slack account in config.yaml:

yaml
# Slack bot account configuration
slack.your_bot_id:
  # Slack platform configuration
  token: 'xoxb-your-bot-token'  # Slack Bot Token, required
  receive_mode: socket  # socket (default), webhook, or manual
  app_token: 'xapp-your-app-token'  # Required in Socket Mode
  
  # OneBot V11 protocol configuration
  onebot.v11:
    access_token: 'your_v11_token'
  
  # OneBot V12 protocol configuration
  onebot.v12:
    access_token: 'your_v12_token'

Client SDK Usage

typescript
import { createOnebot12Client } from '@imhelper/onebot-v12';

const client = createOnebot12Client({
  baseUrl: 'http://localhost:6727/slack/your_bot_id/onebot/v12',
  selfId: 'your_bot_id',
  accessToken: 'your_access_token',
  receiveMode: 'ws',
});

client.on('message.channel', async message => {
  await message.reply('Received!');
});

await client.start();