Debian Codegraph @

pkg/services/chat/slack/doc.go

raw
1 // Package slack provides a notification service for sending messages to Slack channels or users via webhooks and Bot API.
2 //
3 // This package is part of the shoutrrr notification library and implements the Service interface
4 // for delivering notifications to Slack, supporting both incoming webhooks and the Slack Bot API.
5 //
6 // # Service Configuration
7 //
8 // The Service struct provides the main functionality for sending notifications to Slack.
9 // It embeds standard.Standard for common service features and supports dual-mode operation
10 // via webhooks or the Bot API depending on the token type provided.
11 //
12 // # Configuration Fields
13 //
14 // The Config struct supports the following settings:
15 //
16 // - Token: API Bot token or webhook token (required, auto-detected type)
17 // - BotName: Override the bot's display name (optional)
18 // - Icon: Use an emoji or URL as the message icon (optional)
19 // - Channel: Target channel ID in Cxxxxxxxxxx format for API mode (optional)
20 // - Color: Message left-hand border color (optional)
21 // - Title: Prepended text above the message (optional)
22 // - ThreadTS: Thread timestamp for replying in threads (optional)
23 //
24 // # Token Types
25 //
26 // The Token type automatically detects and handles two formats:
27 //
28 // - Webhook tokens: URLs beginning with https://hooks.slack.com/
29 // - API tokens: Bot tokens beginning with xoxb- for Slack API access
30 //
31 // # Usage Example
32 //
33 // service := &slack.Service{}
34 // err := service.Initialize(serviceURL, logger)
35 // if err != nil {
36 // // handle error
37 // }
38 // err = service.Send("Your message here", nil)
39 //
40 // # JSON Payload Creation
41 //
42 // The package provides CreateJSONPayload for building properly formatted Slack message
43 // payloads with support for text, attachments, colors, and thread replies.
44 //
45 // # URL Format
46 //
47 // The configuration URL format for API tokens is:
48 //
49 // slack://xoxb-token@channel?botname=value&icon=value&color=value
50 //
51 // For webhooks:
52 //
53 // slack://botname@https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX
54 //
55 // For more information about Slack apps, visit: https://api.slack.com/apps
56 package slack