The support team at Shortcut uses a version of this script to help us get back to customers about bug fixes and shipped features. It searches for work completed between the last business day and today, checks for support tickets on each Story, and preps data to send to Slack. The name of the Story, a link to the Story, and a count of the number of tickets on the Story are sent to a specific Slack channel, so the support team can quickly find Stories where they need to follow up.
To use this script, open send-stories-to-slack.py
in a text editor. This file will be in the folder where you downloaded the Cookbook repository.
You'll need to have a Slack App set up to use an Incoming Webhook URL to get information from Shortcut into Slack. Slack's guide to setting this up is very friendly!
Place your Slack Incoming Webhooks URL in this line:
`slack_webhook_url = 'https://hooks.slack.com/services/YOUR_DETAILS'`
If you want to reduce the number of completed Stories that are sent to Slack, you can add extra limiters to this line. For example, you can use search operators to limit your results to Stories with a specific owner, or to exclude a specific Project.
If no additional limiters are added, this script will search for all completed Stories in the date range (last business day and today).
# Add any other search limiters like project names, owners, or keywords. limiter = ''
When you've made your changes, save the file.
To run the script, navigate to the folder for the script.
From the main api-cookbook folder:
cd stories-to-slack
Make sure your virtual environment is active. source cookbook/bin/activate
for Mac and cookbook\Scripts\activate
for Windows.
Then type python send-stories-to-slack.py
and press Return/Enter to run the script.