Write a Slack bot in Go
-
Create a new bot user on Slack.
-
Prepare a new config file for the bot.
cp config.json.template echo-config.json
-
Update the config with the bot's API token.
-
Run the bot by running the following command.
go run cmd/echo/echo.go -config=echo-config.json
Your custom bot needs to implement the WASB
interface as shown below.
type WASB interface {
ReceiveMessage() (*Msg, error)
IsValidMessage(m *Msg) bool
SendMessage(m *Msg) error
TearDown() error
}
See how Echo
implements it in cmd/echo/echo.go
.
MIT