slack

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

README

Search Slack messages using the Slack search.messages API for investigative context during alert analysis.

Configuration

Environment Variable CLI Flag Required Description
WARREN_SLACK_TOOL_USER_TOKEN --slack-tool-user-token Yes Slack User token (not Bot token). Requires search:read scope.

Note: The Slack search API requires a User token (xoxp-...), not a Bot token (xoxb-...). Bot tokens do not support the search.messages API.

Available Functions

Function Description
slack_message_search Search Slack messages. Supports parameters: query, sort (score/timestamp), sort_dir (asc/desc), count, page, highlight

Setup

  1. In your Slack workspace, create or use an existing Slack App
  2. Navigate to OAuth & Permissions
  3. Under User Token Scopes, add search:read
  4. Install the app and copy the User OAuth Token (xoxp-...)
  5. Set WARREN_SLACK_TOOL_USER_TOKEN environment variable

The tool is automatically enabled when the user token is configured.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

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

func (*Action) Configure

func (x *Action) Configure(ctx context.Context) error

func (*Action) Flags

func (x *Action) Flags() []cli.Flag

func (*Action) Helper

func (x *Action) Helper() *cli.Command

func (*Action) LogValue

func (x *Action) LogValue() slog.Value

func (*Action) Name

func (x *Action) Name() string

func (*Action) Prompt

func (x *Action) Prompt(ctx context.Context) (string, error)

Prompt returns additional instructions for the system prompt

func (*Action) Run

func (x *Action) Run(ctx context.Context, name string, args map[string]any) (map[string]any, error)

func (*Action) SetOAuthToken

func (x *Action) SetOAuthToken(token string)

SetOAuthToken sets the OAuth token (for testing)

func (*Action) SetSlackClient

func (x *Action) SetSlackClient(client interfaces.SlackClient)

func (*Action) SetTestURL

func (x *Action) SetTestURL(url string)

SetTestURL sets a custom base URL (for testing)

func (*Action) Specs

func (x *Action) Specs(ctx context.Context) ([]gollem.ToolSpec, error)

type Attachment

type Attachment struct {
	ID      int    `json:"id"`
	Pretext string `json:"pretext,omitempty"`
	Text    string `json:"text,omitempty"`
}

Attachment represents message attachments

type ChannelInfo

type ChannelInfo struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

ChannelInfo represents channel information

type Message

type Message struct {
	Type        string       `json:"type"`
	Channel     ChannelInfo  `json:"channel"`
	User        string       `json:"user"`
	Username    string       `json:"username"`
	Text        string       `json:"text"`
	Timestamp   string       `json:"ts"`
	Permalink   string       `json:"permalink"`
	Team        string       `json:"team,omitempty"`
	Attachments []Attachment `json:"attachments,omitempty"`
}

Message represents a single message in search results

type MessagesBlock

type MessagesBlock struct {
	Total      int       `json:"total"`
	Pagination Paging    `json:"paging"`
	Matches    []Message `json:"matches"`
}

MessagesBlock represents the messages block in search response

type Paging

type Paging struct {
	Count int `json:"count"`
	Total int `json:"total"`
	Page  int `json:"page"`
	Pages int `json:"pages"`
}

Paging represents pagination information

type SearchMessageItem

type SearchMessageItem struct {
	Channel       string    `json:"channel"`
	ChannelName   string    `json:"channel_name"`
	User          string    `json:"user"`
	UserName      string    `json:"user_name"`
	Text          string    `json:"text"`
	Timestamp     string    `json:"timestamp"`
	Permalink     string    `json:"permalink"`
	FormattedTime time.Time `json:"formatted_time,omitempty"`
}

SearchMessageItem represents a formatted message item for output

type SearchOptions

type SearchOptions struct {
	Query     string `json:"query"`
	Sort      string `json:"sort,omitempty"`     // score, timestamp
	SortDir   string `json:"sort_dir,omitempty"` // asc, desc
	Count     int    `json:"count,omitempty"`
	Page      int    `json:"page,omitempty"`
	Highlight bool   `json:"highlight,omitempty"`
}

SearchOptions represents the options for Slack message search

type SearchOutput

type SearchOutput struct {
	Total    int                 `json:"total"`
	Messages []SearchMessageItem `json:"messages"`
}

SearchOutput represents the tool output format

type SearchResponse

type SearchResponse struct {
	OK       bool          `json:"ok"`
	Query    string        `json:"query"`
	Messages MessagesBlock `json:"messages"`
	Error    string        `json:"error,omitempty"`
}

SearchResponse represents the response from Slack search API

Jump to

Keyboard shortcuts

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