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.
- Prerequisites
- Creating an instance of the Facebook data set
- Creating an instance of the Free Text Sample rule
- Creating an instance of the Data Flow rule
- Analyzing the Facebook posts
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.
- Click the Application menu in Designer Studio and switch to your application.
- In the App Explorer, click <app_name> > Data Model > Data Set.
- Right-click Facebook, and click Create.
- Name the data set FacebookData.
- From the Type list, select Facebook.
- Specify the context where you want to create the data set:
- In the Apply to (class) field, select the Data-Social-Facebook class.
- Click Create and open.
- On the Facebook tab, complete the Access details section with the information from your Facebook app:
- App ID
- App secret
- Facebook Page Token
- In the Facebook page URL's section, click Add URL and type a Facebook page URL for which you want to analyze posts.
- Optional: In the Authors section, click Add author and type the name of one or more users whose posts you want to ignore.
- Click Save.
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.
- In the Records Explorer, click Decision > Free Text Model.
- Click Create.
- Name the rule SampleModel.
- Specify the context where you want to create the rule:
- In 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. field, select the
- In the Data-Social-Facebook class.
- Click .
- Enable sentiment analysis:
- Select the Enable sentiment analysis check box.
- In the pySentimentLexicon. field, select
- In the pySentimentModels. field, select
- Click the I/O Mapping tab.
- In the .pyText property. field, set the
In the .NLPOutcome property.
field, set theCreate the property if it does not exist. This property must be a single-page property defined on the Data-NLP-Outcome class.
Click
.
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.
- In the Records Explorer, click Data Model > Data Flow.
- Click Create.
- Name the rule NLPProcess.
- Specify the context where you want to create the rule:
- In the Data-Social-Facebook class. field, select the
- Click .
- Double-click the Source shape.
- In the Source properties dialog box, from the list select
- From the FacebookData and click Submit. list, select
- Navigate to the Source shape and click the green add icon.
- From the list, select Free Text Model.
- Double-click the Free Text Model shape.
- In the Free Text Model properties dialog box, in the field, reference the SampleModel rule.
- Click Submit.
- Navigate to the Free Text Model shape and click the green add icon.
- From the list, select Filter.
- Double-click the Filter shape.
- Name the shape Sentiment.
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.- Click Submit.
- Click the Destination shape.
- In the Destination properties dialog box, from the Destination list, select Activity.
- In the Activity field, reference the following activity: pxSaveSummaryForReporting.
- Click Submit.
- Click Save.
Analyzing the Facebook posts
Activate the NLPProcess data flow and keep it active until it processes some records (Facebook posts).
- Click the Application menu in Designer Studio and switch to your application.
- Open the NLPProcess data flow.
- Click Actions > Run.
- In the Data Flow Test Run dialog box, click Activate.
- 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.