This content has been archived and is no longer being maintained.

Table of Contents

Article

Analyzing the text-based content posted on Facebook in Pega 7.1.9

The Pega 7 Platform provides text analytics so that users can analyze text-based content such as news feeds, emails, and postings on social media streams including Facebook, Twitter, and YouTube. This tutorial explains how to use the Pega 7 Platform to analyze the text-based content of Facebook posts.

Facebook is now more than a social networking website that makes it easy for people to connect and share content. Companies use it as a media channel to have direct communication with customers who like particular Facebook pages. The goal is to have active fans spread the word about the company and build a strong brand. At the same time, it is also necessary to identify the unsatisfied customers and address their issues.

To help analyze Facebook posts by users, the Pega 7 Platform offers text analytics capability. Companies can analyze comments for particular Facebook pages to reveal significant community feedback, such as implicit knowledge about users (their intentions and sentiment) and the topics that users discuss. Such information can provide strategic insights and influence enterprise decisions.

This tutorial takes approximately 30-40 minutes to complete.

Prerequisites

  • Register on the Facebook Developers site and create a Facebook app. The app is necessary to obtain App ID and App secret details to use with the Facebook data set.
  • Add the PEGA-NLP ruleset to your application.
  • If you use IBM WebSphere Application Server or Oracle WebLogic Server to run the Pega 7 Platform, you need to configure the Signer and SSL Certificate settings. Without this configuration the Facebook data set does not work.

Creating an instance of the Facebook data set

Create and configure a Facebook data set called FacebookData to establish a connection with the Facebook API.

Do not use one instance of the Facebook data set in multiple data flows. If you stop one of the data flows, the Facebook data set in other data flows is also stopped.
  1. Click the Application menu in Designer Studio and switch to your application.
  2. In the App Explorer, click <app_name> > Data Model > Data Set.
  3. Right-click Facebook, and click Create.
  4. Name the data set FacebookData.
  5. From the Type list, select Facebook.
  6. Specify the context where you want to create the data set:
    • In the Apply to (class) field, select the Data-Social-Facebook class.
  7. Click Create and open.
  8. On the Facebook tab, complete the Access details section with the information from your Facebook app:
    • App ID
    • App secret
    • Facebook Page Token
  9. In the Facebook page URL's section, click Add URL and type a Facebook page URL for which you want to analyze posts.
  10. Optional: In the Authors section, click Add author and type the name of one or more users whose posts you want to ignore.
  11. Click Save.
When specifying numerous URLs and authors, take into consideration the Facebook Graph API limitations. For more information, read the documentation about the Facebook Graph API.

Creating an instance of the Free Text Model rule

Create a Free Text Model rule called SampleModel and configure it to analyze only sentiment in Facebook posts. For more information, see the Free Text Model rule.

  1. In the Records Explorer, click Decision > Free Text Model.
  2. Click Create.
  3. Name the rule SampleModel.
  4. Specify the context where you want to create the rule:
    • In the Apply to (class) field, select the Data-Social-Facebook class.
      You do not need to create the SampleModel rule in the same class as the FacebookData data set, but it needs to be in the Data-Social-Facebook class hierarchy. You can use the top level class or the base class.
  5. Click Create and open.
  6. Enable sentiment analysis:
    1. Select the Enable sentiment analysis check box.
    2. In the Lexicon field, select pySentimentLexicon.
    3. In the Sentiment model field, select pySentimentModels.
  7. Click the I/O Mapping tab.
  8. In the Input text field, set the .pyText property.
  9. In the Outcome field, set the .NLPOutcome property.

    Create the property if it does not exist. This property must be a single-page property defined on the Data-NLP-Outcome class.

  10. Click Save.

Creating an instance of the Data Flow rule

Create a data flow called NLPProcess to reference the SampleModel rule and to process the Facebook posts that are handled by the FacebookData data set.

You need to create the NLPProcess data flow in the same class as the FacebookData data set.
  1. In the Records Explorer, click Data Model > Data Flow.
  2. Click Create.
  3. Name the rule NLPProcess.
  4. Specify the context where you want to create the rule:
    • In the Apply to (class) field, select the Data-Social-Facebook class.
  5. Click Create and open.
  6. Double-click the Source shape.
    1. In the Source properties dialog box, from the Source list select Data set.
    2. From the Data set list, select FacebookData and click Submit.
  7. Navigate to the Source shape and click the green add icon.
  8. From the list, select Free Text Model.
  9. Double-click the Free Text Model shape.
    1. In the Free Text Model properties dialog box, in the Free Text Model field, reference the SampleModel rule.
    2. Click Submit.
  10. Navigate to the Free Text Model shape and click the green add icon.
  11. From the list, select Filter.
  12. Double-click the Filter shape.
    1. Name the shape Sentiment.
    2. In the Filter conditions section, specify the following condition: .NLPOutcome.pyOverallSentiment = "negative"

      The outcome property that you use in the filter condition must be the same as the one that you specified on the I/O Mapping tab of the SampleModel rule.
    3. Click Submit.
  13. Click the Destination shape.
    1. In the Destination properties dialog box, from the Destination list, select Activity.
    2. In the Activity field, reference the following activity: pxSaveSummaryForReporting.
    3. Click Submit.
  14. Click Save.

Analyzing the Facebook posts

Activate the NLPProcess data flow and keep it active until it processes some records (Facebook posts).

  1. Click the Application menu in Designer Studio and switch to your application.
  2. Open the NLPProcess data flow.
  3. Click Actions > Run.
  4. In the Data Flow Test Run dialog box, click Activate.
  5. Wait until the data flow processes some records.

You created the NLPProcess data flow, which uses the FacebookData data set and the SampleModel rule. The FacebookData data set allows you to filter Facebook posts according to the keywords that you specified in it. The SampleModel rule checks the overall sentiment of the Facebook posts. At the end, the posts with negative sentiment are saved in the pxSaveSummaryForReporting property You can use a report definition to retrieve information from this property.

Published July 3, 2015 — Updated September 6, 2017


0% found this useful

Related Content

Have a question? Get answers now.

Visit the Pega Support Community to ask questions, engage in discussions, and help others.