https://github.com/nitor-infotech-oss/go-slacknotification
Send notifications on slack channel in golang using slack webhook url
https://github.com/nitor-infotech-oss/go-slacknotification
Last synced: 7 months ago
JSON representation
Send notifications on slack channel in golang using slack webhook url
- Host: GitHub
- URL: https://github.com/nitor-infotech-oss/go-slacknotification
- Owner: nitor-infotech-oss
- Created: 2020-08-07T12:06:45.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-07T12:23:32.000Z (about 5 years ago)
- Last Synced: 2023-03-02T21:22:21.128Z (over 2 years ago)
- Language: Go
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# slacknotifications
[](https://travis-ci.org/joemccann/dillinger)
# Objective
Slack allows you to create webhooks which can be used as an API endpoints and sent messages programmatically.
A many time, we do want our process to send us the slack notifications.### Prerequisites
There are no dependencies on any of the GoLang packages.### Imprting Package
```
import (
"github.com/nitor-infotech-oss/go-slacknotification/slacknotifications"
)
```Package can be imported by simply using the path of repo where it resides.
### Example Usage
```
package main
import (
"fmt"
"github.com/nitor-infotech-oss/go-slacknotification/slacknotifications"
)func main() {
webhookUrl := "https://hooks.slack.com/services/XXXXXXX/XXXXXXXXXXXXXXX/XXXXXXXXXXXXXXX"
err = slacknotifications.SendSlackNotification(webhookUrl, summaryString)
if err != nil {
fmt.Println("Error while sending msg to slack")
}
}
```### Steps to generate webhook url from slack
- To get the correct webhook url on which we have post the messages, need to add configuration on the incoming WebHoks page.
- Go to https://my.slack.com/services/new/incoming-webhook/ link, it may ask you to log in

- Choose the channel you want to post the messages and click on the Add Incoming Webhooks integration button.
- Once you click above mentioned button this will give you the webhook url (e.g. https://hooks.slack.com/services/XXXXX/xxxxxxx/xxxxxxxxxxxxxx)
