Smart answers, smart solution for decision trees

Smart answers are a great tool for content designers to present complex information in a quick and simple way. Defining what they are - decision trees? calculators? tools? is immaterial - what they do is provide a reusable technical framework to build a quick and simple answer to a complex question.

In Hashdog we found a completely different project than usual, in this project it was necessary to go through the flow of the questions of a tree of the decisions in a friendly way for an Internet user, the challenge was to avoid the long and boring forms and the unrelated questions. This tree flows of the decisions were previously revealed by the client, then the time came to dump these bunch of questions to code, the fun part.

The goal was to present the questions in a friendly way and of course to develop this in the most effective way, investing the least possible time without leaving aside the quality and robustness of the application. Smart answers are presented as an intelligent answer to all these requirements.

Smart decision

Smart Answers is a Ruby on Rails application, developed by GOV.UK and published under MIT license.

The developers behind our smart answer framework thought about creating a tool where they can encode the different queries flow from a decision tree in a language familiar to the developers. All this to take advantage of that you are accustomed to working with classes, modules, and methods, in addition to the elegance and friendly syntax of the Ruby language. To know more about this framework please visit the official documentation, it is well detailed in the repository on Github, here we will only tell about our experience with it.


The setup it was simple, just keep in mind that the front-end is in a different repository, anyway you just have to keep the usual steps, clone the repository first, We prefer to use ssh:

git clone [email protected]:alphagov/smart-answers.git  

Then we run bundle to install the dependencies:


And... that's it!. You don't have to configure any database because smart answer doesn't use any db.


We begin to encode the different streams of previously thought out questions.
At the heart of each Smart Answer is a subclass of SmartAnswer::Flow.
Subclasses like this make a DSL available for specifying metadata and defining all the question nodes, the outcome nodes, and the rules to control routing between the nodes.

Question nodes are defined by calls to one of the various question-type methods. Since the value of self at the "top-level" within the #define method is an instance of the flow, these question-type methods are defined on the SmartAnswer::Flow base class. Here the questions types

We customize the general look and feel to fit the client's taste and requirements, modifying the CSS files.
In our case, we were creating the tests for each case while developing it, but you can use whatever development methodology you prefer.

Running test, QA test returns and deploy to a server to have it online were the final steps.


Our experience with Smart Answer was very good in every way and we recommend it when you have the same requirement. Now if you have any concern or question about Smart Answers please leave a comment or just contac us

You can take a look at the projects where we have been or take a tour in the Brochure

God bless you!