Automaton v0.1.0 Automaton.Bot behaviour View Source
Defines a bot.
Acts as a wrapper around an messaging adapter to make it easy to swap adapters without having to change your code.
When used, the bot expects :otp_app
as an option.
The :otp_app
should point to an OTP application that has the bot
configuration. For example, the bot:
defmodule Sample.Bot do
use Automaton.Bot, otp_app: :sample
...
end
Could be configured with:
config :sample, Sample.Bot,
adapter: Automaton.Adapters.FacebookMessenger,
access_token: "XYZ"
Most of the configuration that goes into the config is specific to the adapter, so check the adapter’s documentation for more information.
Note that the configuration is set into your bot at compile time.
If you need to reference config at runtime you can use a tuple like
{:system, "ENV_VAR"}
.
config :sample, Sample.Bot,
adapter: Automaton.Adapters.FacebookMessenger,
access_token: {:system, "FB_MESSENGER_TOKEN"}
This will forward responses to the bot which will then parse it using the adapter configured and start a conversation.
Link to this section Summary
Functions
Parses the OTP configuration at compile time
Callbacks
Callback to handle an incoming message
Link to this section Types
Link to this section Functions
Parses the OTP configuration at compile time.
Link to this section Callbacks
process(sender_id, message_text, context) :: :ok | {:error, term}
Callback to handle an incoming message