Slack API in Go
Clone or download
Permalink
Failed to load latest commit information.
examples WIP: testing fix using variadic options to allow attaching replies vi… Jul 13, 2018
slackevents support both message and original message Aug 18, 2018
slackutilsx add escape message to slackutilsx Sep 5, 2018
vendor/github.com webhook fixes Sep 5, 2018
.gitignore Added structs and basic methods for handling Slack dialogs Jul 14, 2018
.travis.yml Update Travis CI build matrix Dec 16, 2017
CHANGELOG.md changelog for v0.3.0 Jul 30, 2018
Gopkg.lock webhook fixes Sep 5, 2018
Gopkg.toml webhook fixes Sep 5, 2018
LICENSE Implement most of the API and a couple of tests Jan 24, 2015
README.md Events API support (#293) May 6, 2018
TODO.txt Removed Slack prefix from some structs Aug 16, 2015
admin.go Include the resend param when sending guest invites Apr 20, 2018
attachments.go Add AuthorID to Attachment struct Mar 29, 2018
backoff.go Refactor with some tools (#306) May 6, 2018
bots.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
bots_test.go Add support for the bots.info API. Oct 9, 2016
channels.go revert WebResponse to SlackResponse May 9, 2018
chat.go expose message option for endpoints Sep 11, 2018
chat_test.go revert WebResponse to SlackResponse May 9, 2018
comment.go 🎨 Hygiene, Mostly Related To ID Jul 22, 2015
conversation.go Build fails: conversation.go undefined: post Sep 14, 2018
conversation_test.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
dialog.go dialogs wip Sep 5, 2018
dialog_select.go dialogs wip Sep 5, 2018
dialog_select_test.go dialogs wip Sep 5, 2018
dialog_test.go dialogs wip Sep 5, 2018
dialog_text.go dialogs wip Sep 5, 2018
dialog_text_test.go dialogs wip Sep 5, 2018
dnd.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
dnd_test.go Refactor with some tools (#306) May 6, 2018
emoji.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
emoji_test.go Implement most of the API and a couple of tests Jan 24, 2015
files.go Support the thread_ts parameter of files.upload API Sep 12, 2018
files_test.go revert WebResponse to SlackResponse May 9, 2018
groups.go revert WebResponse to SlackResponse May 9, 2018
history.go Add missing Unreads parameter Mar 5, 2016
im.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
info.go add custom UnmarshalJSON to JSONTime (#314) Jun 29, 2018
item.go Pulling changes from joefitzgerald Jul 26, 2015
item_test.go 👕 Fix Lint and Vet Errors Jul 22, 2015
logger.go reduces required logger scope to just an Output function Jan 14, 2018
logger_test.go reduces required logger scope to just an Output function Jan 14, 2018
messageID.go Simplified ManageConnection to remove unneeded concurrency. Aug 16, 2015
messages.go Slack API changed the files object to list Aug 5, 2018
messages_test.go change to array file share tests Aug 5, 2018
misc.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
misc_test.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
oauth.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
pagination.go Add comments (still no nearly enough) Jan 27, 2015
pins.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
pins_test.go Refactor with some tools (#306) May 6, 2018
reactions.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
reactions_test.go Refactor with some tools (#306) May 6, 2018
rtm.go fix deadlock between disconnect and connect. Aug 5, 2018
search.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
security.go minor fixes and test addition Sep 21, 2018
security_test.go minor fixes and test addition Sep 21, 2018
slack.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
slack_test.go Implement most of the API and a couple of tests Jan 24, 2015
slash.go Add fields EnterpriseID and EnterpriseName to SlashCommand (#265) Feb 21, 2018
slash_test.go Add fields EnterpriseID and EnterpriseName to SlashCommand (#265) Feb 21, 2018
stars.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
stars_test.go Refactor with some tools (#306) May 6, 2018
team.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
team_test.go Refactor with some tools (#306) May 6, 2018
usergroups.go Switch GetUserGroups to use options pattern Sep 5, 2018
usergroups_test.go Switch GetUserGroups to use options pattern Sep 5, 2018
users.go better naming for some internal methods, resolves linting and clearer… Jul 30, 2018
users_test.go revert WebResponse to SlackResponse May 9, 2018
webhooks.go webhook fixes Sep 5, 2018
webhooks_test.go Add convience method for webhooks Aug 5, 2018
websocket.go fix deadlock between disconnect and connect. Aug 5, 2018
websocket_channels.go Remove JSONTimeString Jan 30, 2016
websocket_dm.go 🔤 Document Websocket Files Aug 3, 2015
websocket_dnd.go Add dnd Mar 5, 2016
websocket_files.go Remove JSONTimeString Jan 30, 2016
websocket_groups.go Fixed unmarshalling for channel rename event. Aug 16, 2015
websocket_internals.go Add an explicit event type for RTM rate-limit errors. (#246) Feb 2, 2018
websocket_managed_conn.go Add subteam events Sep 4, 2018
websocket_managed_conn_test.go rtm: add RTM options, and gorilla websocket Dialer Feb 21, 2018
websocket_misc.go Refactor with some tools (#306) May 6, 2018
websocket_pins.go Remove JSONTimeString Jan 30, 2016
websocket_reactions.go Add ItemUser to reactions event Mar 5, 2016
websocket_stars.go Remove JSONTimeString Jan 30, 2016
websocket_subteam.go fix typo Sep 4, 2018
websocket_teams.go Merge pull request #54 from dvdplm/fix/user-is-pointer-in-teamjoinevent Mar 5, 2016

README.md

Slack API in Go GoDoc Build Status

Join the chat at https://gitter.im/go-slack/Lobby

This library supports most if not all of the api.slack.com REST calls, as well as the Real-Time Messaging protocol over websocket, in a fully managed way.

Change log

Support for the EventsAPI has recently been added. It is still in its early stages but nearly all events have been added and tested (except for those events in Developer Preview mode). API stability for events is not promised at this time.

v0.2.0 - Feb 10, 2018

Release adds a bunch of functionality and improvements, mainly to give people a recent version to vendor against.

Please check 0.2.0

CHANGELOG.md

CHANGELOG.md is available. Please visit it for updates.

Installing

go get

$ go get -u github.com/nlopes/slack

Example

Getting all groups

import (
	"fmt"

	"github.com/nlopes/slack"
)

func main() {
	api := slack.New("YOUR_TOKEN_HERE")
	// If you set debugging, it will log all requests to the console
	// Useful when encountering issues
	// api.SetDebug(true)
	groups, err := api.GetGroups(false)
	if err != nil {
		fmt.Printf("%s\n", err)
		return
	}
	for _, group := range groups {
		fmt.Printf("ID: %s, Name: %s\n", group.ID, group.Name)
	}
}

Getting User Information

import (
    "fmt"

    "github.com/nlopes/slack"
)

func main() {
    api := slack.New("YOUR_TOKEN_HERE")
    user, err := api.GetUserInfo("U023BECGF")
    if err != nil {
	    fmt.Printf("%s\n", err)
	    return
    }
    fmt.Printf("ID: %s, Fullname: %s, Email: %s\n", user.ID, user.Profile.RealName, user.Profile.Email)
}

Minimal RTM usage:

See https://github.com/nlopes/slack/blob/master/examples/websocket/websocket.go

Minimal EventsAPI usage:

See https://github.com/nlopes/slack/blob/master/examples/eventsapi/events.go

Contributing

You are more than welcome to contribute to this project. Fork and make a Pull Request, or create an Issue if you see any problem.

License

BSD 2 Clause license