IBM Watson | Classic

The IBM Watson widget lets you analyze the content of an entry and extract meta-data from the content such as categories, concepts, emotions, entities, keywords, relations, semantic roles, and sentiment. This widget uses custom annotation models developed by Watson Knowledge Studio to analyze the data and identify industry- or domain-specific entities and relations in unstructured text.

This widget uses IBM Watson APIs to offer a wide variety of services that let you get more out of your content. Refer to the IBM Cloud API docs for more details.

This step-by-step guide explains how to create the IBM Watson widget extension in Contentstack. The steps to be performed are as follows:

  1. Create service instance in IBM Watson
  2. Generate service credentials
  3. Configure and deploy Lambda function
  4. Add "IBM Watson" widget extension to your stack
  5. Use the extension
  1. Create service instance in IBM Watson

    To begin with, you need to create an instance of the "Natural Language Understanding" service and create service-specific credentials to provide authentication to the selected service in IBM Cloud. To do so, perform the steps given below:

    1. Log in to your IBM Cloud account.
    2. Go to the Natural Language Understanding page in the IBM Cloud Catalog.
    3. Click Create. This creates your service instance.

    Next, we’ll see how to retrieve the service credentials.

    Additional Resource: For more information, refer the Getting started with Watson and IBM Cloud page.

  2. Generate service credentials

    After creating your service instance, perform the following steps:

    1. When you are led to the Manage page, go to the Credentials tab
    2. Click Show to view your credentials. You will find the API key and URL of your service.
    3. Note down the API key and URL, as you will need to use them in Step 6.

    Additional Resource: For more information, refer the Service credentials for Watson services page.

  3. Configure and deploy Lambda function

    To protect sensitive information (such as API Key and URL) and avoid Cross-Origin Resource Sharing (CORS) issues, you can use Lambda function for this extension. To do so, perform the below functions:

    1. After retrieving the credentials, deploy the code for the lambda function to AWS Lambda.

      Note: Refer Step 4 for the source code along with the lambda function of the IBM Watson extension.

    2. In the Environment Variables section of AWS Lambda, enter the credentials against the variables as follows:
    WATSON_SERVICE_API_KEY= API Key received in service instance credentials
    WATSON_SERVICE_URL= URL received in service instance credentials
    
  4. Add "IBM Watson" widget extension to your stack

    To add IBM Watson widget to your stack, log in to your Contentstack account and perform the following steps:
    1. Select the relevant stack where you want to add the widget
    2. Hover over the “Settings gear icon and click on Extensions
    3. Click on the + Add Extension button on the top-right corner and select Create new.
      Creating_new_extension.png
    4. Select the extension type as Custom Widget.
      Select_Extension_Type_-_Custom_Widget.png
    5. You will be led to the “Create New Extension” details page where you need to enter details in the fields as given below:
      • Title: Provide a suitable title. For example, IBM Watson.
      • Hosting method: Select Hosted By Contentstack. As soon as you do this, you will see the "Extension Source Code" field below.
      • Extension Source Code: In this field, you need to enter the extension code. If Extensions are part of your plan, contact our Support team to get the code for the extension.
        The support team will provide you with the source code (src file). Copy the code from the index.html file located in the root folder and paste it in the "Extension source code" field.
      • Config Parameter: Enter the configuration details for the extension. Here, you need to mention the AWS API gateway URL for the lambda function (in the "url" parameter). If you have enabled API key for secured access, you need to mention that too.
        {
            "url": "https://abcde1234.execute-api.
                us-east-1.amazonaws.com/default/
                contentstack-ibm-watson-ai-widget",
            "x-api-key": "SSS111Sss1ssSSsssS11s11SS11SS"
        }
      • Scope: You can choose to incorporate this widget in either “All Content Types” or “Specific Content Types.” Selecting the latter option displays a list of content types from which you can select the required ones.
    6. Click on Save. This will create your extension.

    Now, let’s understand how to use this widget extension in your entries.

  5. Use the extension

    Once you have added this widget to your stack, you can use it in the entries of the selected content type(s). Let’s look at the steps involved in using this widget.

    1. Click on the content type for which you have enabled the custom and click on an entry
    2. You will see the Widgets dropdown on the top of the page. Click on it and select IBM Watson. The selected widget expands on the sidebar.
    3. Select a Field from the dropdown.
    4. Select a Model and click on Run. Based on the model selected, you will find the result on the sidebar.


Was this article helpful?

Thanks for your feedbackSmile-icon

On This Page

^