Cognigy.AI Lab
You've entered the Cognigy.AI Lab. This content and example code is inspirational.
In order to transform an existing IBM Watson Assitant to a Cognigy.AI Virtual Agent, three steps are required:
- Download the IBM Watson Skill
- Transform the intents to Cognigy.AI
- Upload the content to a Cognigy.AI Virtual Agent
- 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:
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
- Please make sure that Python3 is installed to the operation system
- Open the script in your preferred text editor and provide the name of the downloaded IBM skill JSON file here:
Please make sure to add the .json file type to the end of the name - Open the Terminal or Shell of the computer
- Navigate to the directory taht contains the downloaded Credit-Card-dialog.json file
- Run python3 ibmWatsonToCognigyAI.py
- Now, one should find a new file in the new directory, called similar to "cognigy-intents-Credit-Card-dialog.json"
- 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:
- Login to Cognigy.AI
- Open the Agent
- In the left side menu, navigate to Build -> Flows
- Select the Flow the intents should be uploaded to
- On the top right, click on NLU
- Next to the "Create Intent" button, click on the three-button-menu and select "Upload Intents CSV of JSON FIle"
- The explorer / finder will open to select the previously created "cognigy-intents...json" file. Please select and upload it.
- 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
- 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:
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