slack

package
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package slack provides the Slack integration definition for integrations

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrOAuthTokenMissing indicates the Slack OAuth access token is missing from the credential
	ErrOAuthTokenMissing = errors.New("slack: oauth token missing")
	// ErrBotTokenMissing indicates the Slack bot token is missing from the credential
	ErrBotTokenMissing = errors.New("slack: bot token missing")
	// ErrNoCredentialResolved indicates neither OAuth nor bot token credential was found
	ErrNoCredentialResolved = errors.New("slack: no credential resolved")
	// ErrChannelMissing indicates the Slack channel is missing from the operation config
	ErrChannelMissing = errors.New("slack: channel missing")
	// ErrMessageEmpty indicates the Slack message has no content
	ErrMessageEmpty = errors.New("slack: message must have text, blocks, or attachments")
	// ErrClientType indicates the provided client is not a Slack client
	ErrClientType = errors.New("slack: unexpected client type")
	// ErrAuthTestFailed indicates auth.test failed
	ErrAuthTestFailed = errors.New("slack: auth test failed")
	// ErrOperationConfigInvalid indicates operation config could not be decoded
	ErrOperationConfigInvalid = errors.New("slack: operation config invalid")
	// ErrMessageSendFailed indicates chat.postMessage failed
	ErrMessageSendFailed = errors.New("slack: message send failed")
	// ErrResultEncode indicates an operation result could not be serialized
	ErrResultEncode = errors.New("slack: result encode failed")
	// ErrUsersFetchFailed indicates the workspace users list request failed
	ErrUsersFetchFailed = errors.New("slack: users fetch failed")
	// ErrPayloadEncode indicates a collected Slack payload could not be serialized for ingest
	ErrPayloadEncode = errors.New("slack: ingest payload encode failed")
	// ErrCredentialEncode indicates the credential could not be serialized
	ErrCredentialEncode = errors.New("slack: credential encode failed")
	// ErrCredentialDecode indicates the credential could not be deserialized
	ErrCredentialDecode = errors.New("slack: credential decode failed")
	// ErrInstallationMetadataDecode indicates installation metadata could not be decoded from credential data
	ErrInstallationMetadataDecode = errors.New("slack: installation metadata decode failed")
	// ErrTeamIDMissing indicates the Slack team ID is missing
	ErrTeamIDMissing = errors.New("slack: installation id missing")
	// ErrInstallationMetadataEncode indicates installation metadata could not be encoded
	ErrInstallationMetadataEncode = errors.New("slack: installation metadata encode failed")
	// ErrClientBuildFailed indicates a Slack runtime or customer client could not be constructed
	ErrClientBuildFailed = errors.New("slack: client build failed")
	// ErrRuntimeConfigInvalid indicates the runtime Slack configuration is missing required fields
	ErrRuntimeConfigInvalid = errors.New("slack: runtime config invalid")
	// ErrRuntimeConfigDecode indicates the runtime Slack configuration could not be deserialized
	ErrRuntimeConfigDecode = errors.New("slack: runtime config decode failed")
	// ErrDefaultChannelMissing indicates the installation has no default channel configured for system messages
	ErrDefaultChannelMissing = errors.New("slack: default channel missing")
	// ErrTemplateRenderFailed indicates a system message template could not be rendered
	ErrTemplateRenderFailed = errors.New("slack: template render failed")
	// ErrInstallationInputDecode indicates the installation input payload could not be deserialized
	ErrInstallationInputDecode = errors.New("slack: installation input decode failed")
)
View Source
var (
	_, NewSubscriberOp = providerkit.OperationSchema[NewSubscriberMessage]()
	_,//nolint:revive
	NewUserOp = providerkit.OperationSchema[NewUserMessage]()
	_,//nolint:revive
	GitHubAppInstallOp = providerkit.OperationSchema[GitHubAppInstalledMessage]()
	_,//nolint:revive
	DemoRequestOp = providerkit.OperationSchema[DemoRequestMessage]() //nolint:revive
)

System message operation schemas and refs

View Source
var (
	// DefinitionID is the stable identifier for the Slack integration definition
	DefinitionID = types.NewDefinitionRef("def_01K0SLACK000000000000000001")
	_,// messageSendSchema is the operation ref for the Slack message send operation
	MessageSendOp = providerkit.OperationSchema[MessageSendOperation]() //nolint:revive // co-initialized with schema
)

Functions

func AllSlackSystemMessages added in v1.20.0

func AllSlackSystemMessages() []types.OperationRegistration

AllSlackSystemMessages returns all system Slack message operation registrations for wiring into the builder

func Builder

func Builder(cfg Config, runtime *RuntimeSlackConfig) registry.Builder

Builder returns the Slack definition builder with the supplied operator and runtime config applied When runtime.Provisioned() is true, a RuntimeIntegration is included for system-send

Types

type Client

type Client struct{}

Client builds Slack clients for one customer installation

func (Client) Build

Build constructs the unified SlackClient for one customer installation

type Config

type Config struct {
	// ClientID is the Slack OAuth application client identifier
	ClientID string `json:"clientid" koanf:"clientid"`
	// ClientSecret is the Slack OAuth application client secret
	ClientSecret string `json:"clientsecret" koanf:"clientsecret" sensitive:"true"`
	// RedirectURL is the OAuth callback URL registered with the Slack application
	RedirectURL string `json:"redirecturl" koanf:"redirecturl" default:"https://api.theopenlane.io/v1/integrations/auth/callback"`
	// AppID is the oauth app id used for opening the app within a slack workspace
	AppID string `json:"appid" koanf:"appid"`
}

Config holds operator-level credentials for the Slack definition

type DemoRequestMessage added in v1.20.0

type DemoRequestMessage struct {
	// CompanyName is the requesting company name
	CompanyName string `json:"companyName" jsonschema:"required,description=Requesting company name"`
	// Email is the requester email address
	Email string `json:"email" jsonschema:"required,description=Requester email address"`
	// Domains lists any additional domains associated with the request
	Domains []string `json:"domains,omitempty" jsonschema:"description=Additional domains associated with the request"`
	// CompanyDetails is a map of company attributes surfaced in the notification
	CompanyDetails map[string]any `json:"companyDetails,omitempty" jsonschema:"description=Company attributes surfaced in the notification"`
	// UserDetails is a map of user attributes surfaced in the notification
	UserDetails map[string]any `json:"userDetails,omitempty" jsonschema:"description=User attributes surfaced in the notification"`
	// Compliance is a map of compliance interests surfaced in the notification
	Compliance map[string]any `json:"compliance,omitempty" jsonschema:"description=Compliance interests surfaced in the notification"`
	// DemoRequested marks whether the requester asked for a personalized demo
	DemoRequested bool `json:"demoRequested,omitempty" jsonschema:"description=Requester asked for a personalized demo"`
}

DemoRequestMessage is the input for the demo request Slack notification

type DirectorySync

type DirectorySync struct {
	// Disable is used to disable the directory sync operation from GitHub
	Disable bool `json:"disable,omitempty" jsonschema:"title=Disable,description=Disable the syncing of users from Slack"`
	// FilterExpr limits imported records to envelopes matching the CEL expression
	FilterExpr string `` /* 185-byte string literal not displayed */
}

func (DirectorySync) IngestHandle

func (d DirectorySync) IngestHandle() types.IngestHandler

IngestHandle adapts directory sync to the ingest operation registration boundary

func (DirectorySync) Run

func (DirectorySync) Run(ctx context.Context, client *slackgo.Client, lastRunAt *time.Time) ([]types.IngestPayloadSet, error)

Run collects Slack workspace users and emits directory account ingest payloads

type GitHubAppInstalledMessage added in v1.20.0

type GitHubAppInstalledMessage struct {
	// GitHubOrganization is the GitHub organization name where the app was installed
	GitHubOrganization string `json:"githubOrganization" jsonschema:"required,description=GitHub organization name"`
	// GitHubAccountType is the GitHub account type (User, Organization)
	GitHubAccountType string `json:"githubAccountType,omitempty" jsonschema:"description=GitHub account type"`
	// OpenlaneOrganization is the Openlane organization display name
	OpenlaneOrganization string `json:"openlaneOrganization" jsonschema:"required,description=Openlane organization display name"`
	// OpenlaneOrganizationID is the Openlane organization identifier
	OpenlaneOrganizationID string `json:"openlaneOrganizationId,omitempty" jsonschema:"description=Openlane organization id"`
	// ShowOpenlaneOrganizationID reports whether the id should be rendered alongside the display name
	ShowOpenlaneOrganizationID bool `` /* 131-byte string literal not displayed */
}

GitHubAppInstalledMessage is the input for the GitHub App installation Slack notification

type HealthCheck

type HealthCheck struct {
	// Team is the Slack team name
	Team string `json:"team"`
	// URL is the Slack team URL
	URL string `json:"url"`
	// User is the authenticated Slack user
	User string `json:"user"`
}

HealthCheck holds the result of a Slack health check

func (HealthCheck) Handle

func (h HealthCheck) Handle() types.OperationHandler

Handle adapts the health check to the generic operation registration boundary

func (HealthCheck) Run

Run executes the Slack auth.test health check

type InstallationInput added in v1.20.0

type InstallationInput struct {
	// DefaultChannel is the Slack channel id used as the default delivery target for system messages
	DefaultChannel string `` /* 156-byte string literal not displayed */
}

InstallationInput is the provider-defined input supplied when installing the Slack integration. Bot-token connections populate it at install time; OAuth connections leave it empty for now

type InstallationMetadata

type InstallationMetadata struct {
	// TeamID is the Slack workspace identifier
	TeamID string `json:"teamId,omitempty" jsonschema:"title=Team ID"`
	// TeamName is the Slack workspace display name
	TeamName string `json:"teamName,omitempty" jsonschema:"title=Team Name"`
	// DefaultChannel is the Slack channel id used for system notifications on the customer installation
	DefaultChannel string `json:"defaultChannel,omitempty" jsonschema:"title=Default Channel"`
}

InstallationMetadata holds the stable Slack workspace identity for one installation

func (InstallationMetadata) InstallationIdentity

InstallationIdentity implements types.InstallationIdentifiable

type MessageDelivery

type MessageDelivery struct {
	// Channel is the channel the message was posted to
	Channel string `json:"channel"`
	// TS is the message timestamp
	TS string `json:"ts"`
}

MessageDelivery captures one Slack message delivery

type MessageSend

type MessageSend struct {
	// Channel is the first channel the message was posted to
	Channel string `json:"channel,omitempty"`
	// TS is the first message timestamp
	TS string `json:"ts,omitempty"`
	// Deliveries captures every channel delivery performed by the operation
	Deliveries []MessageDelivery `json:"deliveries,omitempty"`
}

MessageSend sends a Slack message via chat.postMessage

func (MessageSend) Handle

func (m MessageSend) Handle() types.OperationHandler

Handle adapts message send to the generic operation registration boundary

func (MessageSend) Run

Run sends a Slack message via chat.postMessage

type MessageSendOperation

type MessageSendOperation struct {
	// TemplateID references a notification template by database ID
	TemplateID string `json:"templateId,omitempty" jsonschema:"title=Template ID"`
	// TemplateKey references a notification template by key
	TemplateKey string `json:"templateKey,omitempty" jsonschema:"title=Template Key"`
	// Channel is the Slack channel identifier to post to
	Channel string `json:"channel,omitempty" jsonschema:"title=Channel"`
	// Destinations are Slack channel identifiers to post the same message to
	Destinations []string `json:"destinations,omitempty" jsonschema:"title=Destinations"`
	// Text is the plain-text message content
	Text string `json:"text,omitempty" jsonschema:"title=Message Text"`
	// Blocks is a Block Kit payload for rich messages
	Blocks []json.RawMessage `json:"blocks,omitempty" jsonschema:"title=Block Kit Payload"`
	// ThreadTS is the thread timestamp for replies
	ThreadTS string `json:"thread_ts,omitempty" jsonschema:"title=Thread Timestamp"`
	// UnfurlLinks controls whether links are unfurled
	UnfurlLinks *bool `json:"unfurl_links,omitempty" jsonschema:"title=Unfurl Links"`
}

MessageSendOperation holds per-invocation parameters for the message.send operation

type NewSubscriberMessage added in v1.20.0

type NewSubscriberMessage struct {
	// Email is the subscriber email address
	Email string `json:"email" jsonschema:"required,description=Subscriber email address"`
}

NewSubscriberMessage is the input for the new subscriber Slack notification

type NewUserMessage added in v1.20.0

type NewUserMessage struct {
	// Email is the new user email address
	Email string `json:"email" jsonschema:"required,description=New user email address"`
}

NewUserMessage is the input for the new user Slack notification

type RuntimeSlackConfig added in v1.20.0

type RuntimeSlackConfig struct {
	// WebhookURL is the Slack incoming webhook URL used to deliver system notifications
	WebhookURL string `` /* 139-byte string literal not displayed */
	// BotToken is a Slack Bot User OAuth Token (xoxb-...) for the platform-owned workspace
	BotToken string `` /* 138-byte string literal not displayed */
	// DefaultChannel is the channel id used for system messages when no explicit channel is specified
	DefaultChannel string `` /* 155-byte string literal not displayed */
}

RuntimeSlackConfig is the runtime-provisioned configuration for the system Slack integration. Sourced from koanf/environment at startup; populated for the platform-owned workspace. Two modes are supported: webhook-only (fire-and-forget via incoming webhook URL) and bot-token mode (full Web API access with channel targeting and Block Kit support)

func (RuntimeSlackConfig) Provisioned added in v1.20.0

func (c RuntimeSlackConfig) Provisioned() bool

Provisioned reports whether the runtime config has the minimum required fields to deliver system messages

type SlackClient added in v1.20.0

type SlackClient struct {
	// API is the Slack Web API client (present for bot-token runtime and customer installations)
	API *slackgo.Client
	// WebhookURL is the Slack incoming webhook used as a fallback when no API client is configured
	WebhookURL string
	// DefaultChannel is the channel id used for system messages when no explicit channel is specified
	DefaultChannel string
}

SlackClient is the unified Slack client used by every Slack operation. Both runtime and customer paths produce a SlackClient; the active transport depends on which fields are populated: API (bot token or OAuth) enables chat.postMessage with channel targeting; WebhookURL provides fire-and-forget delivery when no API client is available

type UserInput

type UserInput struct {
	// DefaultMessaging marks this installation as the preferred Slack workspace for workflow messaging operations
	DefaultMessaging bool `json:"defaultMessaging,omitempty" jsonschema:"title=Default Messaging"`
	// DirectorySync includes the configuration for identity accounts from Slack members
	DirectorySync DirectorySync `json:"directorySync,omitempty" jsonschema:"title=Directory Account Sync"`
}

UserInput holds installation-specific configuration collected from the user

Jump to

Keyboard shortcuts

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