Skip to content

clearfunction/clearbot

Repository files navigation

ClearBot

This code is a Slack application (bot) written using Slack Bolt. It allows users to play mp3 clips on a Sonos speaker. It communicates with Sonos Proxy which then communicates with node-sonos-http-api.

We affectionately refer to this as "Burn Bot."

Architecture

sequenceDiagram
    Slack-->>ClearBot: POST /slack/events { some message }
    ClearBot-->>Sonos Proxy: websocket play_url { some message }
    Sonos Proxy-->>node-sonos-http-api: GET http://localhost:5001/Office/clip/burn.mp3

Requirements

  • NPM
  • Node

Running Locally

The easiest way to test is to set this up in a standalone Slack instance and then use a local proxy like ngrok.

  • Create a Slack application (see Slack Bolt API link below)
  • Run npm run dev (it defaults to port 3000)
  • Run ngrok to create a proxy to your Bolt app (ngrok serve 3000)
  • Point your Slack's event subscription to your ngrok URL
  • Set up Sonos Proxy
  • Enjoy!

Deployment

See the Makefile... make sure you are in the expected subscription by running az account set --subscription YOUR_SUBSCRIPTION_ID.

Resources