Clarke Slack is Clarke UI plugin to interact with the Slack Platform.
In your slack route code
ruby
require 'clarke'
require 'clarke/slack'
post '/slack' do
parameters = JSON.parse(params[:payload])
return render json: {}, status: 403 unless valid_slack_token(parameters)
Clarke.process(Clarke::Slack, parameters)
end
There are 3 types of events:
TextMessage(includeClarke::TextMessage)TextCommand(includeClarke::TextMessage) - TODOButton(includeClarke::Button) - TODO
All the Slack Events have to the following attributes:
response_urltimestampsender(instance ofClarke::Slack::User)
A TextMessage have to the following attribute: text
A TextCommand have to the following attributes: command, text and
parameters
A Button have to the following attributes: action that is an instance of
Clarke::Slack::Action (with a name and a value) and callback_id
There are 3 types of responses:
-
TextMessage- TODO -
EphemeralMessage- TODO -
Button- TODO
A TextMessage have to the following attribute: text.
A response is converted in TextMessage if it contains a text and no buttons or ephemeral options.
This send a text message, only visible for the recipient.
A EphemeralMessage has the following attribute: text.
A message is converted in EphemeralMessage if the option ephemeral is added
into the response.
A ButtonTemplate has the following attributes : text, buttons, options which
contains a callback_id and could contain color and sub_text attributes.
In each button, is stored different attributes : name, text, value.
A response is converted into ButtonTemplate if it has a text and buttons.
Different slack API URL are stored into Clarke::Slack::Config:
API_SEND_MESSAGE = "https://slack.com/api/chat.postMessage?"
API_USER_LIST = "https://slack.com/api/users.list?"
API_CHANNEL_LIST = "https://slack.com/api/channels.list?"
API_USERGROUP_LIST = "https://slack.com/api/usergroups.list?"