November 21, 2016 | Written by: Etienne Rocher
Categorized: How-tos | Watson
Share this post:
Last summer, David Azoulay, co-founder & owner at Simplicité Software, spoke at a Bluemix meetup in Atlanta. The aim of his presentation was to answer this question: “Do you need a flexible and reliable platform to create custom strategic enterprise applications?” The answer was mainly yes. But “yes” is not an answer without a proper demonstration. For that, we took examples of feedback offered by restaurant customers.
As many studies show, advice and feedback from customers is important. Service review websites, like TripAdvisor or Yelp, are based on customer input. Without the feedback, the popularity of theses sites would not be the same. A TripAdvisor survey highlighted some interesting figures:
- 96% of TripAdvisor users consider reading reviews important when planning trips and booking hotels.
- 83% of TripAdvisor users will “usually” or “always” reference reviews before deciding to book a hotel.
With online reviews having such a strong influence, it reinforces the value of a successful online reputation, as well as the potential positive impact on revenue.
Let’s get back to the point: The purpose of the demo is to offer a responsive website front-end app for sharing advice about local restaurants. To do so, we’ll use Simplicité, an enterprise low-code platform, designed for agile and cost-effective business back-end applications, on Bluemix.
If you haven’t started a Simplicité instance on Bluemix yet, you can follow this article to learn how. For an introduction to Simplicité, visit this page.
Sign up for Bluemix. It’s free!
First, we will use it to build the back end. Then, we’ll use Node-RED for the front end. Everything will be running on Bluemix. During the demo, the declarative satisfaction evaluation is replaced by an automatic calculation of the satisfaction percentage based on the analysis of the comments’ tone. The tone analysis capability is provided by the corresponding Watson service (focusing on the “joyness” scores), which is bound on the Node-RED front end. The actual calculation of the satisfaction evaluation percentage is done in the back-end from the raw Watson service output returned by the front end.
The restaurant demonstration is a simple example, but you can extrapolate this kind of service for any business.
The Big Picture
The grey area shows the scope of components provided within Bluemix:
- the Simplicité instance;
- the Node-RED app; and
- the Watson Tone Analyzer service.
The OpenDataSoft dataset service (and its source of OpenStreetMap POIs) is external to Bluemix.
All of this is assembled in Bluemix:
- A Node-RED app is deployed (with the Simplicité nodes added, the Watson nodes being available by default).
- Watson Tone Analyzer is deployed and bound to the Node-RED front end.
- A Simplicité instance is deployed and bound to the Node-RED front end.
Let’s configure our Simplicité back-end application
For this demo we need a simple business objects model to be configured in Simplicité:
- One object for the location (“RstLocation”)
- One object for the restaurants (“RstRestaurant”)
- One object for the comments (“RstComments”)
A restaurant is linked to a location, and several comments are linked to a restaurant (see example below).
Here is the corresponding configuration file if you want to load it it on your own Simplicité instance.
If you want to learn more about the modeling and configuration in Simplicité, you can have a look at our training documentation.
Let’s load our reference data into the back end application
For the demo, we first need to enter manually a list of locations (e.g. Atlanta, GA; Chicago, IL; etc.) which are automatically geolocalized.
Then, we need to get a list of restaurants for these locations. A good source of data is the OpenStreetMap POIs (of type “restaurant”), which are—hopefully—available as a OpenDataSoft dataset (Simplicité having a built-in generic connector for OpenDataSoft datasets).
You can find this dataset by going to opendatasoft.com and searching for “OpenStreetMap.” The dataset is the one named “OpenStreetMap POIs – USA” (see example below).
Here’s another screen shot example:
The Simplicité configuration does the filtering and loading of corresponding data at the location level (using the “Refresh data” custom action).
Let’s build the Node-RED front-end application flows
By default the Bluemix Node-RED boilerplate includes Watson nodes. In this case, you will need to add the Simplicité nodes (see this GitHub repository).
Node-RED allows you to visually connect elements from Simplicité to Node-RED. Once added you will have 2 extra nodes:
Once the Simplicité instance is bound to the Node-RED app, theses nodes are used to interact with the back-end business objects managed in Simplicité.
The initial Node-RED flows (available for download here) uses only explicitly entered evaluation:
These flows expose some HTTP endpoints, which interact with the Simplicité back end:
- The /restaurants GET endpoint is the landing page that uses the other endpoints as dynamic contents; it is the entry point.
- The /restaurants/main GET endpoint is the main component that first allows you to select a location and then displays the paginated list of the restaurants attached to this location.
- The /restaurants/comments GET endpoint is the component that displays a selected restaurant’s comments in a popup.
- The /restaurant/comments (POST) endpoint is the component that formats and post a new comment.
- The /news endpoint that retrieves the generic news data from the Simplicité back end.
Let’s see all this in action
When you point your browser to the landing page, a box prompts you to select your location:
Then, the list of this location’s restaurants is displayed:
If you click on one restaurant’s “Comments” button, you get a pop-up with the list of all comments already entered for this restaurant and a form to enter new comments if you wish:
Initially, you will see that the evaluation is a 5-level radio button that you need to enter.
In the corresponding HTML page node, you can see the static HTML form component:
Avoid the explicit evaluation and instead deduce it from the “tone” of your comment.
To do so, we have two options in Node-RED:
- Using the “sentiment analysis” node provided by default in the Node-RED app; or
- Using the “tone analysis” node available when you bind the corresponding Watson service to the Node-RED app.
Let’s try both!
First option: Add simple sentiment analysis
The simple sentiment analysis node gets the comment as input and outputs a score between -5 and +5 depending on the words found in the comments.
This node can be added to the POST flow like this:
Once added, the explicit HTML form elements for evaluation can be removed.
On the back-end side, a new integer field has to be added to the “RstComments” business object to store the result of the sentiment analysis node along with the comment.
The “preValidate” hook of the “RstComments” object has to be implemented to transform this -5 to +5 score into a 0-100% percentage:
Once this is complete, a newly entered comment is analyzed on the front end, and the evaluation percentage is calculated on the back end.
Second option: Add Watson tone analysis
To get a more accurate result, we can now use the Watson Tone Analyzer service instead of the simple sentiment analysis above.
Once the Watson service is instantiated and bound to the NodeRED app, the dedicated node (v3) can be used:
In our case we choose to use only the “Emotion” analysis and, in particular, the “Joy” score.
The Watson node output is a complex JSON structure that is parsed and transformed into an evaluation percentage on the back-end side using the same approach as above:
And there it is! With this demonstration, you have seen that using Simplicité as an adaptative back end and Node-RED+Watson as agile front end allows you to build modern, flexible, end-to-end business applications on Bluemix.
Now it is time for you to try Simplicité on Bluemix! You can use our Node-RED nodes available on Github and the initial Node-RED.