A simple bot that sends Slack notifications when new posts are added to a Piazza page.
To get notifications without having to check the Piazza website or have email notifications clog up your inbox.
The bot is written in Python 3 and requires the following packages:
slacker piazza-api time
To set this up you need to have access to a page on Piazza and have a Slack account with the necessary permissions.
Then follow this link to create a bot. Once you have created a bot make sure to save the API token as you will need it to authenticate your bot.
Consider setting up a new channel for the bot so that it doesn't overrun the #general discussion. Once you have created the channel you can then add the bot by clicking
Channel Settings >
Invite team members to join... > and selecting your bot from the list of users.
You will need to add your credentials for both Piazza and Slack into the relevant places in the file
slackbot.py. All the areas where you need to input information are marked with
TODO. Simply add the relevant information to the empty strings.
An optional parameter
include_link can be passed to the main function to include or exclude a URL to the post when the message is sent. This is set to true by default but can be changed if you do not want to include links.
I suggest using
screen to run the bot on a machine where it can operate constantly without any interruptions. Simply open a new screen window, run the bot by typing
python3 slackbot.py, and then detach from the window.
The bot is set up to constantly print out statements in the window to show that it is running, although you can comment this out if you wish.
The bot will then send a notification to the relevant Slack channel whenever a new post is added to Piazza, including a hyperlink to the relevant post.
Note: The bot will also post links to private messages sent to the user whose Piazza credentials are being used. All users in the channel will be able to see the link but it will only work for the authorized user.
Please feel free to fork this project and make a pull request if you have an contributions you would like to make.