How Our Slack Bot "Dicebot" Will Work

How Our Slack Bot "Dicebot" Will Work#

Our first lambda function is going to give us a fully functional back-end for a basic chat bot. We're going to develop this for Slack, since Slack is widely used and available for free.

Dicebot Project Description#

Our first lambda function is going to give us a fully functional back-end for a basic chat bot. We're going to develop this for Slack, since Slack is widely used and available for free.

The use case is as follows:

Dicebot should provide users in a slack channel the ability to roll one or more dice by invoking a slash command /roll . The dice being rolled can have any number of sides, but our bot will default to rolling a single 20-sided die when no parameters are specified. When multiple dice are rolled at the same time, the bot should provide the sum of all rolled values in addition to each individual roll.

We will use the dice rolling terminology standardized by various Role-Playing Games as input for Dicebot. In terms of slack input, that means are command usage will be \roll {NUM_DICE}d{DICE_SIDES}.

NUM_DICE is an integer value that denotes the number of dice that we wish to roll. Whenever not specified, NUM_DICE will default to 1

Directly following NUM_DICE, the letter d should be used as a separator between the NUM_DICE and DICE_SIDES values.

DICE_SIDES is another integer, and it the third and final value in the command input. This value represents the number of sides that each dice has. When not specified DICE_SIDES should default to 20.

There should be no spaces separating each input value. For example, to roll two 6-sided dice, we would send the command as /roll 2d6.

Edge case: If the character d is not included, and the input is only a single integer (eg, /roll 3), that is taken to mean _roll 3 dice with the default number of sides - aka equivalent to /roll 3d20.

No discussions yet