This simple script allows the use of Amazon dash button to send an slack message to slack. In order to do so, I am using the node-dash-button module.
Follow the node-dash-button instructions to find your dash-button id.
Get the libpcap dependency:
$ sudo apt-get install libpcap-dev
Clone this repository:
$ git clone https://github.com/imartinezl/dashbutton.git
Start a npm project:
$ npm init
Install the nodejs modules dependencies included in package.json:
$ npm install
Follow Amazon's instructions to configure your button to send messages when you push them but not actually order anything. When you get a Dash button, Amazon gives you a list of setup instructions to get going. Just follow this list of instructions, but don’t complete the final step (#3 I think) Do not select a product, just exit the app.
To find a dash on your network, run the following from the node-dash-button directory in node_modules:
$ cd node_modules/node-dash-button
$ sudo node bin/findbutton
It will watch for new arp and udp requests on your network. There may be several such requests, so press it a few times to make sure. Copy the hardware address as shown below, and make a note of the protocol used.
Note: If your computer has multiple active network interfaces, findbutton
will use the first one listed. If you need to overwrite this setting, pass your preferred interface
as the first argument, such as node bin/findbutton eth6
.
Go to your Slack Workspace >> Administration >> Manage Apps >> Browse:
- Search for: "Incoming WebHooks" and add it*
Then go to Manage >> Custom Integrations >> Incoming WebHooks:
- Copy the "Slack webhook" under the Setup Instructions
Create a .env file specifying the ADDRESS, the SLACK_WEBHOOK_URL and the desired MESSAGE:
SLACK_WEBHOOK_URL='https://hooks.slack.com/services/*********/*********/*********'
ADDRESS='**:**:**:**:**:**'
MESSAGE='Come and join us!! Meeting with food :cake:'
Run the index.js:
$ sudo node index.js