Analyzing Your Company’s Social Media Presence With IBM Watson And Node.js

How can you gain a better understanding of your audience? Well, one way would be to use user-generated content that can be integrated into Machine Learning (ML) technology. In this article, Jamie Munro demonstrates how that can be done.

If you are unfamiliar with Machine Learning (ML) technology, it has existed in science fiction for many years and is finally reaching its maturity in our society. One of the first ML examples I saw as a kid was in Star Trek’s The Next Generation when Lieutenant Tasha Yar trains with her holographic opponent that learns how to fight and better defeat in future battles.

In today’s society, China has developed a “lane robot” that is a guard rail controlled by a computer system that can direct the flow of traffic into different lanes, increasing safety and improving traveling time. This is done automatically based on time of day and how much traffic is flowing in each direction.

Another example is Pittsburg unveiling AI traffic signals that automatically detect traffic patterns and alter the traffic lights on-the-fly. Each light is controlled independently to help reduce both the commuting time and the idling time of cars. According to the article, pilot tests have demonstrated a reduced travel time of 25% and idling time by over 40%. There are, of course, hundreds of other examples of ML technology that make intelligent decisions based on the content it consumes.

To accomplish today’s goal, I am going to demonstrate (using Node.js) how to perform a search with Twitter’s API to retrieve content that will be inputted into the ML algorithm to be analyzed. This way, you’ll be provided with characteristics about the users who wrote that specific content so that you can get a better understanding of your audience. The example application will be written using Node.js as the server.

It is beyond the scope of this article to demonstrate how to write an ML algorithm. Instead, to aid in the analysis, I will demonstrate how to use IBM’s Watson to help you understand the general personality of your social media audience.

1. What Is IBM Watson?

In 2011, Watson began as a computer system that attempted to index the (entire) Internet. It was originally programmed to answer questions posed in ordinary English. Watson competed and won on the TV show Jeopardy! claiming a $1,000,000 cash prize.

Watson was now a proven success.

With the fame of winning on Jeopardy!, IBM has continued to push Watson’s capabilities. Watson has evolved into an enterprise-level application that is focused on Artificial Intelligence (AI) which you can train to identify what you care about most allowing you to make smarter decisions automatically.

The suite of Watson’s services is divided into six high-level categories:

  1. Conversation
    The services in this category allow you to build intelligent chatbot’s or a virtual customer service agent.
  2. Knowledge
    This category is focused on teaching Watson how to interpret data to unlock hidden value and monitor trends.
  3. Vision
    This service provides the ability to tag content inside an image that is used to train Watson to be able to automatically recognize the same pattern inside of other images.
  4. Speech
    These services provide the ability to convert speech to text and the inverse, text to speech.
  5. Language
    This category is split between translating one language to another as well as interpreting the text to predict what predefined category the text belongs to.
  6. Empathy
    This category is devoted to understanding the content’s tone, personality, and emotional state. Inside this category is a service called “Personality Insights” that will be used in this article to predict the personality characteristics with the social media content we will provide it.

This article will be focusing on understanding the personality of the content that we will fetch from Twitter. However, as you can see, Watson provides many other AI features that you can explore to automate many other processes simply through training and content aggregation.

2. Personality Insights

Personality Insights will analyze content and help you understand the habits and preferences at an individual level and at scale. This is called the ‘personality profile.’ The profile is split into two high-level groups: Personality characteristics and Consumption preferences. These groups are further broken down into more finite components.

NoteTo help understand the high-level concepts (before we deep dive into the results), the Personality Insights documentation provides this helpful summary describing how the profile is inferred from the content you provide it.

IBM Watson’s Big Five Personality Traits
Big Five Personality Traits. Image courtesy: IBM.com.

2.1. Personality characteristics

The Personality Insights service infers personality characteristics based on three primary models:

  • The ‘Big Five’ personality characteristics represent the most widely used model for generally describing how a person engages with the world. The model includes five primary dimensions:
    • Agreeableness
    • Conscientiousness
    • Extraversion
    • Emotional range
    • Openness
      NoteEach dimension has six facets that further characterize an individual according to the dimension.
  • Needs describe which aspects of a product will resonate with a person. The model includes twelve characteristic needs:
    • Excitement
    • Harmony
    • Curiosity
    • Ideal
    • Closeness
    • Self-expression
    • Liberty
    • Love
    • Practicality
    • Stability
    • Challenge
    • Structure
  • Values describe motivating factors that influence a person’s decision making. The model includes five values:
    • Self-transcendence / Helping others
    • Conservation / Tradition
    • Hedonism / Taking pleasure in life
    • Self-enhancement / Achieving success
    • Open to change / Excitement

For more information, see Personality models.

2.2. Consumption preferences

Based on the personality characteristics inferred from the input text, the service can also return an indication of the author’s consumption preferences. ‘Consumption preferences’ indicate the author’s likelihood to pursue different products, services, and activities. The service groups the individual preferences into eight categories:

  • Shopping
  • Music
  • Movies
  • Reading and learning
  • Health and activity
  • Volunteering
  • Environmental concern
  • Entrepreneurship

Each category contains from one to as many as a dozen individual preferences.

NoteFor more information, see Consumption preferences. For a more in-depth overview of a particular point of interest, I suggest you refer to the Personality Insights documentation.

To be effective, Watson requires a minimum of a hundred words to provide an insight into the consumer’s personality. The more words provided, the better Watson can analyze and determine the consumer’s preference.

This means, if you wish to target individuals, you will need to collect more data than one or two tweets from a specific person. However, if a user writes a product review, blog post, email, or anything else related to your company, this could be analyzed on both an individual level and at scale.

To begin, let’s start by setting up the Personality Insights service to begin analyzing a real-world example.

3. Configuring The Personality Insights Service

Watson is an enterprise application but they offer a free, limited service. Once you’ve created an account and are logged in, you will need to add the Personality Insight service. IBM offers a Lite plan that is free. The Lite plan is limited to 1,000 API calls per month and is automatically deleted after 30 days — perfect for our demonstration.

Create the Personality Insights Service
Create the Personality Insights Service.

Once the service has been added, we will need to retrieve the service’s credentials to perform API calls against it. From Watson’s Dashboard, your service should be displayed. After you’ve selected the service, you’ll find a link to view the Service credentials in the left-hand menu. You will need to create a new ‘Credential.’ A unique name is required and optional configuration parameters can be defaulted for this login. For now, we will leave the configuration options empty.

After you have created a credential, select the ‘View’ credentials link. This will display the API’s URL, your username, and password required to securely execute API calls. Save these somewhere safe as we will need them in the next step.

4. Testing The Personality Insights Service

To perform API calls, I am going to use Node.js. If you already have Node.js installed, you can move on to the next step; otherwise, follow the instructions to setup Node.js from the official download page.

To demonstrate how to use the Personality Insights, I am going to create a new Node.js project on my computer. With a command prompt open, navigate to the directory where your Node.js projects will be stored and create your new project:

mkdir watson-sentiments
cd watson-sentiments
npm init

To assist with making the API calls to Watson, I am going to leverage the NPM Package: Watson Developer Cloud Node.js SDK. This package can be installed via the command prompt:

npm install watson-developer-cloud --save

Before making the first call, the PersonalityInsightsV3 object needs to be instantiated with the credentials from the previous section. Begin by creating a new file called index.js that will contain the Node.js code.

Here is an example of configuring the class so it is ready to make API calls:

var PersonalityInsightsV3 = require(’watson-developer-cloud/personality-insights/v3’);
var personality_insights = new PersonalityInsightsV3({
  "url": "https://gateway.watsonplatform.net/personality-insights/api",
  "username": "**************************",
  "password": "*************",
  "version_date": "2017-12-01"
});

The personality_insights variable is what we will use to interact with the API for the Personality Insights service. Let’s review how to execute a call and return a personality profile:

var fs = require(’fs’);

personality_insights.profile({
"contentItems": [
   {
         "content": "Some content that contains more than 100 words...",
         "contenttype": "text/plain",
         "created": 1447639154000,
         "id": "666073008692314113",
         "language": "en"
      }
   ],
   "consumption_preferences": true
}, (err, response) => {
if (err) throw err;

fs.writeFile("results.txt", JSON.stringify(response, null, 2), function(err) {
if (err) throw err;

console.log("Results were saved!");
});
  });

The profile function accepts an array of contentItems. The ‘content’ item contains the actual content with a few additional properties identifying additional information to help Watson interpret it.

When this is executed, the results are written to a text file (the results are too large to write in the console). The result is an object that contains the following high-level properties:

  • word_count
  • The count of words interpreted
  • processed_language

The language that the content provided, e.g. (en).

  • Personality
    This is an array of the ‘Big Five’ personality characteristics (Openness, Conscientiousness, Extraversion, Agreeableness, and Emotional range). Each characteristic contains an overall percentile for that characteristic (e.g. 0.8100175318417588). To ascertain more detail, there is an array called children that provides more in-depth insight. For example, a child category under ‘Openness’ is ‘Adventurousness’ that contains its own percentile.
  • Needs
    This is an array of the twelve characteristics that define the aspects a person will resonate with a product (Excitement, Harmony, Curiosity, Ideal, Closeness, Self-expression, Liberty, Love, Practicality, Stability, Challenge, and Structure). Each characteristic contains a percentile of how the content was interpreted.
  • Values
    This is an array of the five characteristics that describe motivating factors that influence a person’s decision making (Self-transcendence / Helping others, Conservation / Tradition, Hedonism / Taking pleasure in life, Self-enhancement / Achieving success, and Open to change / Excitement). Each characteristic contains a percentile of how the content was interpreted.
  • Behavior
    This is an array that contains thirty-one elements. Each element provides a percentile of when the content was created. Seven of the elements define the days of the week (Sunday through Saturday). The remaining twenty-four elements define the hours of the day. This helps you understand when customer’s interact with your product.
  • consumption_preferences
    This is an array that contains eight different categories with as much as a twelve child categories providing a percentile of likelihood to pursue different products, services, and activities (Shopping, Music, Movies, Reading and learning, Health and activity, Volunteering, Environmental concern, and Entrepreneurship).
  • Warnings
    This is an array that provides messages if a problem was encountered interpreting the content provided.

Here is a CodePen of the formatted results:

{
    "word_count": 15223,
    "processed_language": "en",
    "personality": [
        {
            "trait_id": "big5_openness",
            "name": "Openness",
            "category": "personality",
            "percentile": 0.8011555009552956,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_adventurousness",
                    "name": "Adventurousness",
                    "category": "personality",
                    "percentile": 0.8975586904731889,
                    "significant": true
                },
                {
                    "trait_id": "facet_artistic_interests",
                    "name": "Artistic interests",
                    "category": "personality",
                    "percentile": 0.9770309419531911,
                    "significant": true
                },
                {
                    "trait_id": "facet_emotionality",
                    "name": "Emotionality",
                    "category": "personality",
                    "percentile": 0.9947058875647474,
                    "significant": true
                },
                {
                    "trait_id": "facet_imagination",
                    "name": "Imagination",
                    "category": "personality",
                    "percentile": 0.8733065387317464,
                    "significant": true
                },
                {
                    "trait_id": "facet_intellect",
                    "name": "Intellect",
                    "category": "personality",
                    "percentile": 0.8717194796402018,
                    "significant": true
                },
                {
                    "trait_id": "facet_liberalism",
                    "name": "Authority-challenging",
                    "category": "personality",
                    "percentile": 0.6405414845731194,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_conscientiousness",
            "name": "Conscientiousness",
            "category": "personality",
            "percentile": 0.8100175318417588,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_achievement_striving",
                    "name": "Achievement striving",
                    "category": "personality",
                    "percentile": 0.8461329922662831,
                    "significant": true
                },
                {
                    "trait_id": "facet_cautiousness",
                    "name": "Cautiousness",
                    "category": "personality",
                    "percentile": 0.7220362727004178,
                    "significant": true
                },
                {
                    "trait_id": "facet_dutifulness",
                    "name": "Dutifulness",
                    "category": "personality",
                    "percentile": 0.8421638467925515,
                    "significant": true
                },
                {
                    "trait_id": "facet_orderliness",
                    "name": "Orderliness",
                    "category": "personality",
                    "percentile": 0.6121858586705231,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_discipline",
                    "name": "Self-discipline",
                    "category": "personality",
                    "percentile": 0.8317329416265953,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_efficacy",
                    "name": "Self-efficacy",
                    "category": "personality",
                    "percentile": 0.70883137095439,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_extraversion",
            "name": "Extraversion",
            "category": "personality",
            "percentile": 0.6498079607138185,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_activity_level",
                    "name": "Activity level",
                    "category": "personality",
                    "percentile": 0.8822058491396538,
                    "significant": true
                },
                {
                    "trait_id": "facet_assertiveness",
                    "name": "Assertiveness",
                    "category": "personality",
                    "percentile": 0.668984138017408,
                    "significant": true
                },
                {
                    "trait_id": "facet_cheerfulness",
                    "name": "Cheerfulness",
                    "category": "personality",
                    "percentile": 0.9435264775235841,
                    "significant": true
                },
                {
                    "trait_id": "facet_excitement_seeking",
                    "name": "Excitement-seeking",
                    "category": "personality",
                    "percentile": 0.5913387477205387,
                    "significant": true
                },
                {
                    "trait_id": "facet_friendliness",
                    "name": "Outgoing",
                    "category": "personality",
                    "percentile": 0.9577289025786391,
                    "significant": true
                },
                {
                    "trait_id": "facet_gregariousness",
                    "name": "Gregariousness",
                    "category": "personality",
                    "percentile": 0.6494284805198431,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_agreeableness",
            "name": "Agreeableness",
            "category": "personality",
            "percentile": 0.9478612479382063,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_altruism",
                    "name": "Altruism",
                    "category": "personality",
                    "percentile": 0.9924198382420473,
                    "significant": true
                },
                {
                    "trait_id": "facet_cooperation",
                    "name": "Cooperation",
                    "category": "personality",
                    "percentile": 0.8612307420897902,
                    "significant": true
                },
                {
                    "trait_id": "facet_modesty",
                    "name": "Modesty",
                    "category": "personality",
                    "percentile": 0.7726811931877515,
                    "significant": true
                },
                {
                    "trait_id": "facet_morality",
                    "name": "Uncompromising",
                    "category": "personality",
                    "percentile": 0.890791023357115,
                    "significant": true
                },
                {
                    "trait_id": "facet_sympathy",
                    "name": "Sympathy",
                    "category": "personality",
                    "percentile": 0.994218470874908,
                    "significant": true
                },
                {
                    "trait_id": "facet_trust",
                    "name": "Trust",
                    "category": "personality",
                    "percentile": 0.9036111955659848,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_neuroticism",
            "name": "Emotional range",
            "category": "personality",
            "percentile": 0.5008224041628007,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_anger",
                    "name": "Fiery",
                    "category": "personality",
                    "percentile": 0.17640022058508498,
                    "significant": true
                },
                {
                    "trait_id": "facet_anxiety",
                    "name": "Prone to worry",
                    "category": "personality",
                    "percentile": 0.42883076062186987,
                    "significant": true
                },
                {
                    "trait_id": "facet_depression",
                    "name": "Melancholy",
                    "category": "personality",
                    "percentile": 0.15019740428715633,
                    "significant": true
                },
                {
                    "trait_id": "facet_immoderation",
                    "name": "Immoderation",
                    "category": "personality",
                    "percentile": 0.26916719249302234,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_consciousness",
                    "name": "Self-consciousness",
                    "category": "personality",
                    "percentile": 0.30351543340675236,
                    "significant": true
                },
                {
                    "trait_id": "facet_vulnerability",
                    "name": "Susceptible to stress",
                    "category": "personality",
                    "percentile": 0.3897206832678008,
                    "significant": true
                }
            ]
        }
    ],
    "needs": [
        {
            "trait_id": "need_challenge",
            "name": "Challenge",
            "category": "needs",
            "percentile": 0.673623320545115,
            "significant": true
        },
        {
            "trait_id": "need_closeness",
            "name": "Closeness",
            "category": "needs",
            "percentile": 0.8380283404181322,
            "significant": true
        },
        {
            "trait_id": "need_curiosity",
            "name": "Curiosity",
            "category": "needs",
            "percentile": 0.9293839318960936,
            "significant": true
        },
        {
            "trait_id": "need_excitement",
            "name": "Excitement",
            "category": "needs",
            "percentile": 0.7280972568828032,
            "significant": true
        },
        {
            "trait_id": "need_harmony",
            "name": "Harmony",
            "category": "needs",
            "percentile": 0.9694112904157444,
            "significant": true
        },
        {
            "trait_id": "need_ideal",
            "name": "Ideal",
            "category": "needs",
            "percentile": 0.6824330657640135,
            "significant": true
        },
        {
            "trait_id": "need_liberty",
            "name": "Liberty",
            "category": "needs",
            "percentile": 0.786964400223518,
            "significant": true
        },
        {
            "trait_id": "need_love",
            "name": "Love",
            "category": "needs",
            "percentile": 0.8207992048058734,
            "significant": true
        },
        {
            "trait_id": "need_practicality",
            "name": "Practicality",
            "category": "needs",
            "percentile": 0.3503620508268639,
            "significant": true
        },
        {
            "trait_id": "need_self_expression",
            "name": "Self-expression",
            "category": "needs",
            "percentile": 0.8673284357850473,
            "significant": true
        },
        {
            "trait_id": "need_stability",
            "name": "Stability",
            "category": "needs",
            "percentile": 0.8732565885512285,
            "significant": true
        },
        {
            "trait_id": "need_structure",
            "name": "Structure",
            "category": "needs",
            "percentile": 0.7456082872690646,
            "significant": true
        }
    ],
    "values": [
        {
            "trait_id": "value_conservation",
            "name": "Conservation",
            "category": "values",
            "percentile": 0.8926822285613875,
            "significant": true
        },
        {
            "trait_id": "value_openness_to_change",
            "name": "Openness to change",
            "category": "values",
            "percentile": 0.8575991638808613,
            "significant": true
        },
        {
            "trait_id": "value_hedonism",
            "name": "Hedonism",
            "category": "values",
            "percentile": 0.44128086884054324,
            "significant": true
        },
        {
            "trait_id": "value_self_enhancement",
            "name": "Self-enhancement",
            "category": "values",
            "percentile": 0.6458578881392593,
            "significant": true
        },
        {
            "trait_id": "value_self_transcendence",
            "name": "Self-transcendence",
            "category": "values",
            "percentile": 0.8237769534534466,
            "significant": true
        }
    ],
    "behavior": [
        {
            "trait_id": "behavior_sunday",
            "name": "Sunday",
            "category": "behavior",
            "percentage": 0.21392532795156408
        },
        {
            "trait_id": "behavior_monday",
            "name": "Monday",
            "category": "behavior",
            "percentage": 0.425832492431887
        },
        {
            "trait_id": "behavior_tuesday",
            "name": "Tuesday",
            "category": "behavior",
            "percentage": 0.07164480322906155
        },
        {
            "trait_id": "behavior_wednesday",
            "name": "Wednesday",
            "category": "behavior",
            "percentage": 0.011099899091826439
        },
        {
            "trait_id": "behavior_thursday",
            "name": "Thursday",
            "category": "behavior",
            "percentage": 0.12209889001009082
        },
        {
            "trait_id": "behavior_friday",
            "name": "Friday",
            "category": "behavior",
            "percentage": 0.07769929364278506
        },
        {
            "trait_id": "behavior_saturday",
            "name": "Saturday",
            "category": "behavior",
            "percentage": 0.07769929364278506
        },
        {
            "trait_id": "behavior_0000",
            "name": "0:00 am",
            "category": "behavior",
            "percentage": 0.45610494450050454
        },
        {
            "trait_id": "behavior_0100",
            "name": "1:00 am",
            "category": "behavior",
            "percentage": 0.12209889001009082
        },
        {
            "trait_id": "behavior_0200",
            "name": "2:00 am",
            "category": "behavior",
            "percentage": 0.02119071644803229
        },
        {
            "trait_id": "behavior_0300",
            "name": "3:00 am",
            "category": "behavior",
            "percentage": 0.09485368314833502
        },
        {
            "trait_id": "behavior_0400",
            "name": "4:00 am",
            "category": "behavior",
            "percentage": 0.020181634712411706
        },
        {
            "trait_id": "behavior_0500",
            "name": "5:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0600",
            "name": "6:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0700",
            "name": "7:00 am",
            "category": "behavior",
            "percentage": 0.011099899091826439
        },
        {
            "trait_id": "behavior_0800",
            "name": "8:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0900",
            "name": "9:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1000",
            "name": "10:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1100",
            "name": "11:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1200",
            "name": "12:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1300",
            "name": "1:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1400",
            "name": "2:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1500",
            "name": "3:00 pm",
            "category": "behavior",
            "percentage": 0.022199798183652877
        },
        {
            "trait_id": "behavior_1600",
            "name": "4:00 pm",
            "category": "behavior",
            "percentage": 0.022199798183652877
        },
        {
            "trait_id": "behavior_1700",
            "name": "5:00 pm",
            "category": "behavior",
            "percentage": 0.03229061553985873
        },
        {
            "trait_id": "behavior_1800",
            "name": "6:00 pm",
            "category": "behavior",
            "percentage": 0.010090817356205853
        },
        {
            "trait_id": "behavior_1900",
            "name": "7:00 pm",
            "category": "behavior",
            "percentage": 0.011099899091826439
        },
        {
            "trait_id": "behavior_2000",
            "name": "8:00 pm",
            "category": "behavior",
            "percentage": 0.022199798183652877
        },
        {
            "trait_id": "behavior_2100",
            "name": "9:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_2200",
            "name": "10:00 pm",
            "category": "behavior",
            "percentage": 0.03128153380423814
        },
        {
            "trait_id": "behavior_2300",
            "name": "11:00 pm",
            "category": "behavior",
            "percentage": 0.1231079717457114
        }
    ],
    "consumption_preferences": [
        {
            "consumption_preference_category_id": "consumption_preferences_shopping",
            "name": "Purchasing Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_automobile_ownership_cost",
                    "name": "Likely to be sensitive to ownership cost when buying automobiles",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_automobile_safety",
                    "name": "Likely to prefer safety when buying automobiles",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_quality",
                    "name": "Likely to prefer quality when buying clothes",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_style",
                    "name": "Likely to prefer style when buying clothes",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_comfort",
                    "name": "Likely to prefer comfort when buying clothes",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_brand_name",
                    "name": "Likely to be influenced by brand name when making product purchases",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_utility",
                    "name": "Likely to be influenced by product utility when making product purchases",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_online_ads",
                    "name": "Likely to be influenced by online ads when making product purchases",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_social_media",
                    "name": "Likely to be influenced by social media when making product purchases",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_family_members",
                    "name": "Likely to be influenced by family when making product purchases",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_spur_of_moment",
                    "name": "Likely to indulge in spur of the moment purchases",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_credit_card_payment",
                    "name": "Likely to prefer using credit cards for shopping",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_health_and_activity",
            "name": "Health & Activity Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_eat_out",
                    "name": "Likely to eat out frequently",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_gym_membership",
                    "name": "Likely to have a gym membership",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_outdoor",
                    "name": "Likely to like outdoor activities",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_environmental_concern",
            "name": "Environmental Concern Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_concerned_environment",
                    "name": "Likely to be concerned about the environment",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_entrepreneurship",
            "name": "Entrepreneurship Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_start_business",
                    "name": "Likely to consider starting a business in next few years",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_movie",
            "name": "Movie Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_movie_romance",
                    "name": "Likely to like romance movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_adventure",
                    "name": "Likely to like adventure movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_horror",
                    "name": "Likely to like horror movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_musical",
                    "name": "Likely to like musical movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_historical",
                    "name": "Likely to like historical movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_science_fiction",
                    "name": "Likely to like science-fiction movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_war",
                    "name": "Likely to like war movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_drama",
                    "name": "Likely to like drama movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_action",
                    "name": "Likely to like action movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_documentary",
                    "name": "Likely to like documentary movies",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_music",
            "name": "Music Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_music_rap",
                    "name": "Likely to like rap music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_country",
                    "name": "Likely to like country music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_r_b",
                    "name": "Likely to like R&B music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_hip_hop",
                    "name": "Likely to like hip hop music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_live_event",
                    "name": "Likely to attend live musical events",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_playing",
                    "name": "Likely to have experience playing music",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_latin",
                    "name": "Likely to like Latin music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_rock",
                    "name": "Likely to like rock music",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_classical",
                    "name": "Likely to like classical music",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_reading",
            "name": "Reading Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_read_frequency",
                    "name": "Likely to read often",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_entertainment_magazines",
                    "name": "Likely to read entertainment magazines",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_non_fiction",
                    "name": "Likely to read non-fiction books",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_financial_investing",
                    "name": "Likely to read financial investment books",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_autobiographies",
                    "name": "Likely to read autobiographical books",
                    "score": 0
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_volunteering",
            "name": "Volunteering Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_volunteer",
                    "name": "Likely to volunteer for social causes",
                    "score": 0
                }
            ]
        }
    ],
    "warnings": []
}

5. Configuring Twitter

To search Twitter for relevant tweets, I am going to use the Twitter NPM package. From a console window where the application is hosted, run the following command to install:

npm install twitter --save

Before we can implement the Twitter package, you need to create a Twitter application.

Retrieving Twitter’s Access Tokens
Retrieving Twitter’s Access Tokens.

Once you’ve created your application, you need to retrieve the authorization keys required to perform API calls. With your application created, navigate to the ‘Keys’ and ‘Access Tokens’ page. Since we are not performing API calls against users of Twitter, OAuth integration is not required. Instead, we need only the four following keys:

  1. Consumer Key
  2. Consumer Secret
  3. Access Token
  4. Access Token Secret

The last two keys need to be generated near the bottom of the ‘Keys’ and ‘Access Tokens’ page. With the keys, here is an example of searching for Tweets about #SmashingMagazine:

var Twitter = require(’twitter’);

var client = new Twitter({
  consumer_key: ’*********************’,
  consumer_secret: ’******************’,
  access_token_key: ’******************’,
  access_token_secret: ’****************’
});

client.get(’search/tweets’, { q: ’#SmashingMagazine’ }, function(error, tweets, response) {
if(error) throw error;

console.log(tweets);
});

The result of this code will log a list tweets about Smashing Magazine. For the purposes of this demonstration, the following fields are of interest to us:

  1. id
  2. created_at
  3. text
  4. metadata.iso_language_code

These are the fields we will feed Watson.

6. Integrating Personality Insights With Twitter

With Twitter setup and Watson setup, it’s time to integrate the two together and see the results. To make it interesting, let’s search for #DonaldTrump to see what the world thinks about the President of the United States. Here is the code example to search Twitter, feed the results into Watson, and write the results to a text file:

var fs = require(’fs’);
var Twitter = require(’twitter’);

var client = new Twitter({
  consumer_key: ’*********************’,
  consumer_secret: ’******************’,
  access_token_key: ’******************’,
  access_token_secret: ’****************’
});

var PersonalityInsightsV3 = require(’watson-developer-cloud/personality-insights/v3’);
var personality_insights = new PersonalityInsightsV3({
  "url": "https://gateway.watsonplatform.net/personality-insights/api",
  "username": "**************************",
  "password": "*************",
  "version_date": "2017-12-01"
});

client.get(’search/tweets’, { q: ’#DonaldTrump’ }, function(error, tweets, response) {
if(error) throw error;

var contentItems = [];

// Loop through the tweets
for (var i = 0; i < tweets.statuses.length; i++) {
var tweet = tweets.statuses[i];

contentItems.push({
"content": tweet.text,
"contenttype": "text/plain",
"created": new Date(tweet.created_at).getTime(),
"id": tweet.id,
"language": tweet.metadata.iso_language_code
});
}

// Call Watson with the tweets
personality_insights.profile({
"contentItems": contentItems,
"consumption_preferences": true
}, (err, response) => {
if (err) throw err;

// Write the results to a file
fs.writeFile("results.txt", JSON.stringify(response, null, 2), function(err) {
if (err) throw err;

console.log("Results were saved!");
});
});
});

Here is another CodePen of the formatted results that I received:

{
    "word_count": 142,
    "word_count_message": "There were 142 words in the input. We need a minimum of 600, preferably 1,200 or more, to compute statistically significant estimates",
    "processed_language": "en",
    "personality": [
        {
            "trait_id": "big5_openness",
            "name": "Openness",
            "category": "personality",
            "percentile": 0.8854504117949564,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_adventurousness",
                    "name": "Adventurousness",
                    "category": "personality",
                    "percentile": 0.7268938229208839,
                    "significant": true
                },
                {
                    "trait_id": "facet_artistic_interests",
                    "name": "Artistic interests",
                    "category": "personality",
                    "percentile": 0.5766453823437663,
                    "significant": true
                },
                {
                    "trait_id": "facet_emotionality",
                    "name": "Emotionality",
                    "category": "personality",
                    "percentile": 0.13261654703982378,
                    "significant": true
                },
                {
                    "trait_id": "facet_imagination",
                    "name": "Imagination",
                    "category": "personality",
                    "percentile": 0.5457710981884943,
                    "significant": true
                },
                {
                    "trait_id": "facet_intellect",
                    "name": "Intellect",
                    "category": "personality",
                    "percentile": 0.9641811017664994,
                    "significant": true
                },
                {
                    "trait_id": "facet_liberalism",
                    "name": "Authority-challenging",
                    "category": "personality",
                    "percentile": 0.8753982686279054,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_conscientiousness",
            "name": "Conscientiousness",
            "category": "personality",
            "percentile": 0.4647800070433501,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_achievement_striving",
                    "name": "Achievement striving",
                    "category": "personality",
                    "percentile": 0.3168685138821112,
                    "significant": true
                },
                {
                    "trait_id": "facet_cautiousness",
                    "name": "Cautiousness",
                    "category": "personality",
                    "percentile": 0.5863966552808644,
                    "significant": true
                },
                {
                    "trait_id": "facet_dutifulness",
                    "name": "Dutifulness",
                    "category": "personality",
                    "percentile": 0.31971323152073516,
                    "significant": true
                },
                {
                    "trait_id": "facet_orderliness",
                    "name": "Orderliness",
                    "category": "personality",
                    "percentile": 0.5993159609236419,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_discipline",
                    "name": "Self-discipline",
                    "category": "personality",
                    "percentile": 0.2627635421488171,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_efficacy",
                    "name": "Self-efficacy",
                    "category": "personality",
                    "percentile": 0.28008374912222544,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_extraversion",
            "name": "Extraversion",
            "category": "personality",
            "percentile": 0.33896522060709056,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_activity_level",
                    "name": "Activity level",
                    "category": "personality",
                    "percentile": 0.10321447572805076,
                    "significant": true
                },
                {
                    "trait_id": "facet_assertiveness",
                    "name": "Assertiveness",
                    "category": "personality",
                    "percentile": 0.7802908923799108,
                    "significant": true
                },
                {
                    "trait_id": "facet_cheerfulness",
                    "name": "Cheerfulness",
                    "category": "personality",
                    "percentile": 0.01906044499066617,
                    "significant": true
                },
                {
                    "trait_id": "facet_excitement_seeking",
                    "name": "Excitement-seeking",
                    "category": "personality",
                    "percentile": 0.16630302455342577,
                    "significant": true
                },
                {
                    "trait_id": "facet_friendliness",
                    "name": "Outgoing",
                    "category": "personality",
                    "percentile": 0.16428234939947628,
                    "significant": true
                },
                {
                    "trait_id": "facet_gregariousness",
                    "name": "Gregariousness",
                    "category": "personality",
                    "percentile": 0.04297817092093492,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_agreeableness",
            "name": "Agreeableness",
            "category": "personality",
            "percentile": 0.2589070892092963,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_altruism",
                    "name": "Altruism",
                    "category": "personality",
                    "percentile": 0.38532516918194704,
                    "significant": true
                },
                {
                    "trait_id": "facet_cooperation",
                    "name": "Cooperation",
                    "category": "personality",
                    "percentile": 0.1447649718619583,
                    "significant": true
                },
                {
                    "trait_id": "facet_modesty",
                    "name": "Modesty",
                    "category": "personality",
                    "percentile": 0.14995931522856626,
                    "significant": true
                },
                {
                    "trait_id": "facet_morality",
                    "name": "Uncompromising",
                    "category": "personality",
                    "percentile": 0.240919493300837,
                    "significant": true
                },
                {
                    "trait_id": "facet_sympathy",
                    "name": "Sympathy",
                    "category": "personality",
                    "percentile": 0.8996901720928411,
                    "significant": true
                },
                {
                    "trait_id": "facet_trust",
                    "name": "Trust",
                    "category": "personality",
                    "percentile": 0.1732321227276532,
                    "significant": true
                }
            ]
        },
        {
            "trait_id": "big5_neuroticism",
            "name": "Emotional range",
            "category": "personality",
            "percentile": 0.8605689772440881,
            "significant": true,
            "children": [
                {
                    "trait_id": "facet_anger",
                    "name": "Fiery",
                    "category": "personality",
                    "percentile": 0.6055967452890959,
                    "significant": true
                },
                {
                    "trait_id": "facet_anxiety",
                    "name": "Prone to worry",
                    "category": "personality",
                    "percentile": 0.3678978461551372,
                    "significant": true
                },
                {
                    "trait_id": "facet_depression",
                    "name": "Melancholy",
                    "category": "personality",
                    "percentile": 0.42362904215876707,
                    "significant": true
                },
                {
                    "trait_id": "facet_immoderation",
                    "name": "Immoderation",
                    "category": "personality",
                    "percentile": 0.369296268662322,
                    "significant": true
                },
                {
                    "trait_id": "facet_self_consciousness",
                    "name": "Self-consciousness",
                    "category": "personality",
                    "percentile": 0.6169982834106567,
                    "significant": true
                },
                {
                    "trait_id": "facet_vulnerability",
                    "name": "Susceptible to stress",
                    "category": "personality",
                    "percentile": 0.16408600232145337,
                    "significant": true
                }
            ]
        }
    ],
    "needs": [
        {
            "trait_id": "need_challenge",
            "name": "Challenge",
            "category": "needs",
            "percentile": 0.2923880265615786,
            "significant": true
        },
        {
            "trait_id": "need_closeness",
            "name": "Closeness",
            "category": "needs",
            "percentile": 0.038534874980203415,
            "significant": true
        },
        {
            "trait_id": "need_curiosity",
            "name": "Curiosity",
            "category": "needs",
            "percentile": 0.6399178901200104,
            "significant": true
        },
        {
            "trait_id": "need_excitement",
            "name": "Excitement",
            "category": "needs",
            "percentile": 0.01734449277650174,
            "significant": true
        },
        {
            "trait_id": "need_harmony",
            "name": "Harmony",
            "category": "needs",
            "percentile": 0.06023236915237379,
            "significant": true
        },
        {
            "trait_id": "need_ideal",
            "name": "Ideal",
            "category": "needs",
            "percentile": 0.060793084947590226,
            "significant": true
        },
        {
            "trait_id": "need_liberty",
            "name": "Liberty",
            "category": "needs",
            "percentile": 0.06415445782160317,
            "significant": true
        },
        {
            "trait_id": "need_love",
            "name": "Love",
            "category": "needs",
            "percentile": 0.0239459517218627,
            "significant": true
        },
        {
            "trait_id": "need_practicality",
            "name": "Practicality",
            "category": "needs",
            "percentile": 0.19642431663642645,
            "significant": true
        },
        {
            "trait_id": "need_self_expression",
            "name": "Self-expression",
            "category": "needs",
            "percentile": 0.06463679311304288,
            "significant": true
        },
        {
            "trait_id": "need_stability",
            "name": "Stability",
            "category": "needs",
            "percentile": 0.39032017738874963,
            "significant": true
        },
        {
            "trait_id": "need_structure",
            "name": "Structure",
            "category": "needs",
            "percentile": 0.6902619224109275,
            "significant": true
        }
    ],
    "values": [
        {
            "trait_id": "value_conservation",
            "name": "Conservation",
            "category": "values",
            "percentile": 0.2131265586802032,
            "significant": true
        },
        {
            "trait_id": "value_openness_to_change",
            "name": "Openness to change",
            "category": "values",
            "percentile": 0.06790770320378892,
            "significant": true
        },
        {
            "trait_id": "value_hedonism",
            "name": "Hedonism",
            "category": "values",
            "percentile": 0.2371816947653394,
            "significant": true
        },
        {
            "trait_id": "value_self_enhancement",
            "name": "Self-enhancement",
            "category": "values",
            "percentile": 0.0410634363720187,
            "significant": true
        },
        {
            "trait_id": "value_self_transcendence",
            "name": "Self-transcendence",
            "category": "values",
            "percentile": 0.13306331589188464,
            "significant": true
        }
    ],
    "behavior": [
        {
            "trait_id": "behavior_sunday",
            "name": "Sunday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_monday",
            "name": "Monday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_tuesday",
            "name": "Tuesday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_wednesday",
            "name": "Wednesday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_thursday",
            "name": "Thursday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_friday",
            "name": "Friday",
            "category": "behavior",
            "percentage": 1
        },
        {
            "trait_id": "behavior_saturday",
            "name": "Saturday",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0000",
            "name": "0:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0100",
            "name": "1:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0200",
            "name": "2:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0300",
            "name": "3:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0400",
            "name": "4:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0500",
            "name": "5:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0600",
            "name": "6:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0700",
            "name": "7:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0800",
            "name": "8:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_0900",
            "name": "9:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1000",
            "name": "10:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1100",
            "name": "11:00 am",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1200",
            "name": "12:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1300",
            "name": "1:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1400",
            "name": "2:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1500",
            "name": "3:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1600",
            "name": "4:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1700",
            "name": "5:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_1800",
            "name": "6:00 pm",
            "category": "behavior",
            "percentage": 1
        },
        {
            "trait_id": "behavior_1900",
            "name": "7:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_2000",
            "name": "8:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_2100",
            "name": "9:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_2200",
            "name": "10:00 pm",
            "category": "behavior",
            "percentage": 0
        },
        {
            "trait_id": "behavior_2300",
            "name": "11:00 pm",
            "category": "behavior",
            "percentage": 0
        }
    ],
    "consumption_preferences": [
        {
            "consumption_preference_category_id": "consumption_preferences_shopping",
            "name": "Purchasing Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_automobile_ownership_cost",
                    "name": "Likely to be sensitive to ownership cost when buying automobiles",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_automobile_safety",
                    "name": "Likely to prefer safety when buying automobiles",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_quality",
                    "name": "Likely to prefer quality when buying clothes",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_style",
                    "name": "Likely to prefer style when buying clothes",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_clothes_comfort",
                    "name": "Likely to prefer comfort when buying clothes",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_brand_name",
                    "name": "Likely to be influenced by brand name when making product purchases",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_utility",
                    "name": "Likely to be influenced by product utility when making product purchases",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_online_ads",
                    "name": "Likely to be influenced by online ads when making product purchases",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_social_media",
                    "name": "Likely to be influenced by social media when making product purchases",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_influence_family_members",
                    "name": "Likely to be influenced by family when making product purchases",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_spur_of_moment",
                    "name": "Likely to indulge in spur of the moment purchases",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_credit_card_payment",
                    "name": "Likely to prefer using credit cards for shopping",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_health_and_activity",
            "name": "Health & Activity Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_eat_out",
                    "name": "Likely to eat out frequently",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_gym_membership",
                    "name": "Likely to have a gym membership",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_outdoor",
                    "name": "Likely to like outdoor activities",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_environmental_concern",
            "name": "Environmental Concern Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_concerned_environment",
                    "name": "Likely to be concerned about the environment",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_entrepreneurship",
            "name": "Entrepreneurship Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_start_business",
                    "name": "Likely to consider starting a business in next few years",
                    "score": 0.5
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_movie",
            "name": "Movie Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_movie_romance",
                    "name": "Likely to like romance movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_adventure",
                    "name": "Likely to like adventure movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_horror",
                    "name": "Likely to like horror movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_musical",
                    "name": "Likely to like musical movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_historical",
                    "name": "Likely to like historical movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_science_fiction",
                    "name": "Likely to like science-fiction movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_war",
                    "name": "Likely to like war movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_drama",
                    "name": "Likely to like drama movies",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_action",
                    "name": "Likely to like action movies",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_movie_documentary",
                    "name": "Likely to like documentary movies",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_music",
            "name": "Music Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_music_rap",
                    "name": "Likely to like rap music",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_country",
                    "name": "Likely to like country music",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_r_b",
                    "name": "Likely to like R&B music",
                    "score": 0.5
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_hip_hop",
                    "name": "Likely to like hip hop music",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_live_event",
                    "name": "Likely to attend live musical events",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_playing",
                    "name": "Likely to have experience playing music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_latin",
                    "name": "Likely to like Latin music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_rock",
                    "name": "Likely to like rock music",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_music_classical",
                    "name": "Likely to like classical music",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_reading",
            "name": "Reading Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_read_frequency",
                    "name": "Likely to read often",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_entertainment_magazines",
                    "name": "Likely to read entertainment magazines",
                    "score": 0
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_non_fiction",
                    "name": "Likely to read non-fiction books",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_financial_investing",
                    "name": "Likely to read financial investment books",
                    "score": 1
                },
                {
                    "consumption_preference_id": "consumption_preferences_books_autobiographies",
                    "name": "Likely to read autobiographical books",
                    "score": 1
                }
            ]
        },
        {
            "consumption_preference_category_id": "consumption_preferences_volunteering",
            "name": "Volunteering Preferences",
            "consumption_preferences": [
                {
                    "consumption_preference_id": "consumption_preferences_volunteer",
                    "name": "Likely to volunteer for social causes",
                    "score": 1
                }
            ]
        }
    ],
    "warnings": [
        {
            "warning_id": "WORD_COUNT_MESSAGE",
            "message": "There were 142 words in the input. We need a minimum of 600, preferably 1,200 or more, to compute statistically significant estimates"
        }
    ]
}

7. What Do The Results Say?

Once we’ve analyzed the ‘Openness’ trait of the ‘Big Five,’ we can infer the following:

  • Emotion is quite low at 13%
  • Imagination is average at 54%
  • Intellect is very high at 96%
  • Authority challenging is also quite high at 87%

The ‘Conscientiousness’ trait at a high-level is average at 46% compared with the ‘Openness’ high-level average of 88%. Whereas ‘Agreeableness’ is very low at only 25%. I guess people on Twitter don’t like to agree with Donald Trump.

Moving on to the ‘Needs.’ The sub-categories of ‘Curiosity’ and ‘Structure’ are in the 60 percentile compared to other categories being below the 10th percentile (Excitement, Harmony, etc.).

And finally, under ‘Values,’ the sub-category that stands out to me as interesting is the ‘Openness’ to ‘Change’ at an abysmal 6%.

Based on when you perform your search, your results may vary as the results are limited to the past seven days from executing the example.

From these results, I would determine that the average person who tweets about Donald Trump is quite intellectual, challenges authority, and is not open to change.

With these results, it would allow you to automatically alter how you would target your content towards your audience to match the results received. You will need to determine what categories are of interest and what percentiles do you wish to target. With this ammunition, you can begin automating.

8. What Else Can I Do With Watson?

As I mentioned at the beginning of this article, Watson offers many other different services. With these services, you could automate many different parts of common business processes. For example:

  • Building a chat bot that can intelligently answer questions based on a knowledge base of information;
  • Build an application where you dictate what you want written to Watson by using the speech to text functionality;
  • Automatically translate your content into different languages to create a multi-lingual site or knowledge base;
  • Teach Watson how to look for specific patterns in images. This could be used to determine if a logo is embedded into a photo.

This, of course, is a very small subset that my limited imagination can postulate. I’m sure you can think of many other ways to leverage Watson’s immense capabilities.

If you are looking for more examples, IBM has an entire GitHub repository dedicated to their Node.js SDK. The example folder contains over ten sample applications that convert speech to text, text to speech, tone analysis, and visual recognition to name just a few.

9. Conclusion

Before Watson can runaway with technological growth, resulting in the singularity where Artificial Intelligence destroys mankind, this article demonstrated how you can turn social media content into a powerful understanding of how the people creating the content think. Using the results from Watson, your application can use the categories of interest where the percentile exceeds or is less than a predetermined amount to change how you target your audience.

If you have other interesting uses of Watson or how you are using the Personality Insights, be sure to leave a comment below.

Related posts:

Getting Started with JIMP image processing
Building A Real-Time Retrospective Board With Video Chat
MySQL with Node.js
How to use Streams in Node.js
How To Build and Test a Node.js REST API with Express on Ubuntu 18.04
An Introduction To Node.js And MongoDB
Getting Started with Google Drive Node.js API
Getting Started with Fastify Node.js Framework and Faunadb
Better Error Handling In NodeJS With Error Classes
Web Scraping With Node.js
Keeping Node.js Fast: Tools, Techniques, And Tips For Making High-Performance Node.js Servers
How to use CORS in Node.js with Express
Developing A Chatbot Using Microsoft’s Bot Framework, LUIS And Node.js
Uploading Images to Cloudinary using Node.js
Understanding Cookies and Implementing them in Node.js
Node.js Structural Comparisons
Converting a Static Site to a Static Site Generator
Getting Started With Axios In Nuxt
How To Build A Simple Cryptocurrency Blockchain In Node.js
Sharing Code Between Projects: Lessons Learned In The Trenches
Develop Your First Data-Driven Node.js Web App
An Absolute Beginner Guide to Node Package Manager
Breaking Down MEAN vs MERN Stacks
API Authentication with Node.js
Build a Ticketing App with Adonis.js and Vue.js
Basics of SSH and Building an Application in Node.js
Why Node.js is Great for Backend Development?
Writing A Multiplayer Text Adventure Engine In Node.js (Part 1)
Creating Secure Password Resets With JSON Web Tokens
Node.js Rxjs
Creating A Continuous Integration Test Workflow Using GitHub Actions
Node.js vs. PHP – Which is better for Backend development?