- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 06-22-2020 11:35 AM
Importing NLU Model CSV using platform Import sets:
Suggested reading: Platform Import sets
First, create an NLU model in CSV format for your import. Note that in this article, the model has four columns: Model, Intent, Utterance, and Language. Here is a sample in CSV format:
Navigate to System Import Sets -> Data sources.
Make sure that the current application scope is ‘Global’ and then create a new Data Source record. Attach your sample model csv file to the record and click Save.
In the Related Links section of your Data Source record, click “Test Load 20 Records”. This creates the import set staging table.
Next, create a table transform map from the related list and set the target table as “NLU Utterance” and click Save. Once the Transform map is created, click “Auto Map Matching Fields” so that automatic field maps are created.
Create an “onBefore” Transform Script. Here is sample transform script that you could use for this CSV use case:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
// Add your code here
// Get scope from glide session
var scope = gs.getCurrentApplicationId();
var modelId = null;
var intentId = null;
var gr = new GlideRecord('sys_nlu_model');
gr.addQuery('display_name', source.u_model);
gr.addQuery('language', source.u_language);
gr.addQuery('sys_scope', scope);
gr.query();
if(gr.next())
modelId = gr.getValue('sys_id');
else {
gr.initialize();
gr.setValue('display_name', source.u_model);
gr.setValue('language', source.u_language);
gr.setValue('sys_scope', scope);
modelId = gr.insert();
}
var intent_gr = new GlideRecord('sys_nlu_intent');
intent_gr.addQuery('model', modelId);
intent_gr.addQuery('name', source.u_intent);
intent_gr.addQuery('sys_scope', scope);
intent_gr.query();
if (!intent_gr.next()) {
// Create a new intent
intent_gr.initialize();
intent_gr.setValue('model', modelId);
intent_gr.setValue('name', source.u_intent);
intent_gr.setValue('sys_scope', scope);
intentId = intent_gr.insert();
} else {
intentId = intent_gr.getValue('sys_id');
}
source.u_intent = intentId;
})(source, map, log, target);
Note: The model name should be unique within the application scope.
Submit the Transform script and go to the initially created Data Source record.
Select the application scope in which you want to import your model, and then click the ‘Load All Records’ related link.
Run Transform.
Select the newly created Transform map.
Transform runs the Table transform map, and maps data into the NLU tables.
Once the transform is completed, import logs are available to help with debugging.
Update set is attached for reference.
- 1,941 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
@Pranith2 - Thanks for sharing, However, I followed the same step and it did import in the target table but when I opened the mode those imported utterances were not listed, Any thoughts did I miss anything here
Thanks In Advance