Clover is a framework for building chat bots in Elixir. It takes inspiration from Hubot and Hedwig. Like Hubot and Hedwig, Clover:
- uses adapters so you can connect your bot to various platforms
- allows you to specify multiple handlers for incoming messages
- associates a regular expression for matching messages with a function that transforms the message into a response
Like Hedwig, Clover:
- supervises processes for fault tolerance
Clover adds some features:
- matches each incoming message with at most one handler (e.g., no double responses)
- allows you to start your robot under Clover's supervision tree, or under your own
- configuration happens at runtime, not through application config
Planned features for Clover:
- only ever responds to messages addressed to your robot (e.g., no "hear" handlers)
- maintains "room state", so your robot can carry on conversations
- handles messages in their own worker processes
The package can be installed by adding clover
to your list of dependencies in mix.exs
:
def deps do
[
{:clover, "~> 0.1.0"}
]
end
Coming soon. See the Test Robot for an example.
Clover bots always run under a Clover.Robot.Supervisor
process. The supervisor handles crashes in your robot or in its adapter, and restarts processes as needed. However, you have some choice as to who supervises the supervisor.
Let's say you have a Clover bot called Mybot
. To start a robot under Clover's supervision tree, provide a name, your bot's module, and an adapter:
Clover.start_supervised_robot("mybot", Mybot, {Clover.Adapter.Slack, token: "my-slack-bot-token"})
Clover will start your robot under its own supervision tree, and manage it for you.
(The name you provide here will be used to register your robot with Clover. It's not your robot's chat nick.)
To handle supervision yourself:
Clover.start_robot("mybot", Mybot, {Clover.Adapter.Slack, token: "my-slack-bot-token"})
The individual robot and adapter processes will still be supervised by a Clover.Robot.Supervisor
, but you can place this process into your own supervision tree, for greater control over its lifecycle.
Clover is designed to support multiple chat platforms through adapters. Currently, there is a test adapter bundled with Clover, and a Slack adapter (which is also bundled with Clover, but will be pulled out in the future).