-
Notifications
You must be signed in to change notification settings - Fork 16
Migrating from v2.x to v3.x
The third major version of go-sarah
introduces better Slack support.
From 2019 to 2020, Slack is going through big changes, and those include migration from RTM API to Events API.
While new Slack apps are strongly recommended to use Events API for better functionality, RTM API is still supported to work with apps behind firewalls.
With go-sarah
v3.0.0, developers can select which API to use.
To provide the choice of API, an AdapterOption
derived from the call to WithEventsPayloadHandler
or WithRTMPayloadHandler
is required.
Below illustrates how to enable RTM API.
By replacing slack.DefaultRTMPayloadHandler
with a customized handler, one can change the behavior on how to receive the incoming events.
// Setup slack adapter.
slackConfig := slack.NewConfig()
slackConfig.Token = "REPLACE THIS"
adapter, err := slack.NewAdapter(slackConfig, slack.WithRTMPayloadHandler(slack.DefaultRTMPayloadHandler))
Below illustrates how to enable Events API.
By replacing slack.DefaultEventsPayloadHandler
with a customized handler, one can change the behavior on how to receive the incoming events.
// Setup slack adapter.
slackConfig := slack.NewConfig()
slackConfig.Token = "REPLACE THIS"
adapter, err := slack.NewAdapter(slackConfig, slack.WithRTMPayloadHandler(slack.DefaultEventsPayloadHandler))
Now the old slack.MessageInput
is replaced with slack.Input
that wraps the incoming event.
To have a grasp of overall architecture, have a look at Components.