Product Reviews Analysis using Generative AI and No Code Tools
2024-1-4 18:38:34 Author: blogs.sap.com(查看原文) 阅读量:6 收藏

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.

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.

Create an entity Reviews with the following fields.

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

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.

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 –

Next, we build the Product Details Page.

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 –
  • 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.

  • Set the properties for each node as follows.
    Set Page Variable Variable name – AIPayload
    Assigned Value – Object with Properties
    [
    {
    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.


文章来源: https://blogs.sap.com/2024/01/04/product-reviews-analysis-using-generative-ai-and-no-code-tools/
如有侵权请联系:admin#unsafe.sh