Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ashwanthkumar/slack-go-webhook
Go Library to send messages to Slack via Webhooks
https://github.com/ashwanthkumar/slack-go-webhook
slack slack-webhook slackapi
Last synced: about 3 hours ago
JSON representation
Go Library to send messages to Slack via Webhooks
- Host: GitHub
- URL: https://github.com/ashwanthkumar/slack-go-webhook
- Owner: ashwanthkumar
- License: apache-2.0
- Created: 2016-01-26T09:58:01.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-09T02:50:34.000Z (over 4 years ago)
- Last Synced: 2024-06-18T12:44:26.253Z (5 months ago)
- Topics: slack, slack-webhook, slackapi
- Language: Go
- Size: 23.4 KB
- Stars: 165
- Watchers: 4
- Forks: 63
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![GoDoc](https://godoc.org/github.com/ashwanthkumar/slack-go-webhook?status.svg)](https://godoc.org/github.com/ashwanthkumar/slack-go-webhook)
# slack-go-webhook
Go Lang library to send messages to Slack via Incoming Webhooks.
## Usage
```go
package mainimport "github.com/ashwanthkumar/slack-go-webhook"
import "fmt"func main() {
webhookUrl := "https://hooks.slack.com/services/foo/bar/baz"attachment1 := slack.Attachment {}
attachment1.AddField(slack.Field { Title: "Author", Value: "Ashwanth Kumar" }).AddField(slack.Field { Title: "Status", Value: "Completed" })
attachment1.AddAction(slack.Action { Type: "button", Text: "Book flights 🛫", Url: "https://flights.example.com/book/r123456", Style: "primary" })
attachment1.AddAction(slack.Action { Type: "button", Text: "Cancel", Url: "https://flights.example.com/abandon/r123456", Style: "danger" })
payload := slack.Payload {
Text: "Hello from , a Go-Lang library to send slack webhook messages.\n",
Username: "robot",
Channel: "#general",
IconEmoji: ":monkey_face:",
Attachments: []slack.Attachment{attachment1},
}
err := slack.Send(webhookUrl, "", payload)
if len(err) > 0 {
fmt.Printf("error: %s\n", err)
}
}
```## License
Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0