Documentation
¶
Overview ¶
Package chat is the notify adapters for chat platforms that take an incoming webhook: Slack, Microsoft Teams and Discord (R-374, issue #50).
Each posts to one channel, named by a webhook URL an administrator creates in the platform, so each is a channel adapter: it ignores recipients, and only event subscriptions send to it (R-373). A message meant for one person never lands in a room.
The webhook URL is the credential. Whoever holds it can post to the channel, so it is stored sealed like any adapter credential and never shown again (R-190).
Index ¶
- Variables
- func SlackMessage(n api.Notification) map[string]any
- type Adapter
- func (a *Adapter) Capabilities() api.NotifyCapabilities
- func (a *Adapter) Category() api.Category
- func (a *Adapter) Configure(_ context.Context, raw json.RawMessage) error
- func (a *Adapter) HealthCheck(context.Context) error
- func (a *Adapter) Kind() string
- func (a *Adapter) Notify(ctx context.Context, n api.Notification) error
- type Config
- type Credentials
- type Platform
Constants ¶
This section is empty.
Variables ¶
var Discord = Platform{ Kind: "discord", Name: "Discord", Description: "Posts the events a subscription chooses to a Discord channel, through a channel webhook.", IDPrefix: "ntf_", Placeholder: "https://discord.com/api/webhooks/…", Help: "The webhook URL from the server's Integrations settings.", Hosts: []string{"discord.com", "discordapp.com"}, Steps: discordSteps(), Format: discordMessage, }
Discord posts to a Discord channel webhook.
var Slack = Platform{ Kind: "slack", Name: "Slack", Description: "Posts the events a subscription chooses to a Slack channel, through an incoming webhook.", IDPrefix: "ntf_", Placeholder: "https://hooks.slack.com/services/…", Help: "The incoming webhook URL Slack gives you for the channel.", Hosts: []string{"hooks.slack.com", "hooks.slack-gov.com"}, Steps: slackSteps(), Format: func(n api.Notification) any { return SlackMessage(n) }, }
Slack posts to a Slack incoming webhook.
var Teams = Platform{ Kind: "teams", Name: "Microsoft Teams", Description: "Posts the events a subscription chooses to a Microsoft Teams channel, as an adaptive card, through a Workflows webhook.", IDPrefix: "ntf_", Placeholder: "https://….environment.api.powerplatform.com/powerautomate/automations/direct/workflows/…", Help: "The webhook URL of a Send webhook alerts to a channel workflow.", Steps: teamsSteps(), Hosts: []string{ "api.powerplatform.com", "api.gov.powerplatform.microsoft.us", "api.high.powerplatform.microsoft.us", "api.appsplatform.us", "api.powerplatform.partner.microsoftonline.cn", "logic.azure.us", "logic.azure.cn", }, Retired: map[string]string{ "webhook.office.com": "Microsoft retired Office 365 connector webhooks in Teams on May 22, 2026. Create a workflow from the Send webhook alerts to a channel template and copy its URL.", "logic.azure.com": "Microsoft retired Teams workflow URLs on logic.azure.com on November 30, 2025. Open the workflow in Power Automate and copy the new URL from its trigger.", }, Format: teamsMessage, }
Teams posts to a Microsoft Teams channel through a Workflows webhook.
Functions ¶
func SlackMessage ¶ added in v0.11.0
func SlackMessage(n api.Notification) map[string]any
SlackMessage lays a notification out as a Slack message: text for the phone notification, blocks for the message itself. Used by the Slack adapter too.
Types ¶
type Adapter ¶
type Adapter struct {
notifykit.Unconnected
// contains filtered or unexported fields
}
Adapter posts to one channel.
func (*Adapter) Capabilities ¶
func (a *Adapter) Capabilities() api.NotifyCapabilities
Capabilities: a channel, not people.
func (*Adapter) HealthCheck ¶
HealthCheck succeeds once configured. It does not post: a health check that sends a message to a channel every five minutes would be the outage.
type Config ¶
type Config struct {
Credentials Credentials `json:"credentials,omitzero"`
TimeoutSeconds int `json:"timeout_seconds,omitempty"`
}
Config is the adapter's configuration.
type Credentials ¶
Credentials is what this adapter keeps secret.
type Platform ¶
type Platform struct {
Kind string
Name string
Description string
IDPrefix string
Placeholder string
Help string
// Hosts are the hosts a webhook URL for the platform is on. A URL on
// another host is refused at configuration, because a webhook URL pasted
// into the wrong platform's form fails at the first event otherwise.
// Empty accepts any host.
Hosts []string
// Retired are hosts the platform once issued webhook URLs on and no
// longer serves, each with what to do instead. A URL on one is refused
// with that remedy rather than the generic wrong-platform message.
Retired map[string]string
// Steps walk someone through making the webhook (api.KindInfo.Steps).
Steps []api.Step
Format func(n api.Notification) any
}
Platform is what differs between the three: a name, and how a notification is laid out.