File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ## Slack webhook
2+
3+ ** Slack webhook** is a simple library that allows application to seamlessly send Slack Message by using the Incoming Webhooks API from Slack.
4+
5+ Get it:
6+ ``` go
7+ go get -u github.com /anthonycorbacho/slack-webhook
8+ ```
9+
10+ ### Quick start
11+ You have to setup your Slack Incoming Webhooks, you can refer to this document https://api.slack.com/incoming-webhooks
12+
13+ ``` go
14+ package main
15+
16+ import (
17+ " fmt"
18+
19+ " github.com/anthonycorbacho/slack-webhook"
20+ )
21+
22+ func main () {
23+ hookURL := " <slack_hook_url>"
24+
25+ attachment1 := slack.Attachment {}
26+ attachment1.AddField (slack.Field {Title: " Field test" , Value: " Field value" })
27+
28+ msg := slack.Message {
29+ Text: " This is a slack message content" ,
30+ Attachments: []slack.Attachment {attachment1},
31+ }
32+ err := slack.Send (hookURL, msg)
33+ if err != nil {
34+ fmt.Printf (" failed to send message: %v \n " , err)
35+ }
36+ }
37+ ```
You can’t perform that action at this time.
0 commit comments