A Python based dice roller for slack in AWS Lambda, based on the AWS Python Slack Command Blueprint, follow the instructions in the file
The command only supports simple dice notations like 2d6+1 or 3d8-2.
Follow these steps to configure the slash command in Slack:
-
Navigate to
https://<your-team-domain>.slack.com/services/new
-
Search for and select "Slash Commands".
-
Enter a name for your command and click "Add Slash Command Integration".
-
Copy the token string from the integration settings and use it in the next section.
-
After you complete this blueprint, enter the provided API endpoint URL in the URL field.
Follow these steps to encrypt your Slack token for use in this function:
-
Create a KMS key - http://docs.aws.amazon.com/kms/latest/developerguide/create-keys.html.
-
Encrypt the token using the AWS CLI.
$ aws kms encrypt --key-id alias/<KMS key name> --plaintext "<COMMAND_TOKEN>"
-
Copy the base-64 encoded, encrypted key (CiphertextBlob) to the
kmsEncyptedToken
variable. -
Give your function's role permission for the
kms:Decrypt
action. Example:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "kms:Decrypt" ], "Resource": [ "<your KMS key ARN>" ] } ] }
```
Follow these steps to complete the configuration of your command API endpoint
-
When completing the blueprint configuration select "POST" for method and "Open" for security on the Endpoint Configuration page.
-
After completing the function creation, open the newly created API in the API Gateway console.
-
Add a mapping template for the
x-www-form-urlencoded
content type with the following body:{ "body": $input.json("$") }
-
Deploy the API to the prod stage.
-
Update the URL for your Slack slash command with the invocation URL for the created API resource in the prod stage.
- Support target numbers, exploding dice, roll-and-keep and other dierolling conventions
- Better formatting of output