11

Product Reviews Analysis using Generative AI and No Code Tools

 8 months ago
source link: https://blogs.sap.com/2024/01/04/product-reviews-analysis-using-generative-ai-and-no-code-tools/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
January 4, 2024 7 minute read

Product Reviews Analysis using Generative AI and No Code Tools

Picture-1-1.jpg

Introduction:

In today’s digital age, customer reviews hold significant power in shaping buying decisions. For businesses striving to understand and improve customer experiences, harnessing the potential of AI becomes a game-changer. Sentiment Analysis is one area which can help businesses understand how customers perceive their products or services.

Based on this analysis, businesses can prioritize improvements, address issues, and make strategic decisions to enhance their offerings. Positive sentiments can be leveraged for marketing purposes, while negative sentiments can indicate areas needing improvement or damage control. At the same time, it helps users make an informed decision on which products they should buy.

There are many tools available today, that can help you build on this use case. However, the purpose of this blog is to showcase how this can be accomplished using No-Code tools and by leveraging SAP AI Core for Generative AI capabilities.

This ensures that citizen developers with no coding expertise or who can sometimes feel overwhelmed by the complexities of programming, are able to build applications within few hours.Also professional developers can quickly prototype with drag and drop ease and minimal configurations.

Today, I will take you through the process of creating a full stack application with SAP Build Apps and  Generative AI that helps perform sentiment analysis on product reviews.

Let’s quickly dive into the details.

Solution Architecture:

At its core, this app organizes products and their associated reviews, offering a comprehensive overview. It allows users to enter a product review and then categorizes it into positive, negative, or neutral review using Open AI’s ChatGPT to perform sentiment analysis.

The application consists of the following main parts:

  • SAP Build Apps – Web and Mobile application for the Frontend.
  • SAP Build Apps – Visual Cloud Functions for the Backend.
  • SAP AI Core.
pic23-1.png

Let’s get started – 

Prerequisites

  • You should have access to SAP Build Apps on your SAP BTP Subaccount.
  • Pre-created destinations for Northwind OData Service and AI Core in BTP.

First, we will create an application backend for the reviews.

pic25.png pic2-1.png pic26.png

Create an entity Reviews with the following fields.

pic5-1.png

Create a Visual Cloud Function to return the counts of positive , negative and neutral reviews for each product.

  1. In the Functions Tab, click on Create New. Set the name to reviewCount.
  2. Under configuration, select the Reviews Entity.
  3. Click on End execution (on the right), and then on Execution Finished.
  4. Under Output values, click Add value, and set the following:
    pic22.png
  5. Click Set formula and enter the following formula:

    GROUP(outputs["List records Reviews / Records listed"].records,item.productId,{productID:key,positive:COUNT(SELECT(items, item.sentiment == 3)), negative:COUNT(SELECT(items, item.sentiment == 1)), neutral: COUNT(SELECT(items, item.sentiment == 2))}) 
  6. Deploy the backend.

Please refer to this blog for more details on how to create Visual Cloud functions.

 Next, we create a web application project from the SAP Build Lobby.

pic25-1.png pic24.png pic27.png

Enable BTP Authentication.

  • Go to the “Auth” Tab in project.
  • Select SAP BTP Authentication.

Add integration for the Northwind OData Service.

  • Under the “Data” tab, click on “Add Integration”.
  • Select “BTP Destination”.
  • Search for the Northwind destination.
  • Configure and enable the “Products” entity and save.

Add Integration for AI Core.

  • Under the “Data” Tab, click on “Create Data Entity” under SAP Build Apps classic data entities.
  • Select BTP Destination Rest API Integration.
  • Set Data Entity Name – AICoreLLM.
  • Select BTP Destination name.
  • Set 2 additional Common Request Headers.
    pic13-1.png
  • Enable Create Mode.
  • Make following changes and save the entity.
    pic12-2.png

Add Integration for the Reviews backend.

  • Under the “Data” tab, click on “Add Integration”.
  • Select Cloud Functions.
  • Select Product Review Analysis Backend.(The project created in step 1).
  • Enable the Data Entity and save.

Now, let’s build the Products List.

  • Create a data variable for the products resource – Products1.
  • Create an app variable for the review counts – reviewCounts.
  • We will create a composite component for the product.
    Refer to this tutorial on how to create one. Instead of the star rating in the above tutorial, we will use counts for positive, negative and neutral reviews. Create properties positiveReviewCount, negativeReviewCount and neutralReviewcount for the component.
  • Bind the composite component to the products data.
    Field Binding
    Repeat with The data variable Products1
    Title label Data item in repeat: current.ProductName
    positiveReviewCount DEFAULT(FIND_BY_KEY(appVars.reviewCounts,”ProductID”, STRING(repeated.current.ProductID)).positive,0)
    negativeReviewcount DEFAULT(FIND_BY_KEY(appVars.reviewCounts,”ProductID”, STRING(repeated.current.ProductID)).negative,0)
    neutralReviewcount DEFAULT(FIND_BY_KEY(appVars.reviewCounts,”ProductID”, STRING(repeated.current.ProductID)).neutral,0)
    Image Source You can choose any image of your choice

    Products UI should look like this –

    pic14-2.png

Next, we build the Product Details Page.

  • Create a new page and name it – Product Details.
  • Under “Page Parameter”, add the following page parameters.
    Field Type Purpose
    productID Text The product to be displayed on the product page, received when the user clicks on a certain product in the list of products
  • Add Data Variable Reviews1 for the resource Reviews.
  • Add Data Variable Product1 for a single data record.
  • In the logic pane, create the below logic flow.
    pic15.png
  • Add Filtering and Sorting.
    pic18.png
    pic17-1.png
  • Add Navigation to this Page from the Products Page.
  • Add Container Product Details that will hold the details of the product such as name, quantity per unit, units in stock and unit price. Do the necessary bindings.
    Field Binding
    Title Data Variable
    Product1.ProductName
    Text1 Formula
    “Quantity Per Unit – “+data.Product1.QuantityPerUnit
    Text2 Formula
    “Units in Stock – “+data.Product1.UnitsInStock
    Text3 Formula
    “Price  – “+data.Product1.UnitPrice
  • Add “Add Review” button.
  • Add a container – Reviews Section to list all the reviews added so far for the product. Do the necessary bindings.
    Property Binding
    Primary label Data Item in Repeat
    Secondary Label Formula – ” – “+repeated.current.reviewedBy
    Arrow Visible False
    Text3 Formula – “Price  – “+data.Product1.UnitPrice
  • The page should look like this at this point.
    pic19.png

Now, the final page  – Add Review.

  • Create a new page and name it – Add Review.
  • Under “Page Variables”, add the following page variables:
    newReviewSentiment text Store the sentiment of the review given.
    newReview Text Contains the text the user enters as a new review
    AIPayload Object Request Payload for the AI Core API
  • Under “Page Parameter”, add productID parameter.
  • Add an input and button. Give the input a label – Add Review.
  • The page should look like this –
    pic20.png
  • Component Tap -> Set Page Variable -> Create Record -> Set Page Variable -> Create Record-> Navigate Back

    Open the logic pane and create the logic flow for the Submit button.

    pic21.png
  • Set the properties for each node as follows.
    Set Page Variable Variable name – AIPayload
    Assigned Value – Object with Properties
    max_tokens – 256
    top_p – 1
    temperature – 0
    model – gpt-35-turbo-16k
    n – 1
    stream – False
    messages – List of values
    [
    {
    role: "system",
    content: "You are a helpful assistant which does sentiment analysis."
    },
    {
    role: "assistant",
    content: "Return 3 for positive, 2 for neutral and 1 for negative."
    },{
    role: "user",
    content: pageVariable - newReview
    }
    ]
    Create Record Resource – AICoreLLM
    Record – Page variable – AIPayload
    Set Page Variable Variable Name – newReviewSentiment
    Assigned Value – Formula – outputs[“Save the AICore Response”].response.choices[0].message.content
    Create Record Resource – Reviews
    Reviews – Object with properties
    Review – Page Variable – newReview
    ProductID – Page Parameter – ProductID
    sentiment – Formula – NUMBER(pageVars.newReviewSentiment)
    ReviewedBy – your name
    DateCreated – Formula – NOW()

Voila! Your application is ready.
Watch the video to see how the application looks and works.

Conclusion:

Awesome, we were able to build a full stack application leveraging Gen AI capabilities in very less time. That’s the power of No-Code and Generative AI.

This use case is just an example of how easily one can integrate intelligence in our solutions and create value for customers. One can extend this app to further derive insights on top of the analysis done. For example, create charts / metrics to measure which product is the least or most bought/liked.

I would like to thank Gunter Albrecht , Jay Adnure  for helping and guiding me in my learning journey. Special thanks to Daniel Wroblewski for below blog posts which helped me understand SAP BUILD better –

With that, I come to the end of my very first blog.
Do let me know your thoughts in the comments section.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK