Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

slack-go

A (very simple) Go library for posting messages to incoming webhooks in Slack.

You will need to set up a Slack App with an incoming webhook URL; see the developer documentation for details.

Example

package main
import"github.com/PromptBit/slack-go/slack"funcmain() {
webhookURL:="<add url here>"err:=slack.PostToWebhook(webhookURL, slack.Message{
Text: "Error occurred with /some/endpoint",
Blocks: []slack.Block{
{
Type: slack.BlockTypeHeader,
Text: &slack.Text{
Type: slack.TextTypePlainText,
Text: ":warning: Error occurred with /some/endpoint",
Emoji: true,
},
},
{
Type: slack.BlockTypeSection,
Text: &slack.Text{
Type: slack.TextTypePlainText,
Text: "runtime error: invalid memory address or nil pointer dereference",
},
},
{
Type: slack.BlockTypeSection,
Text: &slack.Text{
Type: slack.TextTypeMarkdown,
Text: "*Stacktrace*\n```stacktrace would go here...```",
},
},
},
})
iferr!=nil {
panic(err)
}
}

That code will result in the following being posted to Slack:

Screenshot of sent message

For more formatting options, refer to the blocks reference and Block Kit Builder.

About

Go library for posting messages to incoming webhooks in Slack.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages