diff --git a/packages/core.gbapp/services/GBMinService.ts b/packages/core.gbapp/services/GBMinService.ts index b7f8ec22..a74513c5 100644 --- a/packages/core.gbapp/services/GBMinService.ts +++ b/packages/core.gbapp/services/GBMinService.ts @@ -244,7 +244,7 @@ export class GBMinService { if (instance !== null) { const speechToken = instance.speechKey != null ? await this.getSTSToken(instance) : null; let theme = instance.theme; - if (theme !== undefined) { + if (theme === undefined) { theme = 'default.gbtheme'; } res.send( @@ -485,6 +485,10 @@ export class GBMinService { private async processMessageActivity(context, min: GBMinInstance, step: GBDialogStep) { // Direct script invoking by itent name. + const globalQuit = (locale, utterance) => { + return utterance.match(Messages[locale].global_quit); + } + const isVMCall = Object.keys(min.scriptMap).find(key => min.scriptMap[key] === context.activity.text) !== undefined; @@ -498,6 +502,9 @@ export class GBMinService { } else if (context.activity.text.charAt(0) === '/') { await step.beginDialog(context.activity.text); + } else if (globalQuit(step.context.activity.locale, context.activity.text)) { + await step.cancelAllDialogs(); + await step.context.sendActivity(Messages[step.context.activity.locale].canceled); } else if (context.activity.text === 'admin') { await step.beginDialog('/admin'); diff --git a/packages/core.gbapp/strings.ts b/packages/core.gbapp/strings.ts index 244d457b..49e91acc 100644 --- a/packages/core.gbapp/strings.ts +++ b/packages/core.gbapp/strings.ts @@ -6,8 +6,9 @@ export const Messages = { good_evening: 'good evening', good_night: 'good night', hi: (msg) => `Hello, ${msg}.`, - very_sorry_about_error: `I'm sorry to inform that there was an error which was recorded to be solved.` - + very_sorry_about_error: `I'm sorry to inform that there was an error which was recorded to be solved.`, + global_quit: /^(quit|Quit)/i, + canceled: 'Canceled. If I can be useful, let me know how' }, 'pt-BR': { show_video: 'Vou te mostrar um vídeo. Por favor, aguarde...', @@ -15,6 +16,8 @@ export const Messages = { good_evening: 'boa tarde', good_night: 'boa noite', hi: (msg) => `Oi, ${msg}.`, - very_sorry_about_error: `Lamento, ocorreu um erro que já foi registrado para ser tratado.` + very_sorry_about_error: `Lamento, ocorreu um erro que já foi registrado para ser tratado.`, + global_quit: /^(sair|Sair)/i, + canceled: 'Cancelado, avise como posso ser útil novamente.' } };