Trigger the Slack message to light up the SwitchBot Color Bulb.
- Slack with paid plan
- Slack CLI
- SwitchBot Color Bulb
- SwitchBot API Key
- SwitchBot device id
-
Setup
git clone https://github.com/Doarakko/release-party cd release-party
-
Enter your release message and channel ids to
triggers/trigger.ts
event: { event_type: TriggerEventTypes.MessagePosted, filter: { version: 1.0, root: { operator: "AND", inputs: [ { // triggers only bot messages statement: "{{data.user_id}} == null", }, { operator: "OR", inputs: [ { statement: "{{data.text}} CONTAINS 'deploy'", }, { statement: "{{data.text}} CONTAINS 'test'", }, ], }, ], }, }, channel_ids: [_test_channel_id], },
-
Deploy
slack deploy slack trigger create # SwitchBot slack env add SWITCHBOT_API_KEY <your key> slack env add SWITCHBOT_DEVICE_ID <your id>
When updating the trigger, run the following command.
slack trigger update --trigger-id=yyyy
-
Enter your environmental variables to
.env
cp .env.example .env
-
Run
slack run slack trigger create
curl -X POST -H 'Content-type: application/json' --data '{"text":"test"}' "https://hooks.slack.com/services/xxxx/yyyy/zzzz"
curl "https://api.switch-bot.com/v1.0/devices" -H "Authorization: <SWITCHBOT_API_KEY>"
# on
curl -X POST -H 'Content-type: application/json' --data '{"command": "turnOn"}' "https://api.switch-bot.com/v1.0/devices/<SWITCHBOT_DEVICE_ID>/commands" -H "Authorization: <SWITCHBOT_API_KEY>"
# off
curl -X POST -H 'Content-type: application/json' --data '{"command": "turnOff"}' "https://api.switch-bot.com/v1.0/devices/<SWITCHBOT_DEVICE_ID>/commands" -H "Authorization: <SWITCHBOT_API_KEY>"