From 090c0aecd82a272b3a5f0afd72235154c3c0c880 Mon Sep 17 00:00:00 2001 From: Rommel Berrios Date: Thu, 16 May 2019 11:38:18 -0600 Subject: [PATCH] Fixed @sys. slots on dialogflow --- CHANGELOG.md | 1 + package.json | 2 +- src/DialogflowSchema.ts | 5 ++++- test/dialogflow.spec.ts | 20 ++++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d1572..e789831 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Now alexa spec is splitted into smaller units testing specific functionality +- Fixed @sys. slots on dialogflow were converted into a different type ## [2.1.2] - 2019-05-08 diff --git a/package.json b/package.json index 7f2770a..3aad73f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "voxa-cli", - "version": "2.1.2", + "version": "2.1.3-alpha1", "description": "The Voxa CLI tools", "bin": { "voxa": "./bin/voxa.js" diff --git a/src/DialogflowSchema.ts b/src/DialogflowSchema.ts index e4b35b9..45155ef 100644 --- a/src/DialogflowSchema.ts +++ b/src/DialogflowSchema.ts @@ -241,7 +241,10 @@ export class DialogflowSchema extends Schema { const slot = _.find(parameters, { name: text }); if (isTemplate && slot) { - _.set(element, "meta", `@${_.kebabCase(slot.dataType)}`); + const slotMeta = slot.dataType.includes("@sys.") + ? slot.dataType + : `@${_.kebabCase(slot.dataType)}`; + _.set(element, "meta", slotMeta); _.set(element, "alias", alias); } diff --git a/test/dialogflow.spec.ts b/test/dialogflow.spec.ts index 595e71f..3976ca0 100644 --- a/test/dialogflow.spec.ts +++ b/test/dialogflow.spec.ts @@ -1,4 +1,5 @@ import { expect } from "chai"; +import * as _ from "lodash"; import * as path from "path"; import { configurations } from "./mocha.spec"; @@ -43,12 +44,18 @@ configurations.forEach(interactionFile => { describe("NumberIntent", () => { let intent: any; + let intentUtterance: any; before(async () => { intent = await require(path.join( __dirname, interactionFile.speechPath, "dialogflow/production/intents/NumberIntent.json" )); + intentUtterance = await require(path.join( + __dirname, + interactionFile.speechPath, + "dialogflow/production/intents/NumberIntent_usersays_en.json" + )); }); it("should set slotRequired for the first slot to be false", () => { @@ -59,6 +66,19 @@ configurations.forEach(interactionFile => { it("should set webhookForSlotFilling to true", () => { expect(intent.webhookForSlotFilling).to.be.true; }); + + it("should have @sys slot for numbers", () => { + intentUtterance.forEach((utterance: any) => { + const numberMetaPhrase = utterance.data.find((item: any) => item.meta === "@sys.number"); + expect(numberMetaPhrase).to.be.ok; + + expect(_.pick(numberMetaPhrase, ["meta", "alias", "text"])).to.be.eql({ + meta: "@sys.number", + alias: "number", + text: "{number}" + }); + }); + }); }); describe("JokeIntent", () => {