diff --git a/deploy/core.gbapp/dialogs/WhoAmIDialog.ts b/deploy/core.gbapp/dialogs/WhoAmIDialog.ts index 1ec5c7a0..980ec7b0 100644 --- a/deploy/core.gbapp/dialogs/WhoAmIDialog.ts +++ b/deploy/core.gbapp/dialogs/WhoAmIDialog.ts @@ -34,13 +34,13 @@ import { GBConversationalService } from "./../services/GBConversationalService"; import { GBCoreService } from "../services/GBCoreService"; -import { IGBDialog } from "botlib"; +import { IGBDialog } from "botlib"; import { GBMinInstance } from "botlib"; import { BotAdapter } from "botbuilder"; export class WhoAmIDialog extends IGBDialog { - + /** * Setup dialogs flows and define services call. * @@ -48,20 +48,20 @@ export class WhoAmIDialog extends IGBDialog { * @param min The minimal bot instance data. */ static setup(bot: BotAdapter, min: GBMinInstance) { - + min.dialogs.add("/whoAmI", [ async (dc, args) => { - dc.context.sendActivity(`${min.instance.description}`); + await dc.context.sendActivity(`${min.instance.description}`); - if (min.instance.whoAmIVideo){ - dc.context.sendActivity(`Vou te mostrar um vídeo. Por favor, aguarde...`); - min.conversationalService.sendEvent(dc, "play", { - playerType: "video", - data: min.instance.whoAmIVideo.trim() - }); - } + if (min.instance.whoAmIVideo) { + await dc.context.sendActivity(`Vou te mostrar um vídeo. Por favor, aguarde...`); + await min.conversationalService.sendEvent(dc, "play", { + playerType: "video", + data: min.instance.whoAmIVideo.trim() + }); + } - dc.replace('/ask', {isReturning: true}); + await dc.replace('/ask', { isReturning: true }); } ]); } diff --git a/deploy/core.gbapp/services/GBMinService.ts b/deploy/core.gbapp/services/GBMinService.ts index f58af680..c11151c5 100644 --- a/deploy/core.gbapp/services/GBMinService.ts +++ b/deploy/core.gbapp/services/GBMinService.ts @@ -236,8 +236,14 @@ export class GBMinService { }, this); } - private receiver(adapter: BotFrameworkAdapter, req: any, res: any, conversationState: ConversationState, min: any, instance: any, appPackages: any[]) { + /** + * Bot Service hook method. + */ + private receiver(adapter: BotFrameworkAdapter, req: any, res: any, conversationState + : ConversationState, min: any, instance: any, appPackages: any[]) { + return adapter.processActivity(req, res, async (context) => { + const state = conversationState.get(context); const dc = min.dialogs.createContext(context, state); const user = min.userState.get(dc.context); diff --git a/deploy/customer-satisfaction.gbapp/dialogs/FeedbackDialog.ts b/deploy/customer-satisfaction.gbapp/dialogs/FeedbackDialog.ts index 8eda2dc9..33d1056e 100644 --- a/deploy/customer-satisfaction.gbapp/dialogs/FeedbackDialog.ts +++ b/deploy/customer-satisfaction.gbapp/dialogs/FeedbackDialog.ts @@ -76,7 +76,7 @@ export class FeedbackDialog extends IGBDialog { "Sugestões melhoram muito minha qualidade...", "Obrigado pela sua iniciativa de sugestão." ]; - dc.context.sendActivity(messages[0]); // TODO: Handle rnd. + await dc.context.sendActivity(messages[0]); // TODO: Handle rnd. } let messages = [ @@ -89,13 +89,13 @@ export class FeedbackDialog extends IGBDialog { async (dc, value) => { let rate = await AzureText.getSentiment(min.instance.textAnalyticsKey, "pt-br", value); if (rate > 0) { - dc.context.sendActivity("Bom saber que você gostou. Conte comigo."); + await dc.context.sendActivity("Bom saber que você gostou. Conte comigo."); } else { - dc.context.sendActivity( + await dc.context.sendActivity( "Vamos registrar sua questão, obrigado pela sinceridade." ); } - dc.replace('/ask', { isReturning: true }); + await dc.replace('/ask', { isReturning: true }); }]); } } diff --git a/deploy/default.gbui/package.json b/deploy/default.gbui/package.json index f2ecc6aa..4d820f54 100644 --- a/deploy/default.gbui/package.json +++ b/deploy/default.gbui/package.json @@ -5,12 +5,12 @@ "homepage": ".", "dependencies": { "ajv": "^6.5.3", - "botframework-webchat": "^0.14.2", + "botframework-webchat": "^0.12.0", "deep-extend": "^0.6.0", "fetch": "^1.1.0", "msal": "^0.2.2", - "react": "^16.4.2", - "react-dom": "^16.4.2", + "react": "^15.5.0", + "react-dom": "^15.5.0", "react-helmet": "^5.2.0", "react-player": "^1.6.4", "react-powerbi": "^0.2.1", diff --git a/deploy/kb.gbapp/dialogs/AskDialog.ts b/deploy/kb.gbapp/dialogs/AskDialog.ts index ee40f8f8..c68b6d15 100644 --- a/deploy/kb.gbapp/dialogs/AskDialog.ts +++ b/deploy/kb.gbapp/dialogs/AskDialog.ts @@ -126,7 +126,7 @@ export class AskDialog extends IGBDialog { // Goes to ask loop, again. - dc.replace("/ask", { isReturning: true }); + await dc.replace("/ask", { isReturning: true }); } else { @@ -176,8 +176,8 @@ export class AskDialog extends IGBDialog { "Desculpe-me, não achei nada parecido. Poderia tentar escrever de outra forma?" ]; - dc.context.sendActivity(messages[0]); // TODO: Handle rnd. - dc.replace("/ask", { isReturning: true }); + await dc.context.sendActivity(messages[0]); // TODO: Handle rnd. + await dc.replace("/ask", { isReturning: true }); } } } @@ -212,8 +212,8 @@ export class AskDialog extends IGBDialog { } }, async (dc, value) => { - dc.endAll(); - dc.begin("/answer", { query: value }); + await dc.endAll(); + await dc.begin("/answer", { query: value }); } ]); } diff --git a/deploy/kb.gbapp/dialogs/MenuDialog.ts b/deploy/kb.gbapp/dialogs/MenuDialog.ts index cdcda5bb..256692c1 100644 --- a/deploy/kb.gbapp/dialogs/MenuDialog.ts +++ b/deploy/kb.gbapp/dialogs/MenuDialog.ts @@ -32,24 +32,14 @@ "use strict"; -import { Length } from "sequelize-typescript"; -import { - CardAction, - HeroCard, - CardImage, - BotAdapter, - CardFactory, - MessageFactory -} from "botbuilder"; +const UrlJoin = require("url-join"); + +import { BotAdapter, CardFactory, MessageFactory } from "botbuilder"; import { IGBDialog } from "botlib"; import { GBMinInstance } from "botlib"; -import { AzureText } from "pragmatismo-io-framework"; import { GuaribasSubject } from '../models'; import { KBService } from "../services/KBService"; -const UrlJoin = require("url-join"); -const WaitUntil = require("wait-until"); - export class MenuDialog extends IGBDialog { /** @@ -66,21 +56,21 @@ export class MenuDialog extends IGBDialog { min.dialogs.add("/menu", [ async (dc, args) => { var rootSubjectId = null; - var botId = min.botId; // var msg = dc.message; TODO: message from Where in V4? // if (msg.attachments && msg.attachments.length > 0) { // var attachment = msg.attachments[0]; // } - if (args && args.data) { var subject = JSON.parse(args.data); // ? + // If there is a shortcut specified as subject destination, go there. + if (subject.to) { let dialog = subject.to.split(":")[1]; - dc.replace("/" + dialog); - dc.end(); + await dc.replace("/" + dialog); + await dc.end(); return; } const user = min.userState.get(dc.context); @@ -88,7 +78,6 @@ export class MenuDialog extends IGBDialog { rootSubjectId = subject.subjectId; if (user.subjects.length > 0) { - let data = await service.getFaqBySubjectArray("menu", user.subjects); await min.conversationalService.sendEvent(dc, "play", { playerType: "bullet", @@ -100,39 +89,27 @@ export class MenuDialog extends IGBDialog { const user = min.userState.get(dc.context); user.subjects = []; - WaitUntil() - .interval(2000) - .times(1) - .condition(function (cb) { - return false; - }) - .done(function (result) { - let messages = [ - "Aqui estão algumas categorias de assuntos...", - "Selecionando o assunto você pode me ajudar a encontrar a resposta certa...", - "Você pode selecionar algum dos assuntos abaixo e perguntar algo..." - ]; - dc.context.sendActivity(messages[0]); // TODO: Handle rnd. - }); - + let messages = [ + "Aqui estão algumas categorias de assuntos...", + "Selecionando o assunto você pode me ajudar a encontrar a resposta certa...", + "Você pode selecionar algum dos assuntos abaixo e perguntar algo..." + ]; + await dc.context.sendActivity(messages[0]); // TODO: Handle rnd. user.isAsking = false; } - const msg = MessageFactory.text('Greetings from example message'); + const msg = MessageFactory.text(''); var attachments = []; let data = await service.getSubjectItems( min.instance.instanceId, rootSubjectId); - msg.attachmentLayout = 'carousel'; - data.forEach(function (item: GuaribasSubject) { var subject = item; - var card = CardFactory.heroCard( subject.title, CardFactory.images([UrlJoin( @@ -177,10 +154,10 @@ export class MenuDialog extends IGBDialog { }, async (dc, value) => { var text = value; - if (text==="no"||text==="n") { // TODO: Migrate to a common. - dc.replace("/feedback"); + if (text === "no" || text === "n") { // TODO: Migrate to a common. + await dc.replace("/feedback"); } else { - dc.replace("/ask"); + await dc.replace("/ask"); } } ]);