Robots in Disguise, Part 2: Trimming Your Decision Tree

Dave Huynh
4 min readMay 9, 2016

--

Welcome to part 2 of my series on learning about conversational interfaces a.k.a chat bots by building one. Multi-user support and testing has been delayed due to authentication issues. So for this installment, I’m going to instead focus on a feature request I received from a couple of friends and the insights I derived from that feature.

The Use Case

If you recall from Part 1, the bot I’ve built is a helper for olympic weightlifters and helps keep track of and calculate weights needed for various strength exercises. For example, you ask the bot for your best back squat and he returns the amount of weight in pounds or kilograms.

The requested feature is pretty simple: for a given weight, tell the user which weight plates a.k.a. bumper plates to stack on the barbell.

For example, a male who is lifting 185lbs will need a barbell (45lbs) + two 45lb plates + two 25lb plates.

Similarly, a male who is lifting 105kg will need a barbell (20kg) + two 25kg plates + two 15kg plates + two 2kg plates + two 1/2kg plates. This is seen in the first loaded barbell below:

Barbells loaded with assorted kilogram bumper plates and change plates

This is a pretty useless feature as far as weightlifting training goes,* but building it offered a learning opportunity as I try to solve this problem using a chat bot interface.

*It is never advisable to go directly from not lifting to a max or even percentage of a max lift. Always warm up properly.

Implementation

For simplicity, I’m going to gloss over how the required plate stacks are calculated. You can find my simplified version of the calculation used by RockyBot on GitHub.

Here is the feature in action:

The user can trigger the weight stacking feature by asking the bot to “stack” the weight or “plate” the weight. Right now, it returns different stack options for each side of the barbell in the form of simple arrays. We will look at better and more advanced ways of presenting this and other information in a future installment of this series.

The task for the bot seems pretty straightforward, but in order to identify the correct arrangement of weight plates, we have to traverse down a decision tree that looks something like this:

Rocky’s decision tree as he calculates what plates to put on the barbell

For a given weight, the bot needs to know which kind of plates (which unit) to use. It needs to know whether the lifter is male or female i.e. whether to use a 20kg/45lb or 15kg/35lb bar. Finally, it needs to know what plates are available at the gym (shown above as sets of plates).

Once the bot knows all the information it tries to give the user a couple of options for stacking the plates to get the desired weight.

In the demo video, I bypass the need to traverse the tree and ask a bunch of questions by:

  1. Assuming the units of the weight based on the user’s previous request
  2. Grabbing gender from Facebook (a plus for building a FB Messenger bot)
  3. More or less assuming the lifter has access to an ‘unlimited’ set of plates, but below the theoretical maximum a human can lift.
It is safe to assume most people won’t need as many plates as Olympic champion Alex Torokhtiy

These assumptions and “tricks” allowed me to make Rocky seem more intelligent than he actually is.

Key Takeaways

  • The same advantage of using a chat bot (no visual and button inputs) makes for a huge disadvantage when trying to collect information from the user. On a screen, you can ask for and get a lot of information with form fields, buttons, toggles, etc… With a chat bot, you have to ask for this information conversationally.
  • A back and forth Q&A between the user and the bot to get these critical pieces of information feels more like a telephone menu tree than the next great user interface and should be avoided at all costs.
  • To make the user experience smooth it is crucial to know, predict, or assume as much information as possible and trim nodes off your decision trees.
  • The emergence of quality artificial intelligence and predictive analystics helps to solve this knowledge problem and, for me, explains why bots are just now becoming a much more viable user interface.

Next Time

I’m going to finish true multi-user support and report back on what I learn from watching my test group use the bot during weight training.

--

--