Bot of Slack written by elixir.
- This application supervise Slack and Supervisor of actions. Actions are separated from process of Slack.
- This bot uses Elixir-Slack. Thanks a lot.
-
To add bot action, open
lib/bot_action/action.ex
. -
Bot action has two functions.
hear/3
andrespond/3
. -
For example, when bot listened 'hello', bot sends a message to Slack.
def hear("hello", message, slack) do
send_message("Hello World !!", message, slack)
end
- For example, when bot received 'who', bot sends a message to Slack.
def respond("who", message, slack) do
send_message("My name is bot.", message, slack)
end
-
Create Bot at Slack and get API Token.
-
Make
config/config.exs
or set environmentMAGICBOT_API_KEY
that has API token.
config/config.exs
use Mix.Config
config :MagicBot,
api_key: "Your API Token"
- Run
mix run --no-halt
.ThenConnected as name
will be displayed. Your bot can receive message from Slack.