webhooks

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BotEventPath = "/slack/event"
)
View Source
const (
	InteractionPath = "/slack/interaction"
)
View Source
const (
	SlashCommandPath = "/slack/command"
)

Variables

View Source
var BotEventHandlers = map[string]BotEventHandler{
	"app_mention": events.AppMentionHandler,

	"channel_archive": events.ChannelGroupHandler,
	"channel_created": events.ChannelCreatedHandler,

	"channel_unarchive": events.ChannelGroupHandler,

	"group_archive": events.ChannelGroupHandler,

	"group_open": events.ChannelGroupHandler,

	"group_unarchive": events.ChannelGroupHandler,

	"member_joined_channel": events.ChannelGroupHandler,

	"message": events.MessageHandler,

	"reaction_added":   events.ReactionHandler,
	"reaction_removed": events.ReactionHandler,

	"url_verification": events.URLVerificationHandler,
}

Functions

func NewHandler

func NewHandler(l *zap.Logger, vars sdkservices.Vars, d sdkservices.Dispatcher, id sdktypes.IntegrationID) handler

Types

type Action

type Action struct {
	Type string `json:"type,omitempty"`
	// Identifies the block within a surface that contained the interactive
	// component that was used. See https://api.slack.com/reference/block-kit/block-elements.
	BlockID  string `json:"block_id,omitempty"`
	ActionTS string `json:"action_ts,omitempty"`

	// Identifies the interactive component itself. Some blocks can contain
	// multiple interactive components, so [BlockID] alone may not be specific
	// enough to identify the source component. For more information, see
	// https://api.slack.com/reference/block-kit/block-elements.
	ActionID string `json:"action_id,omitempty"`
	// Set by your app when you composed the blocks, this is the value that was
	// specified in the interactive component when an interaction happened. For
	// example, a select menu will have multiple possible values depending on
	// what the user picks from the menu, and Value will identify the chosen
	// option. See https://api.slack.com/reference/block-kit/block-elements.
	Value string `json:"value,omitempty"`

	Style string     `json:"style,omitempty"`
	Text  *chat.Text `json:"text,omitempty"`
}

https://api.slack.com/reference/interaction-payloads/block-actions

type BlockActionsPayload

type BlockActionsPayload struct {
	// Type must be "block_actions" (or "interactive_message" for attachments,
	// which we don't support because they're superseded by blocks).
	Type      string      `json:"type,omitempty"`
	User      *users.User `json:"user,omitempty"`
	Container *Container  `json:"container,omitempty"`
	// Contains data from the specific interactive component that was used.
	// App surfaces can contain blocks with multiple interactive components,
	// and each of those components can have multiple values selected by users.
	Actions []Action `json:"actions,omitempty"`

	APIAppID            string      `json:"api_app_id,omitempty"`
	Team                *Team       `json:"team,omitempty"`
	IsEnterpriseInstall bool        `json:"is_enterprise_install,omitempty"`
	Enterprise          *Enterprise `json:"enterprise,omitempty"`

	Channel *conversations.Channel `json:"channel,omitempty"`
	Message *chat.Message          `json:"message,omitempty"`

	// Short-lived webhook URL to send messages in response to interactions.
	// Attention: documented as deprecated for next-generation Slack apps, see
	// https://api.slack.com/reference/interaction-payloads/block-actions#fields
	// and compare with [webhooks.SlashCommand].
	ResponseURL string `json:"response_url,omitempty"`
	// Short-lived ID that will let your app open a modal
	// (https://api.slack.com/surfaces/modals).
	TriggerID string `json:"trigger_id,omitempty"`
}

https://api.slack.com/reference/interaction-payloads/block-actions#fields

type BotEventHandler added in v0.3.3

type BotEventHandler = func(*zap.Logger, http.ResponseWriter, []byte, *events.Callback) any

type Container

type Container struct {
	Type        string `json:"type,omitempty"`
	MessageTS   string `json:"message_ts,omitempty"`
	ChannelID   string `json:"channel_id,omitempty"`
	IsEphemeral bool   `json:"is_ephemeral,omitempty"`
	ViewID      string `json:"view_id,omitempty"`
}

https://api.slack.com/reference/interaction-payloads/block-actions#examples

type Enterprise

type Enterprise struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name,omitempty"`
}

https://api.slack.com/methods/oauth.v2.access#examples

type Response

type Response struct {
	Text            string           `json:"text,omitempty"`
	Blocks          []map[string]any `json:"blocks,omitempty"`
	ResponseType    string           `json:"response_type,omitempty"`
	ThreadTS        string           `json:"thread_ts,omitempty"`
	ReplaceOriginal bool             `json:"replace_original,omitempty"`
	DeleteOriginal  bool             `json:"delete_original,omitempty"`
}

type SlashCommand

type SlashCommand struct {
	// Unique identifier of the Slack workspace where the event occurred.
	TeamID string
	// Human-readable name of the Slack workspace where the event occurred.
	TeamDomain string

	// Is the executing Slack workspace part of an Enterprise Grid?
	IsEnterpriseInstall bool
	EnterpriseID        string
	EnterpriseName      string

	// APIAppID is our Slack app's unique ID. Useful in case we point multiple
	// Slack apps to the same webhook URL, but want to treat them differently
	// (e.g. official vs. unofficial, breaking changes, and flavors).
	APIAppID  string
	ChannelID string
	// Human-readable name of the channel - don't rely on it.
	ChannelName string
	// ID of the user who triggered the command.
	// Use "<@value>" in messages to mention them.
	UserID string
	// Command must be "/ak" or "/autokitteh" in our Slack app.
	Command string
	// Text that the user typed after the command (e.g. "help").
	Text string

	// Short-lived webhook URL (https://api.slack.com/messaging/webhooks) to generate
	// message responses (https://api.slack.com/interactivity/handling#message_responses).
	// Compare with [api.BlockActionsInteractionPayload], where this field is deprecated
	// per https://api.slack.com/reference/interaction-payloads/block-actions#fields.
	ResponseURL string
	// Short-lived ID that will let your app open a modal
	// (https://api.slack.com/surfaces/modals).
	TriggerID string
}

See https://api.slack.com/interactivity/slash-commands#app_command_handling and https://api.slack.com/types/event.

type Team

type Team struct {
	ID     string `json:"id,omitempty"`
	Domain string `json:"domain,omitempty"`
	Name   string `json:"name,omitempty"`
}

https://api.slack.com/methods/oauth.v2.access#examples https://api.slack.com/reference/interaction-payloads/block-actions#examples

Jump to

Keyboard shortcuts

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