A Slack bot to remotely control your OctoPrint instance on a Raspberry Pi.
ApatoPrint is a nodejs application that runs alongside OctoPrint that connects to the OctoPrint API and the Slack API as a Slack bot. You set up a private channel for it to accept commands from and only add in people you would like to be able to control the printers. From there you can send it commands to do various things like stopping, starting, and getting status updates.
NOTE: Because of various limitations on nodejs version support on older Raspberry Pis this requires a Pi version 2 or greater if you would like to use camera functionality
If you have already done this just skip this section and move on to Setup ApatoPrint.
You have a few options for this. If you are starting fresh you can use the OctoPi Raspbian image you can flash to your SD card that has OctoPrint installed already for you or you can download the source onto a Pi you already have setup and install it from source. Both methods are outlined here https://octoprint.org/download/
If you do not already have Node.js installed on your Raspberry Pi you can find directions on how to install it here https://github.com/nodesource/distributions. You will need at least version 8 but I would recomend installing the latest stable version.
- Change directory to be alongside your OctoPrint install (most likely this is your home directory so
cd ~
) - Get a copy of ApatoPrint via a git clone or downloading a zip from here
- Clone the latest release of this repo into a folder named "ApatoPrint"
git clone --branch v1.1.0 https://github.com/BozarthPrime/ApatoPrint.git ApatoPrint
- Or download the latest release zip and extract it into a folder named "ApatoPrint"
- Clone the latest release of this repo into a folder named "ApatoPrint"
- Change directory into the ApatoPrint folder
cd ApatoPrint
- Install dependencies by running
npm install
Open the settings.json
file and adjust the settings to fit your environment.
- Open OctoPrint settings
- Select API from the left side menu
- Make sure that the "Enable" box is checked
- Copy the "API Key" field into the
octoprint.apiKey
field insettings.json
- Go to https://my.slack.com/services/new/bot
- Set a name for your bot. Ex. "ApatoPrint"
- Click "Add bot integration"
- Copy your "API Token" into the
slack.token
field insettings.json
To make your printer control secure you are going to want to make a private channel between you and your printer where it will accept commands from.
- In Slack click "+" next to Channels
- Name your channel something. Ex. "printer-control"
- In the "Send invites to" field add your bot that you created for ApatoPrint
- Click "Create Channel"
- Open your private channel in a browser and copy the ID in the last segment of the address (it should be 8 alpha-numeric characters. Do not include the trailing slash). Copy that ID into the
slack.commandChannelId
field insettings.json
- Copy your channel name into the
slack.commandChannelName
field insettings.json
The other settings are self explanatory in the names of them. If you are running this on the raspberry pi with OctoPrint as recomended octoprint.address
will be "localhost". If you are running it on something else you will want to use the IP address of the raspberry pi running OctoPrint.
From the main Apatoprint directory run npm start
Print all commands
Syntax:
help
Print a specified file
Syntax:
print <file name>
Pause a running print
Syntax:
pause
Resume a running print
Syntax:
resume
Cancel the running print
Syntax:
cancel
Get the status of the current job
Syntax:
jobstatus
Get a picture of the current job
Syntax:
jobpicture
Get the status of the printer
Syntax:
printerstatus
Display all the files on the server
Syntax:
getallfiles
Manually start a timelapse (only works with ApatoPrint timelapse)
Syntax:
starttimelapse
Manually stop a timelapse (only works with ApatoPrint timelapse)
Syntax:
stoptimelapse
Connect to a printer
Syntax:
connect
Disconnect the printer
Syntax:
disconnect
ๆ็ - For posting and open-sourcing your art.