Import IBM Watson Assistants to Cognigy.AI

 

 

import-ibm-watson-assistant-to-cognigy-ai.pngIn order to transform an existing IBM Watson Assitant to a Cognigy.AI Virtual Agent, three steps are required:

  1. Download the IBM Watson Skill
  2. Transform the intents to Cognigy.AI
  3. Upload the content to a Cognigy.AI Virtual Agent
  4. Optional: Automatically upload intents to a new Flow

Download the IBM Watson Skill

The first required step is to download the existing IBM Watson Skill in order to have the raw information about all Intents and Dialogs. Therefore, one has to login to the IBM Cloud and open the Watson service while the URL is structured such as the following

https://  <region>  .assistant.watson.cloud.ibm.com

After logging in and navigating to the "Skills" section, one should see a similar view to:

 

ibm-watson-assistant-skills-view-download_copy.png

 

As displayed in the screenshot above, one can click on the three button menu inside of the preferred Skill card and click on the "Download" button. After clicking this button, the Skill will be downloaded as JSON file. It's called Credit-Card-dialog.json for the example shown in above.

Transform the intents to Cognigy.AI

Next, the Intents have to be converted into a valid Cognigy.AI format to be uploaded successfully. In order to do so, the following Python script can be used:

import json

# Read the JSON content of the downloaded IBM Watson file
fileName = "Credit-Card-dialog.json"

file = open(fileName)
fileJSON = json.load(file)

# Initialize the list of intents that will be uploaded to Cognigy.AI
intents = []

# Loop through all existing IBM Watson intents
for intent in fileJSON["intents"]:

# Transform the current intent into the Cognigy.AI format
intents.append({
"name": intent["intent"],
"exampleSentences": [example["text"] for example in intent["examples"]],
"rules": [],
"tags": [],
"confirmationSentences": [],
"condition": "",
"disambiguationSentence": "",
"childFeatures": False,
"parent": "",
"defaultReply": None
})

with open("cognigy-intents-{}".format(fileName), "w", encoding="utf-8") as outputFile:
json.dump(intents, outputFile, ensure_ascii=False)

How to

  1. Please make sure that Python3 is installed to the operation system
  2. Open the script in your preferred text editor and provide the name of the downloaded IBM skill JSON file here:

    cognigy-python-ibm-transformer-change-file-name.png
    Please make sure to add the .json file type to the end of the name

  3. Open the Terminal or Shell of the computer
  4. Navigate to the directory taht contains the downloaded Credit-Card-dialog.json file
  5. Run python3 ibmWatsonToCognigyAI.py

    terminal-python-script-transform-imb-to-cognigy-intents.png

  6. Now, one should find a new file in the new directory, called similar to "cognigy-intents-Credit-Card-dialog.json"
  7. Done

Upload the content to a Cognigy.AI Virtual Agent

Last but not least, the new intents must be uploaded to a virtual agent inside of Cognigy.AI. Therefore, please:

  1. Login to Cognigy.AI
  2. Open the Agent
  3. In the left side menu, navigate to Build -> Flows
  4. Select the Flow the intents should be uploaded to
  5. On the top right, click on NLU
  6. Next to the "Create Intent" button, click on the three-button-menu and select "Upload Intents CSV of JSON FIle"

    cognigy-ai-upload-intents-to-nlu-flow.png

  7. The explorer / finder will open to select the previously created "cognigy-intents...json" file. Please select and upload it.
  8. After successfully uploaded the file, one will see the IBM intents in the list of intents on the left side. However, now they are transformed and imported to the Cognigy.AI system
  9. Done

Congratulations!

Please find all used files attached to this Help Center article.

Optional: Automatically upload intents to a new Flow

If the converted intents should be uploaded automatically, one can use the free and open Cognigy API: https://api-trial.cognigy.ai/openapi 

In this case, three operations are needed for achieving the expected outcome:

  1. Create a new Flow
  2. Create a new Intent
  3. Create a new Example Sentence

Such as explained in the documentation, the API Key is required for using the API. Those credentials can be created in the Profile Settings inside of Cognigy.AI: https://trial.cognigy.ai/me 

The attached Python script ibmWatsonToCognigyAIAutoUpload.py contains the automatic creation and upload.


Comments

0 comments

Article is closed for comments.

Was this article helpful?
0 out of 0 found this helpful