Get customer sentiment insights from product reviews

Get the code Try the app View the demo


Do you know what your customers really think about your product or service? Knowing this information is vital to your business and livelihood and lets you adapt your business as needed. This code pattern uses food reviews to explain how to easily extract insights from raw review data. It walks you through a working example of a web application that queries and manipulates data from Watson Discovery. And, with the aid of custom models using Watson Knowledge Studio (WKS), the data has additional enrichments that provide improved insights for user analysis.


Rather than relying on your own assumptions, how can you be sure what exactly your customers are saying about your business? The answer is in being able to analyze raw customer feedback in reviews, forums, and so on. Through the use of various UI components, the Node.js app in this code pattern demonstrates how to extract and visualize enriched data provided by the Watson Discovery engine. The data is further enhanced by a custom-built Watson Knowledge Studio model created specifically for handling food review type data. You can use the multiple UI components in this app as a starting point for developing your own Watson Discovery applications.

The main benefit of using Watson Discovery is its powerful engine that provides cognitive enrichments and insights into your data. The app in this code pattern provides examples of how to showcase these enrichments through the use of filters, lists, and graphs. The key enrichments are:

  • Entities – people, companies, organizations, cities, and more
  • Categories – classification of the data into a hierarchy of categories up to 5 levels deep
  • Concepts – identified general concepts that aren’t necessarily referenced in the data
  • Keywords – important topics typically used to index or search the data
  • Entity types – the classification of the discovered entities, such as person, location, or job title
  • Sentiment – the overall positive or negative sentiment of each document

With Watson Knowledge Studio, you can teach Watson about additional entities and relationships that go beyond its default entity extraction and enrichment process with a custom annotation model. Through the use of annotations, you can indicate entities and entity relationships on a small subset of documents, which can then be applied to a much larger set of similar documents. This model can then be applied to a Watson Discovery instance and incorporated into the Discovery enrichment process as documents are uploaded into the service.

When you have completed this code pattern, you should know how to:

  • Load and enrich data in Watson Discovery
  • Use Watson Knowledge Studio to create a custom annotation model
  • Deploy a WKS model to Watson Discovery
  • Query and manipulate data in Watson Discovery
  • Create UI components to represent enriched data created by Watson Discovery
  • Build a complete web app that uses JavaScript technologies to feature Watson Discovery data and enrichments



  1. Import the customer reviews into the Discovery collection.
  2. Load a sample set of review documents into WKS for annotation.
  3. Create a WKS model and train the model.
  4. Deploy the WKS model to a Watson Discovery instance.
  5. The user interacts with the back-end server through the app UI. The front-end app UI uses React to render search results and can reuse all of the views that the back end uses for server-side rendering. The front end uses semantic-ui-react components and is responsive.
  6. Process user input and route it to the back-end server, which is responsible for server-side rendering of the views to be displayed on the browser. The back-end server is written using Express and uses the express-react-views engine to render views written using React.
  7. The back-end server sends the user requests to Watson Discovery. It acts as a proxy server, forwarding queries from the front end to the Watson Discovery API while keeping sensitive API keys concealed from the user.


Find the detailed steps for this pattern in the README. The steps will show you how to:

  1. Clone the repo.
  2. Create Watson Discovery and Watson Knowledge Studio IBM Cloud services.
  3. Create a Watson Knowledge Studio workspace.
  4. Create a type system.
  5. Import training documents.
  6. Create the model.
  7. Deploy the machine learning model to Watson Discovery.
  8. Load the corpus documents to Watson Discovery.
  9. Configure credentials.
  10. Run the application.