Introduction - IBM Watson/Bluemix Services
We've already had two blog posts on IBM Watson so far. One blog post for Watson's Tone Analyzer service, and another blog post for Watson's Visual Recognition service. We're going to go through this article quickly since we already have a lot of experience using Watson. If this is your first time, see the Tone Analyzer service since it's meant for people getting started.
IBM's Personality Insight service "predicts personality characteristics, needs, and values through written text." We're going to go through setting the service up, and creating a node project to use that service.
Create The Service On IBM's Website
First, we need to set the Personality Insight service up on IBM's website. If you don't have a Bluemix account, register for one. (Free, very easy, no credit card.)
Next, go to the Personality Insights page and click the "Get started free" button. (Log in if you need too.)
You'll be prompted to create a new project. For the project name, enter "srcmakePersonality" and click the "Create Project" button on the bottom right of the screen.
You'll be taken to your project page. Click the "Show" button and make note of the username and password under the Credentials section. We'll need to use them soon to authenticate our API calls to the Personality Insights API.
(Did this section seem fast? Remember to watch the youtube video for this topic or go back and read the Tone Analyzer article, since we went through these steps in detail.)
So we have our API credentials, now we need to actually write some code to use the service.
Setting Up Our Node Project
We're going to make a project using Node to test using the Personality Insights service. Since this is just going to be a basic project (that we've already went over in detail in the Tone Analyzer article), just copy the code from GitHub. In your terminal in the folder you want the project to be stored in:
It's a basic node project with the Watson library installed, and a config.js file to store our credentials.
Open "config.js" and for the username and password, enter the usename and password that we got in the previous section after creating the srcmakePersonality project on the Bluemix website.
Adding The Personality Insight Code
Our project is set up, but doesn't actually do anything useful yet. We want to test the Personality Insight service. Specifically, we want to make an API call to it and pass it some text to be analyzed. We're going to write code that does that, with the help of the API reference documentation.
Add the following code to "index.js".
We simply include the watson library and our config library. The text we want to analyze is Martin Luther King Jr's "I Have a Dream" speech. We call the Personality Insights API on this text, and output the result.
Testing Our Code
Testing our code is simple. In the command line, run index.js.
You'll see the following output:
Actually, the output was 440 lines long! But I cut it down to only the first three traits. You can see that Watson returns some personality names, and some numbers that correspond to what the speaker/writer of the text is of that personality.
In this article, we looked at and coded for the Watson Personality Insight service. It was pretty simple, all we did was create a project on the Bluemix website to get a username and password, then we wrote some Node code to call the API that controls the Personality Insight service.
Obviously, you can spin the project off and customize it for whatever your need is, but we at least know how to use the service.
Like this content and want more? Feel free to look around and find another blog post that interests you. You can also contact me through one of the various social media channels.