Creates the ability to add stories to PivotalTracker from Slack via a !pivotal
trigger word.
Do you use Slack? Do you use PivotalTracker? Want to be able to quickly add stories to PivotalTracker from Slack?
The function uses simple Slack Channel => Pivotal Project pairings. So, for example, you could have a Slack channel named #devops which had a corresponding DevOps Pivotal Project.
Example Usage: !pivotal clean up the apache settings; our server isn't using https
in the #devops channel would create the story "clean up the apache settings" in the DevOps PivotalTracker project, with the description "our server isn't using https"
The code in this repo is designed to run as an AWS Lambda Function
- Privileges to create an AWS Lambda Function
- Privileges to add a custom Slack integration
- awscli Installed
- A PivotalTracker API token
- [Recommended] Create a non-person account on PivotalTracker (e.g. a user named "Slack") This is because stories' underlying "created_by" field in PivotalTracker will be whatever account's API token is used.
- Get PivotalTracker API token
- Create a
dictionary.json
file to define Channel=>Project pairings - Upload the dictionary file to S3 with public-read permissions
- Create a
bangpivotal
Lambda - Set 2 environment variables in the Lambda
- pivotal_token
- json_dictionary_url
- Add an API Gateway trigger
- Create a Slack Outgoing WebHook
- Point the Slack WebHook at the API Gateway trigger URL
- Set 3rd environment variable in the Lambda
- slack_token
- Bundle the code into bundle.zip
- Upload bundle.zip to Lambda
The Pairings Dictionary is a simple JSON file containing key-value pairs where the Slack channel is the key and the value is the corresponding PivotalTracker project ID number.
- Clone the repo.
- Make a copy of
example_dictionary.json
and name itdictionary.json
- Edit
dictionary.json
to create whatever channel=>project pairings you want.- You will need the PivotalTracker project ID numbers (they're in the URLs)
- Store your
dictionary.json
in Amazon S3:aws s3 cp dictionary.json s3://path/to/bucket --acl public-read
- Get the web URL of the dictionary.json, you'll need it.
The Lambda function needs 3 key pieces of information in order to function. The Slack token, the Pivotal token, and the URL of the pairings dictionary.
- Log in to the AWS Console Lambda service.
- Create a new blank Lambda function named
bangpivotal
. - Add an API Gateway trigger with "Open" security to
bangpivotal
. - Copy the URL of the API Gateway, you'll need it.
- Add 3 environment variables to
bangpivotal
:
slack_token
-- Get this value from your Slack outgoing webhook integrationpivotal_token
-- Get this value from PivotalTracker in the "Profile" settingsjson_dictionary_url
-- This is the URL to your dictionary.json file in S3
- Set the Lambda handler to be
bangpivotal.lambda_handler
. - In the repo directory, run
./bundleit.sh
to zip up the code into a file namedbundle.zip
- Upload the new bundle.zip:
aws lambda update-function-code --zip-file fileb://bundle.zip --function-name bangpivotal
You will need to configure your Slack outgoing webhook to trigger on !pivotal
and point it to the trigger API Gateway URL from the previous Lambda instructions.
- Go to https://YOURSLACK.slack.com/apps/build/custom-integration
- Outgoing WebHooks > Add Outgoing WebHooks integration
- Channel: Any
- Trigger Word(s):
!pivotal
- URL(s): [the API Gateway URL of your Lambda Function]
These instructions are pretty hasty and assume you have at least some idea of how to use webhooks/AWS/Slack/etc.
Also my code is probably pretty ugly. Please feel free to pretty it up.