A docker image for listening on Amazon Dash Buttons and trigger events when one gets clicked.
You can get the build docker image form here:
In order to run this container you'll need docker installed.
You will have to configure a config.json to configure your Amazon Dash Buttons and give information to services.
To start the docker container use the following command:
docker run -d --name dash-button --net=host --restart unless-stopped --privileged -v /pathToConfig.json:/config.json fusonic/amazon-dash-buttons:latest
Change pathToConfig.json to match your config.json file.
--net
- have access to the network, which dash-buttons are connected to--privileged
- being able to inspect packages in the host system-v
- mount the json file into container
There is a config.example.json located in the root of the project, where you can see how your config file could look like.
Here is an example on how to configure a dash button:
"buttons": [
{
"mac": "xx:xx:xx:xx:xx:xx",
"provider": "slack",
"providerConfig": {
"stuffForProvider": "beep"
}
}
]
And a provider:
"providerConfig": {
"slack": {
"stuffForProvider": "beep"
}
}
A complete config.json could look like this:
{
"buttons": [
{
"mac": "xxxx",
"provider": "slack",
"providerConfig": {
"channel": "xxxx",
"username": "dash-bot",
"text": ":grin:",
"icon_emoji": "true"
}
}
],
"providerConfig": {
"slack": {
"token": "xxxx"
}
}
}
Currently the following providers are supported:
- Bring
- Meeting Reminder (sends a reminder for a Google Calender event via Slack)
- Slack
- Webhook (sending GET and POST requests)
If the provider you are looking for is currently not supported, feel free to integrate it into the project. Therefore have a look at the Contribute section.
There is a detailed README.md file covering how to configure your config.json here.
You can also find the file here well formated on Github.
To add a new provider you must create a JavaScript file in files/opt/dash-button/scripts/providers/providerName/providerName.js and register the provider as a module.
Here an example on Slack
module.exports = {
dashHandler : function (sender, providerConfig) {
// magic
}
};
Note: the file must have the same name as the provider declared in the config.json!
The dashHandler
function is called with two parameters:
sender
- containing information from buttonproviderConfig
- containing information
With these parameters you can access information declared in the config.json file.
We created a rundev file that mounts the scrips folder as a volume, which is useful for developing new features.
# build docker image for development
docker build -t dev/dash-buttons .
# start run file
./rundev
- Docker
- NodeJS
This project is licensed under the MIT License.