socketmode_handler

command
v0.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2026 License: BSD-2-Clause Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

This example demonstrates the SocketmodeHandler, a higher-level API that routes Socket Mode events to registered handler functions instead of requiring a manual event-loop switch.

Socket Mode requires two tokens:

  • App-level token (xapp-…): opens the WebSocket connection via apps.connections.open. Generate one in your app settings under Basic Information → App-Level Tokens with the connections:write scope.

  • Bot token (xoxb-…): used for all Web API calls (posting messages, opening views, etc.). This is the token you get after installing the app to a workspace.

The bot token is passed to slack.New() as the primary credential; the app-level token is passed via slack.OptionAppLevelToken().

To run:

export SLACK_APP_TOKEN=xapp-...
export SLACK_BOT_TOKEN=xoxb-...
go run examples/socketmode_handler/socketmode_handler.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL