slack v0.1.0 Slack

This module defines the Slack struct. Use create/1 to convert webhook request data from Slack for parsing slash command and interactive message requests.

Slack struct contains the below fields. The default value of these fields is nil if the incoming request does not contain a matching field name.

  • action - map with :name and :value for action request (action request only)
  • command - slash command string (command request only)
  • text - the text string following the slash command (command request only)
  • team - map with :domain and :id for Slack team
  • channel - map with :name and :id for Slack channel
  • user - map with :name and :id for Slack user
  • token - validation token used to confirm request came from Slack
  • reponse_url - string containing URL for delayed response to request

Action request only fields (nil for command requests)

  • callback_id - string of callback_id from message attachment
  • action_ts - string timestamp when action occurred
  • message_ts - string timestamp when message containing action was posted
  • attachment_id - string id for specific attachment within message
  • original_message - original message JSON object

See Slack docs for responding to button actions and slash commands

Summary

Functions

Converts incoming Slack HTTP request params to a Slack struct. params is expected to be a string-keyed map with either an "actions" or "command" key to determine the request type

Types

t()
t() :: %Slack{action: term, action_ts: term, attachment_id: term, callback_id: term, channel: map, command: term, message_ts: term, original_message: term, response_url: term, team: map, text: term, token: binary, user: map}

Functions

create(params)
create(map) :: Slack.t

Converts incoming Slack HTTP request params to a Slack struct. params is expected to be a string-keyed map with either an "actions" or "command" key to determine the request type.

Returns {:ok, struct} if params are valid format. Returns {:error, message} if params does not match the expected request data from Slack.