SlackAPI

Hex.pm Version

This project is designed to simplify the use of the Slack API by downloading API JSON data from the Slack API documentation(ex_slack_api_docs) and generating Elixir modules for each API.

This project reduces the friction often encountered when working with the Slack API, enabling developers to implement features more quickly and effectively.

Installation

If available in Hex, the package can be installed by adding slack_api to your list of dependencies in mix.exs:

def deps do
  [
    {:slack_api, "~> 1.2"}
  ]
end

Update API

Run the following command to generate the Slack API documentation in JSON format,

which will be downloaded and created in the docs directory.

$ mix slack_api_docs.gen.json docs

To generate Elixir API modules based on the JSON file, execute the following command:

$ mix slack_api.gen

Usage

just chat to channel

bot_token = "xoxb-00000000000-0000000000-OOOOOOOOO"
SlackAPI.req(%SlackAPI.Chat.PostMessage{
  token: bot_token,
  channel: "BBUNGBBUNG",
  text: "blahblah"
})

call apps.conversations.open api (for socket mode)

app_token = "0000-00000000000-0000000000-OOOOOOOOO"
SlackAPI.req(%SlackAPI.Apps.Connections.Open{token: app_token})