anthonycorbacho / slack-webhook

A simple library that allows sending Slack Message by using the Incoming Webhooks API from Slack

Home Page:https://godoc.org/github.com/anthonycorbacho/slack-webhook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slack webhook

Slack webhook is a simple library that allows application to seamlessly send Slack Message by using the Incoming Webhooks API from Slack.

Get it:

go get -u github.com/anthonycorbacho/slack-webhook

Quick start

You have to setup your Slack Incoming Webhooks, you can refer to this document https://api.slack.com/incoming-webhooks

package main

import (
	"fmt"

	"github.com/anthonycorbacho/slack-webhook"
)

func main() {
	hookURL := "<slack_hook_url>"

	attachment1 := slack.Attachment{}
	attachment1.AddField(slack.Field{Title: "Field test", Value: "Field value"})

	msg := slack.Message{
		Text:        "This is a slack message content",
		Attachments: []slack.Attachment{attachment1},
	}
	err := slack.Send(hookURL, msg)
	if err != nil {
		fmt.Printf("failed to send message: %v\n", err)
	}
}

About

A simple library that allows sending Slack Message by using the Incoming Webhooks API from Slack

https://godoc.org/github.com/anthonycorbacho/slack-webhook

License:Apache License 2.0


Languages

Language:Go 100.0%