Skip to content

Commit fdf9d20

Browse files
first commit
0 parents  commit fdf9d20

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

Readme.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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+
```

0 commit comments

Comments
 (0)