slackline/socket_mode
This module is generated by gleam run -m slackline_codegen/generate. Do not edit it by hand.
Socket Mode: receive events, interactions and slash commands over a WebSocket instead of a public request url.
Open a connection url with slackline/api/apps.connections_open and an
app-level (xapp-) token. Connect a WebSocket client to it. Decode each
text frame with socket_mode.parse. Answer every message that has an
envelope_id within three seconds with socket_mode.ack(envelope_id).
slackline/app.handle_socket does all of that for an app. See
https://docs.slack.dev/apis/events-api/using-socket-mode.
Types
pub type ConnectionInfo {
ConnectionInfo(app_id: option.Option(String))
}
Constructors
-
ConnectionInfo(app_id: option.Option(String))
Diagnostic details Slack attaches to hello and disconnect messages.
pub type DebugInfo {
DebugInfo(
host: option.Option(String),
started: option.Option(String),
build_number: option.Option(Int),
approximate_connection_time: option.Option(Int),
)
}
Constructors
-
DebugInfo( host: option.Option(String), started: option.Option(String), build_number: option.Option(Int), approximate_connection_time: option.Option(Int), )Arguments
- approximate_connection_time
-
Roughly how long, in seconds, until Slack refreshes this connection.
Why Slack is closing a connection.
pub type DisconnectReason {
Warning
RefreshRequested
LinkDisabled
UnknownDisconnectReason(String)
}
Constructors
-
WarningThe connection will be closed in about ten seconds. Open a new one.
-
RefreshRequestedSlack is about to refresh the connection. Open a new one.
-
LinkDisabledSocket Mode was turned off for the app.
-
UnknownDisconnectReason(String)A value that this version of slackline does not know.
One message received over a Socket Mode WebSocket.
pub type SocketMessage {
Hello(
num_connections: option.Option(Int),
connection_info: option.Option(ConnectionInfo),
debug_info: option.Option(DebugInfo),
)
Disconnect(
reason: DisconnectReason,
debug_info: option.Option(DebugInfo),
)
EventsApi(
envelope_id: String,
payload: event.Envelope,
accepts_response_payload: option.Option(Bool),
retry_attempt: option.Option(Int),
retry_reason: option.Option(String),
)
Interactive(
envelope_id: String,
payload: interaction.Interaction,
accepts_response_payload: option.Option(Bool),
)
SlashCommands(
envelope_id: String,
payload: command.SlashCommand,
accepts_response_payload: option.Option(Bool),
)
UnknownSocketMessage(type_: String, raw: value.Value)
}
Constructors
-
Hello( num_connections: option.Option(Int), connection_info: option.Option(ConnectionInfo), debug_info: option.Option(DebugInfo), )Sent when a connection is ready.
-
Disconnect( reason: DisconnectReason, debug_info: option.Option(DebugInfo), )Slack is about to close this connection.
-
EventsApi( envelope_id: String, payload: event.Envelope, accepts_response_payload: option.Option(Bool), retry_attempt: option.Option(Int), retry_reason: option.Option(String), )An Events API delivery. Acknowledge it with
ack. -
Interactive( envelope_id: String, payload: interaction.Interaction, accepts_response_payload: option.Option(Bool), )An interactivity payload (block actions, view submissions, shortcuts, …). Acknowledge it with
ackorack_with. -
SlashCommands( envelope_id: String, payload: command.SlashCommand, accepts_response_payload: option.Option(Bool), )A slash command. Acknowledge it with
ackorack_with. -
UnknownSocketMessage(type_: String, raw: value.Value)A
typethat this version of slackline does not know.rawholds the full json.
Values
pub fn ack_with(
envelope_id: String,
payload: json.Json,
) -> String
The frame that acknowledges a message with a response payload, for
messages where accepts_response_payload is true (for example a slash
command reply or a view submission response_action).
pub fn connection_info_decoder() -> decode.Decoder(ConnectionInfo)
Decodes ConnectionInfo from json.
pub fn connection_info_to_json(it: ConnectionInfo) -> json.Json
Encodes ConnectionInfo as json.
pub fn debug_info_decoder() -> decode.Decoder(DebugInfo)
Decodes DebugInfo from json.
pub fn disconnect_reason_decoder() -> decode.Decoder(
DisconnectReason,
)
Decodes DisconnectReason from a json string.
pub fn disconnect_reason_from_string(
string: String,
) -> DisconnectReason
Parses DisconnectReason from its json string.
pub fn disconnect_reason_to_json(
it: DisconnectReason,
) -> json.Json
Encodes DisconnectReason as a json string.
pub fn disconnect_reason_to_string(
it: DisconnectReason,
) -> String
The json string of DisconnectReason.
pub fn envelope_id(
message: SocketMessage,
) -> option.Option(String)
The envelope id of a message that needs acknowledging, if any.
pub fn parse(
frame: String,
) -> Result(SocketMessage, json.DecodeError)
Decodes one WebSocket text frame.
pub fn socket_message_decoder() -> decode.Decoder(SocketMessage)
Decodes SocketMessage from json. The type field selects the variant.
pub fn socket_message_to_json(it: SocketMessage) -> json.Json
Encodes SocketMessage as json.