Converting NLU Models to ServisBOT Common Format

How to convert NLU models to common format

For a number of NLU providers, you can do a direct export of your design which can be uploaded to the Insights tool directly. We will make a best effort attempt to convert the model to the ServisBOT common format automatically. If the model can not be converted, you will need to convert the model manually, as outlined in the following guide.

Supported NLU providers (as of November 2022):

  • Dialogflow ES
  • Luis
  • Watson
  • Amazon Lex

To get started with an NLU model stored in a public NLU vendor, follow the instructions below.

Cognigy

From the Cognigy console, select the bot from the list of agents.

Cognigy Agents

From there, navigate to the menu on the left side of the screen and click “Manage”. A dropdown menu will open up. Select “Packaging”.

Cognigy Export 1

Select the lexicons(intents) to be exported.

Cognigy Export 2

From there click “Next”. The next screen contains a text box for a “Package Name”. It will be labeled “Package-BOTNAME”. This can be kept as is, or changed to remove “Package” from the beginning. Click “Export” then click the link next to “Download Export”.

This will result in a .zip file being downloaded with a name similar to “BOTNAME_DATE_TIME.zip”. When the .zip file is opened a root folder will contain a folder labeled “lexicon”. The files in the folder are labeled with an id. Each id represents an intent name, which can be found by opening each file.

Cognigy Intent

Make sure to note the id associated with each intent. The intent name can be found next to “name”.

Utterance files can be found in the folder labeled “lexiconKeyphrase”. The files are also labeled by id. They are not grouped specifically by intent.

Cognigy Utterance

After opening the file, the utterance can be found next to “value”. To find out which intent the utterance belongs to, find the id next to “lexiconReference”.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Since each utterance is located in its own file, this process may take a long time, expecially for larger bots. In this case, it may be easier to create a csv by referencing the Cognigy console.

Navigating to “Lexicons” under “Build” on the menu on the left of the screen will bring up the intents for the bot. Clicking on each intent will bring up the list of utterances for that intent.

DialogFlow CX

Bot data is normally exported and a .json file is downloaded containing the bot name, intents, and utterances. However, for DialogFlow CX that option is not supported and the conversion of the data into ServisBOT common format has to be done directly from the DialogFlow CX console.

From the console, select the project and then select a bot from the “Agents” list. Each agent represents a bot.

DialogFlow CX Agents

From there, navigate to the “Manage” tab on the menu on the left side of the screen. Navigate to “Intents”. Each intent will be displayed.

DialogFlow CX Intents

Clicking in to each intent will show the utterances of that intent.

DialogFlow CX Utterances

Use the intent data to create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

DialogFlow ES

If your exported bot fails to parse, you can follow these manual steps to convert your DialogFlow ES bot to the ServisBOT common format.

From the DialogFlow ES console, open the menu by clicking the three lines icon on the top left of the screen. Select a bot from the drop-down menu and then navigate to “Settings” by clicking the gear icon next to the drop-down and bot name.

DialogFlow Bot

Click on the “Export and Import” tab and select “Export as Zip”.

DialogFlow Export

Exporting a DialogFlow bot design will download a zip file. After unzipping the file there will be a folder with the bot name. In the folder there will be 2 .json files and an “intents” folder. Within the intents folder are 2 kinds of files - files with utterances and files with intent names, all .json. Utterance files contain an intent name followed by usersays and the language. Intent files just say the intent name.

DialogFlow Intents

The INTENT.json file will look something like the above image, where “name” corresponds to the intent name.

DialogFlow Utterances

The INTENT_usersays_.json will look the the above image, where the list “data” will contain “text” which corresponds to an utterance.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Lex V1

If your exported bot fails to parse, you can follow these manual steps to convert your Lex V1 bot to the ServisBOT common format.

When exporting a bot design from Lex V1, there are 2 platform options, Alexa Skills Kit & Lex. Each produce a different format of data.

In the LexV1 console, select your bot from the list and click “Actions.”

LexV1 Export

A dropdown menu will appear. Select “Export”. After selecting a bot version, a platform can be selected, Amazon Skills Kit (ASK) or Amazon Lex. The instructions for both are below.

Lex V1: Platform Alexa Skills Kit

Select “Amazon Skills Kit (ASK)” under “Platform” and then click “Export”.

LexV1 ASK

Exporting the data in this format will give you a single .json file containing the bot name. The file may have to be reformatted to make the json display readable.

LexV1 ASK JSON

The .json file will look something like the above image. In the “intents” list, “name” refers to the intent and “samples” contains a list of the corresponding utterances.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Lex V1: Platform Lex

Select “Amazon Lex” under “Platform” and then click “Export”.

LexV1 Lex

Exporting the data in this format will give you a single .json file containing the bot name.

LexV1 Lex JSON

The .json file will look something like the image above. Under “resource” there is “name” which refers to the bot name. In the “intents” list there is “name” referring to the name of the intent. Under that there will be a list “sampleUtterances” which will contain the utterances of the intent.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Lex V2

If your exported bot fails to parse, you can follow these manual steps to convert your Lex V2 bot to the ServisBOT common format.

From the LexV2 console, select a bot from the list, click “Actions” and from the drop-down menu select “Export”.

LexV2 Export

Exporting Lex V2 data into will give you a folder with a name including the bot name followed by the bot version, a code, and LexJson. Navigating further into the folders from the bot design export will show that each intent has its own folder and .json file.

An example of an intent json file is as follows:

LexV2 JSON

“Name” refers to the name of the intent and within “sampleUtterances” there is a list of utterances belonging to the intent.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Luis

If your exported bot fails to parse, you can follow these manual steps to convert your Luis bot to the ServisBOT common format.

Login to a Luis account, select a bot from the “Conversation Apps” list, and click “Export”. A dropdown menu will appear.

Luis Export

Select “Export as JSON” and a .json file will be downloaded with a name similar to BOTNAME.json.

Luis JSON

The above image shows the .json file downloaded from the previous step. When navigating down to “utterances” in the file, “text” represents the utterance and “intent” represents the intent that utterance belongs to.

This data must be taken and put into a CSV file with the following columns: Botname, intent, and utterance. The Botname is the name of the bot selected from the “Conversation Apps” list.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

Watson

If your exported bot fails to parse, you can follow these manual steps to convert your Watson bot to the ServisBOT common format.

There are two ways to export Watson data and each way will result in a different format of json file. Note that bots in “Classic” do not carry over to “New” and vice versa, so bots will only exist in one of those platforms.

Your starting point, be it “Classic” or “New”, may vary. The Watson Assistant will display the current version.

Classic Experience

From the Watson Assistant, select the bot from the dropdown menu at the top of the screen. Once selected, click the icon on the top right “Manage”. Navigate to “Switch to Classic Experience”.

Watson Classic

Once in the classic experience, select the assistant you would like to export. Click on “Skills” on the menu on the right of the screen. Click the three dots icon on the selected bot and click “Download”.

Watson Export

Exporting Watson data will give you a .json file with a name similar to BOTNAME-dialog.json and will look like the image below.

Watson JSON

“Intent” will refer to the intent name while the “examples” list will hold all utterances within that intent.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design

New Experience

From the Watson Assistant click “Actions” on the sidebar menu. In actions click the gear on the top right of the screen “Global Settings”.

Watson New Export1

Navigate to the “Upload/Download” tab. Click “Download”.

Watson New Export2

Exporting Watson data will give you a .json file with a name similar to BOTNAME-dialog.json and will look like the image below.

Watson New JSON1

“Name” refers to the name of the bot. Intents and utterances are a little harder to locate in this json file. “Title” will refer rto an intent name and will correspond to the words and numbers listed under “intent”. In the above image “set_appointment” corresponds to “action_19432_intent_27233”.

Watson New JSON2

Further down in the json file are the utterances within the intent. Notice that the utterances under “examples” belong to “action_19432_intent_27233”, which is intent “set_appointment”.

Create a CSV file with the following columns: Botname, intent, and utterance.

Each utterance should have a row in the CSV with the same Botname, and the correct intent name in the intent column, similar to the image below.

Bot Design


Last modified November 11, 2022