Record Class SlackChannelConfig
- Record Components:
botToken-xoxb-...Bot User OAuth token for the Slack Web API. Required.appToken-xapp-...App-Level Token granting theconnections:writescope, used to open the Socket Mode WebSocket. Required.webApiBaseUrl- base URL for the Slack Web API. Defaults tohttps://slack.com/api; tests override this to point at a MockWebServer instance. Always lacks a trailing slash.reconnectInitialBackoff- initial WebSocket reconnect delay. Doubled on each consecutive failure up toreconnectMaxBackoff.reconnectMaxBackoff- cap for the reconnect delay.
SlackChannel.
Slack auth uses two distinct tokens because the channel runs in
Socket Mode: the bot token (xoxb-...) is the Bot User OAuth
token used for outbound Web API calls (chat.postMessage et al),
and the app token (xapp-...) is the App-Level Token used to
open the inbound WebSocket via apps.connections.open. Both
are mandatory; without either, the channel declines to start.
Socket Mode is chosen over the Events API webhook for v1 (TNS-350
spec called for the latter) because the framework intentionally has
no HTTP server inside tnsai-channels — every adapter today
pulls from its platform (Telegram long-poll, Email IMAP poll) rather
than accepting inbound HTTP. Adding a public-URL-exposing webhook
receiver would be a much larger architectural change than wiring up
a WebSocket, and would block a homelab deployment topology where
inbound HTTP is not feasible. A signing-secret-verifying
SlackWebhookChannel sibling can be added later if a use case
needs it.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionappToken()Returns the value of theappTokenrecord component.botToken()Returns the value of thebotTokenrecord component.final booleanIndicates whether some other object is "equal to" this one.static Optional<SlackChannelConfig> Populate from environment variables.final inthashCode()Returns a hash code value for this object.Returns the value of thereconnectInitialBackoffrecord component.Returns the value of thereconnectMaxBackoffrecord component.final StringtoString()Returns a string representation of this record class.Returns the value of thewebApiBaseUrlrecord component.
-
Field Details
-
DEFAULT_WEB_API_BASE_URL
Default base URL for the Slack Web API.- See Also:
-
DEFAULT_RECONNECT_INITIAL
Default initial reconnect delay — 1s. -
DEFAULT_RECONNECT_MAX
Default max reconnect delay — 60s.
-
-
Constructor Details
-
SlackChannelConfig
public SlackChannelConfig(String botToken, String appToken, String webApiBaseUrl, Duration reconnectInitialBackoff, Duration reconnectMaxBackoff) Creates an instance of aSlackChannelConfigrecord class.- Parameters:
botToken- the value for thebotTokenrecord componentappToken- the value for theappTokenrecord componentwebApiBaseUrl- the value for thewebApiBaseUrlrecord componentreconnectInitialBackoff- the value for thereconnectInitialBackoffrecord componentreconnectMaxBackoff- the value for thereconnectMaxBackoffrecord component
-
-
Method Details
-
fromEnvironment
Populate from environment variables. Missing required vars returnOptional.empty()so the channel can decline to start without raising an exception.Recognised vars:
SLACK_BOT_TOKEN(required),SLACK_APP_TOKEN(required),SLACK_WEB_API_BASE_URL(optional override for mirrors/proxies). -
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
botToken
Returns the value of thebotTokenrecord component.- Returns:
- the value of the
botTokenrecord component
-
appToken
Returns the value of theappTokenrecord component.- Returns:
- the value of the
appTokenrecord component
-
webApiBaseUrl
Returns the value of thewebApiBaseUrlrecord component.- Returns:
- the value of the
webApiBaseUrlrecord component
-
reconnectInitialBackoff
Returns the value of thereconnectInitialBackoffrecord component.- Returns:
- the value of the
reconnectInitialBackoffrecord component
-
reconnectMaxBackoff
Returns the value of thereconnectMaxBackoffrecord component.- Returns:
- the value of the
reconnectMaxBackoffrecord component
-