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)