Help us shape the future of Go! Take the 2026 Go Developer Survey

slack

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package slack is the notify adapter for Slack (R-374): a channel adapter (R-373) that posts the events a subscription chooses to the Slack channel that subscription names.

It posts as Pando's own Slack app, with the app's bot token. The app is not made by hand: connecting the adapter creates it from a manifest, gives it Pando's icon and installs it in the workspace (connect.go), so a person pastes one configuration token and chooses Allow. Where Slack cannot send the browser back — a Pando without an https address — the app is made from a prefilled link instead and its bot token pasted back.

An adapter set up before that, with an incoming webhook URL, keeps posting through it, to the one channel the webhook names.

Index

Constants

View Source
const (
	FieldBotToken     = "bot_token"
	FieldAppID        = "app_id"
	FieldTeamName     = "team_name"
	FieldClientID     = "client_id"
	FieldClientSecret = "client_secret"
	FieldIconSet      = "icon_set"
	FieldWebhookURL   = "webhook_url"
)

The credential fields the adapter keeps, all written by Pando when it connects except a webhook URL from before it did.

View Source
const Kind = "slack"

Kind is the adapter's kind string.

Variables

This section is empty.

Functions

func Info

func Info() api.KindInfo

Info describes the kind for the console's and the CLI's forms. It asks for nothing before it is saved: saving opens the connection, which creates the app and fills in the rest.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter posts to Slack.

func New

func New() *Adapter

New returns an unconfigured adapter.

func (*Adapter) BeginAuthorization

func (a *Adapter) BeginAuthorization(ctx context.Context, req api.AuthorizationRequest) (api.Authorization, error)

BeginAuthorization creates the app and returns Slack's approval screen (web), or the link to create it by hand (manual).

func (*Adapter) Capabilities

func (a *Adapter) Capabilities() api.NotifyCapabilities

Capabilities: a channel adapter whose subscriptions each choose a channel — unless it posts through a webhook, which names the one channel it reaches.

func (*Adapter) Category

func (a *Adapter) Category() api.Category

func (*Adapter) Channels

func (a *Adapter) Channels(ctx context.Context, query string) ([]api.NotifyChannel, error)

Channels lists the workspace's public channels, and the private ones Pando was invited to, whose names contain query.

func (*Adapter) CompleteAuthorization

func (a *Adapter) CompleteAuthorization(ctx context.Context, req api.AuthorizationCompletion) (api.AuthorizationResult, error)

CompleteAuthorization exchanges the code Slack returned for the bot token (web), or checks a bot token pasted by hand (manual, Code).

func (*Adapter) Configure

func (a *Adapter) Configure(ctx context.Context, raw json.RawMessage) error

Configure reads the configuration core assembled, credentials included. An adapter not connected yet is configured, and not authorized.

func (*Adapter) HealthCheck

func (a *Adapter) HealthCheck(context.Context) error

HealthCheck succeeds once configured. It does not post: a message to a channel every few minutes would be the outage.

func (*Adapter) Kind

func (a *Adapter) Kind() string

func (*Adapter) Notify

func (a *Adapter) Notify(ctx context.Context, n api.Notification) error

Notify posts one message to the channel the subscription chose.

type Config

type Config struct {
	Credentials    map[string]secret.Value `json:"credentials,omitempty"`
	TimeoutSeconds int                     `json:"timeout_seconds,omitempty"`
}

Config is the adapter's configuration.

Jump to

Keyboard shortcuts

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