diff --git a/components/nlus/nlu.ts b/components/nlus/nlu.ts index a6f6b9b..c1b7349 100644 --- a/components/nlus/nlu.ts +++ b/components/nlus/nlu.ts @@ -187,6 +187,10 @@ export default class Nlu extends Component { } } else { // Create new entity + if ((key as string).length > 20) { + console.log(`Failed to create ${key}. Entity name must not be longer than 20 characters.`); + continue; + } await this.helper.toPromise(this.api.nluApi, this.api.nluApi.projectsProjectIdNlusNluNameEntitiesPost, projectId, nluDesc.name, { ...nluDesc.entities[key], name: key }); @@ -222,6 +226,10 @@ export default class Nlu extends Component { for (const key in nluDesc.entities) { if (nluDesc.entities[key]) { // create new entity + if ((key as string).length > 20) { + console.log(`Failed to create ${key}. Entity name must not be longer than 20 characters.`); + continue; + } await this.helper.toPromise(this.api.nluApi, this.api.nluApi.projectsProjectIdNlusNluNameEntitiesPost, projectId, nluDesc.name, { ...nluDesc.entities[key], name: key }); diff --git a/lib/components/nlus/nlu.js b/lib/components/nlus/nlu.js index 43f387d..afcd181 100644 --- a/lib/components/nlus/nlu.js +++ b/lib/components/nlus/nlu.js @@ -185,6 +185,10 @@ class Nlu extends merapi_1.Component { } else { // Create new entity + if (key.length > 20) { + console.log(`Failed to create ${key}. Entity name must not be longer than 20 characters.`); + continue; + } yield this.helper.toPromise(this.api.nluApi, this.api.nluApi.projectsProjectIdNlusNluNameEntitiesPost, projectId, nluDesc.name, Object.assign({}, nluDesc.entities[key], { name: key })); } } @@ -211,6 +215,10 @@ class Nlu extends merapi_1.Component { for (const key in nluDesc.entities) { if (nluDesc.entities[key]) { // create new entity + if (key.length > 20) { + console.log(`Failed to create ${key}. Entity name must not be longer than 20 characters.`); + continue; + } yield this.helper.toPromise(this.api.nluApi, this.api.nluApi.projectsProjectIdNlusNluNameEntitiesPost, projectId, nluDesc.name, Object.assign({}, nluDesc.entities[key], { name: key })); } }