How-tos

Build a simple restaurant advisor app using Simplicité, Node-RED and IBM Watson

Share this post:

simplicite_bw_logoLast 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.

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.

Diagram of Simplicite, Watson and Bluemix app

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.

Bluemix screenshot of components

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).

Diagram of connections

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).

Screen shot of OpenStreetMap POIs

Here’s another screen shot example:

Screen shot of OpenStreetMap POIs - USA

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:

Screen shot of Simplicite object nodeScreen shot of Simplicite session node

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:

Diagram of the Initial Node-RED flow

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:

Screen shot of Simplicite Advisor - Locations

Then, the list of this location’s restaurants is displayed:

Screen shot of Simplicite Advisor - Restaurants

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:

Screen shot of Simplicite Advisor - Comments

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:

Example of Node HTMLDiagram of Restaurant Nodes

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:

Diagram of POST flow example

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:

Code Example

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:

Screen shot of Watson Tone Analyzer Node

Like this:

Example of Watson Node added

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:

Screen shot of Code Example 2

Conclusion

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.

More How-tos stories
February 13, 2019

Simplify and Automate Deployments Using GitOps with IBM Multicloud Manager 3.1.2

Use Argo CD, a GitOps continuous delivery tool for Kubernetes, and IBM Multicloud Manager to achieve declarative and automated deployment of applications to multiple Kubernetes clusters.

Continue reading

February 11, 2019

Solving Business Problems with Splunk on IBM Cloud Kubernetes Service

In this tutorial, we will install Splunk Connect for Kubernetes into an existing Splunk instance. Splunk Connect for Kubernetes provides a way to import and search your Kubernetes logging, object, and metrics data in Splunk.

Continue reading

February 8, 2019

A How-To for Migrating Redis to IBM Cloud Databases for Redis

If you’re moving your data over to IBM Cloud Databases for Redis, you’ll need to take some steps to successfully migrate all of your data. We’ve got you covered. In this post, we’ll show you a quick way to start migrating your data across to Databases for Redis, whether your database is on-premise or in the cloud.

Continue reading