Home

Awesome

Slack RTM (Real Time Messaging) API Integration

GoDoc Build Status

This package allows integration with the Slack Real Time Messaging API for consuming and publishing messages in real time to/from Slack.

To make use of the API, you will need to setup a user account or a 'bot' (robot) user (a special kind of user account specifically designed for programatic access to APIs) and obtain an authentication token from Slack.

Once you have a user account and an authentication token you can use the API to connect to slack. Here is an example:

conn, err := slack.Connect(slackToken)
	
if err != nil {
	log.Fatal(err)
}

replier := func(msg *slack.Message) {
	msg.Respond(msg.Text)
}

slack.EventProcessor(conn, replier, nil)

The above snippet of code connects to the Slack RTM API over a web socket and starts listening for all messages directed specifically at the user account used to connect to slack (either a direct message or a message in a channel preceded by '@username:' ). It will then echo the same message back to Slack.

To also process messages not directed specifically at the connected user, a similar function can be passed as the third parameter to the EventProcessor method (either in addition to or instead of the second parameter).

This package is used by Talbot, a bot that is available to be used directly, extended or simply as an example.

Features

Features implemented

To Do

Still outstanding...