react downgraded to 15.5.0 due to https://github.com/Microsoft/BotFramework-WebChat/issues/970.
Promises revised.
This commit is contained in:
parent
c31671f3b4
commit
bd03cfbc6c
6 changed files with 48 additions and 65 deletions
|
@ -51,17 +51,17 @@ export class WhoAmIDialog extends IGBDialog {
|
||||||
|
|
||||||
min.dialogs.add("/whoAmI", [
|
min.dialogs.add("/whoAmI", [
|
||||||
async (dc, args) => {
|
async (dc, args) => {
|
||||||
dc.context.sendActivity(`${min.instance.description}`);
|
await dc.context.sendActivity(`${min.instance.description}`);
|
||||||
|
|
||||||
if (min.instance.whoAmIVideo) {
|
if (min.instance.whoAmIVideo) {
|
||||||
dc.context.sendActivity(`Vou te mostrar um vídeo. Por favor, aguarde...`);
|
await dc.context.sendActivity(`Vou te mostrar um vídeo. Por favor, aguarde...`);
|
||||||
min.conversationalService.sendEvent(dc, "play", {
|
await min.conversationalService.sendEvent(dc, "play", {
|
||||||
playerType: "video",
|
playerType: "video",
|
||||||
data: min.instance.whoAmIVideo.trim()
|
data: min.instance.whoAmIVideo.trim()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.replace('/ask', {isReturning: true});
|
await dc.replace('/ask', { isReturning: true });
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -236,8 +236,14 @@ export class GBMinService {
|
||||||
}, this);
|
}, 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) => {
|
return adapter.processActivity(req, res, async (context) => {
|
||||||
|
|
||||||
const state = conversationState.get(context);
|
const state = conversationState.get(context);
|
||||||
const dc = min.dialogs.createContext(context, state);
|
const dc = min.dialogs.createContext(context, state);
|
||||||
const user = min.userState.get(dc.context);
|
const user = min.userState.get(dc.context);
|
||||||
|
|
|
@ -76,7 +76,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
"Sugestões melhoram muito minha qualidade...",
|
"Sugestões melhoram muito minha qualidade...",
|
||||||
"Obrigado pela sua iniciativa de sugestão."
|
"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 = [
|
let messages = [
|
||||||
|
@ -89,13 +89,13 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
async (dc, value) => {
|
async (dc, value) => {
|
||||||
let rate = await AzureText.getSentiment(min.instance.textAnalyticsKey, "pt-br", value);
|
let rate = await AzureText.getSentiment(min.instance.textAnalyticsKey, "pt-br", value);
|
||||||
if (rate > 0) {
|
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 {
|
} else {
|
||||||
dc.context.sendActivity(
|
await dc.context.sendActivity(
|
||||||
"Vamos registrar sua questão, obrigado pela sinceridade."
|
"Vamos registrar sua questão, obrigado pela sinceridade."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
dc.replace('/ask', { isReturning: true });
|
await dc.replace('/ask', { isReturning: true });
|
||||||
}]);
|
}]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ajv": "^6.5.3",
|
"ajv": "^6.5.3",
|
||||||
"botframework-webchat": "^0.14.2",
|
"botframework-webchat": "^0.12.0",
|
||||||
"deep-extend": "^0.6.0",
|
"deep-extend": "^0.6.0",
|
||||||
"fetch": "^1.1.0",
|
"fetch": "^1.1.0",
|
||||||
"msal": "^0.2.2",
|
"msal": "^0.2.2",
|
||||||
"react": "^16.4.2",
|
"react": "^15.5.0",
|
||||||
"react-dom": "^16.4.2",
|
"react-dom": "^15.5.0",
|
||||||
"react-helmet": "^5.2.0",
|
"react-helmet": "^5.2.0",
|
||||||
"react-player": "^1.6.4",
|
"react-player": "^1.6.4",
|
||||||
"react-powerbi": "^0.2.1",
|
"react-powerbi": "^0.2.1",
|
||||||
|
|
|
@ -126,7 +126,7 @@ export class AskDialog extends IGBDialog {
|
||||||
|
|
||||||
// Goes to ask loop, again.
|
// Goes to ask loop, again.
|
||||||
|
|
||||||
dc.replace("/ask", { isReturning: true });
|
await dc.replace("/ask", { isReturning: true });
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -176,8 +176,8 @@ export class AskDialog extends IGBDialog {
|
||||||
"Desculpe-me, não achei nada parecido. Poderia tentar escrever de outra forma?"
|
"Desculpe-me, não achei nada parecido. Poderia tentar escrever de outra forma?"
|
||||||
];
|
];
|
||||||
|
|
||||||
dc.context.sendActivity(messages[0]); // TODO: Handle rnd.
|
await dc.context.sendActivity(messages[0]); // TODO: Handle rnd.
|
||||||
dc.replace("/ask", { isReturning: true });
|
await dc.replace("/ask", { isReturning: true });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,8 +212,8 @@ export class AskDialog extends IGBDialog {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async (dc, value) => {
|
async (dc, value) => {
|
||||||
dc.endAll();
|
await dc.endAll();
|
||||||
dc.begin("/answer", { query: value });
|
await dc.begin("/answer", { query: value });
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,24 +32,14 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
import { Length } from "sequelize-typescript";
|
const UrlJoin = require("url-join");
|
||||||
import {
|
|
||||||
CardAction,
|
import { BotAdapter, CardFactory, MessageFactory } from "botbuilder";
|
||||||
HeroCard,
|
|
||||||
CardImage,
|
|
||||||
BotAdapter,
|
|
||||||
CardFactory,
|
|
||||||
MessageFactory
|
|
||||||
} from "botbuilder";
|
|
||||||
import { IGBDialog } from "botlib";
|
import { IGBDialog } from "botlib";
|
||||||
import { GBMinInstance } from "botlib";
|
import { GBMinInstance } from "botlib";
|
||||||
import { AzureText } from "pragmatismo-io-framework";
|
|
||||||
import { GuaribasSubject } from '../models';
|
import { GuaribasSubject } from '../models';
|
||||||
import { KBService } from "../services/KBService";
|
import { KBService } from "../services/KBService";
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
|
||||||
const WaitUntil = require("wait-until");
|
|
||||||
|
|
||||||
export class MenuDialog extends IGBDialog {
|
export class MenuDialog extends IGBDialog {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,21 +56,21 @@ export class MenuDialog extends IGBDialog {
|
||||||
min.dialogs.add("/menu", [
|
min.dialogs.add("/menu", [
|
||||||
async (dc, args) => {
|
async (dc, args) => {
|
||||||
var rootSubjectId = null;
|
var rootSubjectId = null;
|
||||||
var botId = min.botId;
|
|
||||||
|
|
||||||
// var msg = dc.message; TODO: message from Where in V4?
|
// var msg = dc.message; TODO: message from Where in V4?
|
||||||
// if (msg.attachments && msg.attachments.length > 0) {
|
// if (msg.attachments && msg.attachments.length > 0) {
|
||||||
// var attachment = msg.attachments[0];
|
// var attachment = msg.attachments[0];
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
if (args && args.data) {
|
if (args && args.data) {
|
||||||
var subject = JSON.parse(args.data); // ?
|
var subject = JSON.parse(args.data); // ?
|
||||||
|
|
||||||
|
// If there is a shortcut specified as subject destination, go there.
|
||||||
|
|
||||||
if (subject.to) {
|
if (subject.to) {
|
||||||
let dialog = subject.to.split(":")[1];
|
let dialog = subject.to.split(":")[1];
|
||||||
dc.replace("/" + dialog);
|
await dc.replace("/" + dialog);
|
||||||
dc.end();
|
await dc.end();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const user = min.userState.get(dc.context);
|
const user = min.userState.get(dc.context);
|
||||||
|
@ -88,7 +78,6 @@ export class MenuDialog extends IGBDialog {
|
||||||
rootSubjectId = subject.subjectId;
|
rootSubjectId = subject.subjectId;
|
||||||
|
|
||||||
if (user.subjects.length > 0) {
|
if (user.subjects.length > 0) {
|
||||||
|
|
||||||
let data = await service.getFaqBySubjectArray("menu", user.subjects);
|
let data = await service.getFaqBySubjectArray("menu", user.subjects);
|
||||||
await min.conversationalService.sendEvent(dc, "play", {
|
await min.conversationalService.sendEvent(dc, "play", {
|
||||||
playerType: "bullet",
|
playerType: "bullet",
|
||||||
|
@ -100,39 +89,27 @@ export class MenuDialog extends IGBDialog {
|
||||||
const user = min.userState.get(dc.context);
|
const user = min.userState.get(dc.context);
|
||||||
user.subjects = [];
|
user.subjects = [];
|
||||||
|
|
||||||
WaitUntil()
|
|
||||||
.interval(2000)
|
|
||||||
.times(1)
|
|
||||||
.condition(function (cb) {
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.done(function (result) {
|
|
||||||
let messages = [
|
let messages = [
|
||||||
"Aqui estão algumas categorias de assuntos...",
|
"Aqui estão algumas categorias de assuntos...",
|
||||||
"Selecionando o assunto você pode me ajudar a encontrar a resposta certa...",
|
"Selecionando o assunto você pode me ajudar a encontrar a resposta certa...",
|
||||||
"Você pode selecionar algum dos assuntos abaixo e perguntar algo..."
|
"Você pode selecionar algum dos assuntos abaixo e perguntar algo..."
|
||||||
];
|
];
|
||||||
dc.context.sendActivity(messages[0]); // TODO: Handle rnd.
|
await dc.context.sendActivity(messages[0]); // TODO: Handle rnd.
|
||||||
});
|
|
||||||
|
|
||||||
user.isAsking = false;
|
user.isAsking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg = MessageFactory.text('Greetings from example message');
|
const msg = MessageFactory.text('');
|
||||||
var attachments = [];
|
var attachments = [];
|
||||||
|
|
||||||
let data = await service.getSubjectItems(
|
let data = await service.getSubjectItems(
|
||||||
min.instance.instanceId,
|
min.instance.instanceId,
|
||||||
rootSubjectId);
|
rootSubjectId);
|
||||||
|
|
||||||
|
|
||||||
msg.attachmentLayout = 'carousel';
|
msg.attachmentLayout = 'carousel';
|
||||||
|
|
||||||
|
|
||||||
data.forEach(function (item: GuaribasSubject) {
|
data.forEach(function (item: GuaribasSubject) {
|
||||||
|
|
||||||
var subject = item;
|
var subject = item;
|
||||||
|
|
||||||
var card = CardFactory.heroCard(
|
var card = CardFactory.heroCard(
|
||||||
subject.title,
|
subject.title,
|
||||||
CardFactory.images([UrlJoin(
|
CardFactory.images([UrlJoin(
|
||||||
|
@ -178,9 +155,9 @@ export class MenuDialog extends IGBDialog {
|
||||||
async (dc, value) => {
|
async (dc, value) => {
|
||||||
var text = value;
|
var text = value;
|
||||||
if (text === "no" || text === "n") { // TODO: Migrate to a common.
|
if (text === "no" || text === "n") { // TODO: Migrate to a common.
|
||||||
dc.replace("/feedback");
|
await dc.replace("/feedback");
|
||||||
} else {
|
} else {
|
||||||
dc.replace("/ask");
|
await dc.replace("/ask");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Reference in a new issue