Automating work based on Twitter data

Published April 20, 2018

This video is part of Pega Academy learning module: Utilizing text analytics to improve business performance.

Automating Work Based on Twitter Data

In this lesson you will learn how to automate work based on the output of text analysis.

Uplus is a major telecommunications company interested in improving customer engagement on social media. It wants to monitor relevant Twitter data and post appropriate responses where necessary. However, there are thousands of messages posted on Twitter every day, and it is not practical for customer service representatives to review all of them and respond.

Uplus can leverage text analytics to automate this work and maximize the value of their employees’ time. Only tweets with an overall sentiment detected as negative need to be forwarded to a customer service representative.

To implement this requirement, you need three things:

  • A Twitter Data Set to read Twitter data
  • A Text Analyzer to analyze text
  • A Data Flow to automatically create work items based on the output of the text analysis

Start by creating a Twitter Data Set.

The Type must be set to Twitter. The Apply to class must be Data-Social-Twitter.

A Twitter Data Set is a means to access live Twitter data. Provide the Access details, which you can obtain when you create your own Twitter app in

In the keywords section, specify the keywords to look for in the entire set of tweets. In this case look for @uplus.

You can also access tweets from only specific authors by adding their twitter handles in the timeline section.

Next, create a Text Analyzer to analyze the text data.

The Apply to must be in the same hierarchy as the Data-Social-Twitter class.

A Text Analyzer performs natural language processing on a piece of text. It then produces a structured output, which can be analyzed using reports. It performs three types of text analysis. Sentiment analysis, Classification and Entity extraction. Based on the output of each of these analyses, work can be automated. For the current requirement, only the Sentiment analysis is needed. Sentiment analysis detects the attitude of the author toward a particular subject.

To enable Sentiment analysis, you must configure a Lexicon and a Sentiment model. A lexicon is a manually defined set of words with the associated sentiment tagged. A sentiment model is developed by training the system using machine learning techniques to detect the sentiment. Typically, you create lexicons and sentiment models that are specific to the type of text. For example, some may work well with Twitter messages, while some may work better with email.

Now, configure the Input and Output properties for the Text Analyzer. In this case, the Text Analyzer reads the input text from a property called pyText and writes the output of text analysis to a property called NLPOutcome, both in the Data-Social-Twitter class.

Next, you need a Data Flow to feed the live Twitter data to the Text Analyzer.

The Apply to must be the same as the Twitter Data Set’s Apply to class.

Start by configuring the input data source to the Twitter Data Set created earlier.

Next, add the Text Analyzer created in the previous step.

Add a second destination to write the text analysis output into a report. This will allow Uplus to view the volume of all tweets in a report, not just negative ones.

Add a Filter shape to filter only the negative tweets.

Uplus wants to use the Overall Sentiment outcome to decide if a tweet is negative. Overall sentiment is available in the property pyOverallSentiment.

Configure one Destination shape to create a case when a negative tweet is detected.

A case is a work item assigned to a customer service representative. Add necessary mapping to pass on the text analysis information to the service representative.

Next, configure the other Destination shape to send the unfiltered output of the Text Analyzer into an activity that updates the reports.

Run the Data Flow to listen for live tweets.

When negative tweets are detected, a case is automatically created, which can be picked up by a customer service representative.

These are the cases created for negative tweets.

The service representative can then review the message and post a response.

The reports of the text analysis are available in the dashboard. For example, this is the volume per sentiment detected.

You have now reached the end of this lesson which explained how to automate work based on the output of text analysis.

100% found this useful