This post describes how to use Openwhisk to access the cognitive technologies of Watson to automatically provide insights into the articles on a blog news page.
Add Alchemy API to your Bluemix account
Insert a new Openwhisk action in the chain to extract cognitive insights on news articles
Update front end code to display cognitive insights
Add Alchemy API service to your Bluemix account
Login into your BlueMix account here. After you login, select catalog from the top navigation. On the left navigation bar select the checkbox next to Watson to limit the display to Watson services only. Your screen should look like this:
Select Alchemy API, leave the defaults values and click Create. After a few moments, the Watson Alchemy API service should be created and added to your Bluemix space.
Click on service credentials on the left navigation to find your API key.
Note this API key, you will need it for your Openwhisk action.
Your Bluemix space is now Watson enabled.
Watson Openwhisk Action
Create a new Openwhisk action
This new Openwhisk action does the following
Sends a URL to the Alchemy API service
Extracts keywords, concepts, and document emotion
Appends Watson insights to the article information
Invokes the insert action to insert the article
The contents of the append_watson action in its entirety:
Openwhisk flow modification
The previous workflow in Openwhisk looked like this:
The new modified flow has the Watson Alchemy API action inserted:
Modify append article description action
Previously, the append article description action invoked the insert article action. To insert the append Watson service into our chain of action we need to swap out the insert article whisk call for the append Watson call.
Just change this
Modify insert article
Previously, the insert article method was prescriptive in the parameters it inserted into the Cloudant doc. To provide for more flexibility, this change stores all supplied parameters in the Cloudant document.
The updated Openwhisk action just passes the params object as the value for ‘doc’
Once you update all your Openwhisk actions, your cloudants documents should have a lot more information.
Display cognitive insights
Cloudant is asked to return three additional fields: Sentiment, Concepts, Keywords
A dynamic table object without borders is created and inserted using jQuery
After those changes, the news page should look like the one below.
That is it! Using Bluemix with Watson services it’s easy to add cognitive insight into your blog. All without managing a single server.