diff --git a/VERSION.md b/VERSION.md index 862fd4ac..9fb62197 100644 --- a/VERSION.md +++ b/VERSION.md @@ -1,7 +1,20 @@ +## Version 0.0.23 + +- FIX: Duplicated asking on main loop removed. +- FIX: Whatsapp log phrase correction. +- FIX: Directline can now receive messages sent in not-in-conversation, projector-only fashion. + +## Version 0.0.22 + +- NEW: Auto-dispatch to dialog based on intent name. + +## Version 0.0.21 + +- FIX: Whatsapp directline client improved. + ## Version 0.0.20 - NEW: Whatsapp directline client is now working in preview. -- NEW: Auto-dispatch to dialog based on intent name. ## Version 0.0.19 diff --git a/deploy/kb.gbapp/dialogs/AskDialog.ts b/deploy/kb.gbapp/dialogs/AskDialog.ts index 54edc949..5511dca9 100644 --- a/deploy/kb.gbapp/dialogs/AskDialog.ts +++ b/deploy/kb.gbapp/dialogs/AskDialog.ts @@ -33,7 +33,7 @@ "use strict"; import { Prompts, UniversalBot, Session, ListStyle } from "botbuilder"; -import { IGBDialog } from "botlib"; +import { IGBDialog } from "botlib"; import { AzureText } from "pragmatismo-io-framework"; import { GBMinInstance } from "botlib"; import { KBService } from './../services/KBService'; @@ -63,10 +63,6 @@ export class AskDialog extends IGBDialog { if (text === "") { session.replaceDialog("/ask"); - } else if (AzureText.isIntentNo(text)) { - session.replaceDialog("/feedback"); - } else if (AzureText.isIntentYes(text)) { - session.replaceDialog("/menu"); } else { AzureText.getSpelledText( min.instance.spellcheckerKey, @@ -109,10 +105,10 @@ export class AskDialog extends IGBDialog { session.userData.isAsking = false; if (session.userData.subjects.length > 0) { - let subjectText = - `${KBService.getSubjectItemsSeparatedBySpaces( - session.userData.subjects - )}`; + let subjectText = + `${KBService.getSubjectItemsSeparatedBySpaces( + session.userData.subjects + )}`; let msgs = [ `Respondendo nao apenas sobre ${subjectText}... `, @@ -138,14 +134,13 @@ export class AskDialog extends IGBDialog { text, (data, error) => { - if (!data) - { + if (!data) { let msgs = [ "Desculpe-me, não encontrei nada a respeito.", "Lamento... Não encontrei nada sobre isso. Vamos tentar novamente?", "Desculpe-me, não achei nada parecido. Poderia tentar escrever de outra forma?" ]; - + session.send(msgs); session.replaceDialog("/ask", { isReturning: true }); } @@ -167,13 +162,6 @@ export class AskDialog extends IGBDialog { .dialog("/ask", [ (session, args) => { session.userData.isAsking = true; - - let text = [ - `Pergunte-me sobre qualquer assunto ou digite **menu** para conhecer uma lista de opções.`, - `Pode perguntar sobre qualquer assunto... Ou digita **menu** para conhecer uma lista de opções.`, - `Faça qualquer pergunta ou também posso te mostrar o **menu** de assuntos sempre que precisar...` - ]; - if (session.userData.subjects.length > 0) { text = [ `Faça sua pergunta...`, @@ -189,8 +177,9 @@ export class AskDialog extends IGBDialog { "Deseja fazer outra pergunta?" ]; } - - Prompts.text(session, text); + if (text.length > 0) { + Prompts.text(session, text); + } }, (session, results) => { session.replaceDialog("/answer", { query: results.response }); diff --git a/deploy/kb.gbapp/dialogs/MenuDialog.ts b/deploy/kb.gbapp/dialogs/MenuDialog.ts index 63784e34..556a3d94 100644 --- a/deploy/kb.gbapp/dialogs/MenuDialog.ts +++ b/deploy/kb.gbapp/dialogs/MenuDialog.ts @@ -180,10 +180,7 @@ export class MenuDialog extends IGBDialog { session.replaceDialog("/ask"); } } - ]) - .triggerAction({ - matches: /^(menu)/i - }); + ]); bot.beginDialogAction("menuAction", "/menu"); } diff --git a/deploy/kb.gbapp/services/KBService.ts b/deploy/kb.gbapp/services/KBService.ts index ae9cb4f7..3bcb7385 100644 --- a/deploy/kb.gbapp/services/KBService.ts +++ b/deploy/kb.gbapp/services/KBService.ts @@ -452,7 +452,7 @@ export class KBService { playerType: "video", data: answer.content }); - } else if (answer.content.length > 140) { + } else if (answer.content.length > 140 && session.message.source != "directline") { let msgs = [ "Vou te responder na tela para melhor visualização...", "A resposta está na tela...", diff --git a/deploy/whatsapp.gblib/services/WhatsappDirectLine.ts b/deploy/whatsapp.gblib/services/WhatsappDirectLine.ts index 1d745bb0..8ca02d13 100644 --- a/deploy/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/deploy/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -89,7 +89,8 @@ export class WhatsappDirectLine extends GBService { qs: { token: this.whatsappServiceKey, - webhookUrl: `${this.whatsappServiceWebhookUrl}/instances/${this.botId}/whatsapp` + webhookUrl: `${this.whatsappServiceWebhookUrl}/instances/${this.botId}/whatsapp`, + set: true }, headers: { @@ -101,7 +102,7 @@ export class WhatsappDirectLine extends GBService { const result = await request.post(options); logger.info(result); } catch (error) { - logger.error('Error initializing DirectLine client', error); + logger.error('Error initializing 3rd party Whatsapp provider.', error); } return client; @@ -177,7 +178,6 @@ export class WhatsappDirectLine extends GBService { } - pollMessages(client, conversationId, from, fromName) { logger.info(`GBWhatsapp: Starting polling message for conversationId: @@ -203,8 +203,8 @@ export class WhatsappDirectLine extends GBService { if (activities && activities.length) { // Ignore own messages. - - activities = activities.filter((m) => { return m.from.id === this.botId && m.type === "message" }); +// TODO: this.botId instead of "general-bot-9672a8d3" + activities = activities.filter((m) => { return m.from.id === "general-bot-9672a8d3" && m.type === "message" }); if (activities.length) { diff --git a/package.json b/package.json index d42c5708..11087953 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "botserver", - "version": "0.0.21", + "version": "0.0.23", "description": "General Bot Community Edition open-core server.", "contributors": [ "Rodrigo Rodriguez " @@ -30,34 +30,34 @@ }, "dependencies": { "@types/azure": "^0.9.19", - "@types/chai": "4.0.4", - "@types/mocha": "2.2.43", + "@types/chai": "4.1.3", + "@types/mocha": "5.2.0", "@types/url-join": "^0.8.2", - "async": "^1.5.2", + "async": "^2.6.0", "body-parser": "^1.18.2", - "botbuilder": "^3.14.0", - "botlib": "0.0.19", + "botbuilder": "^3.15.0", + "botlib": "0.0.23", "chai": "^4.1.2", "chokidar": "^2.0.2", "csv-parse": "^2.4.0", - "dotenv-extended": "^1.0.4", + "dotenv-extended": "^2.0.2", "express": "^4.16.2", - "fs-extra": "^5.0.0", - "fs-walk": "0.0.1", + "fs-extra": "^6.0.1", + "fs-walk": "0.0.2", "marked": "^0.3.12", - "mocha": "^3.5.3", + "mocha": "^5.1.1", "mocha-typescript": "^1.1.12", - "pragmatismo-io-framework": "^1.0.11", + "pragmatismo-io-framework": "^1.0.12", "reflect-metadata": "^0.1.12", "request-promise-native": "^1.0.5", "sequelize": "^4.37.6", "sequelize-typescript": "^0.6.3", "sqlite3": "^4.0.0", - "swagger-client": "^2.1.18", + "swagger-client": "^3.8.3", "tedious": "^2.1.1", - "ts-node": "3.3.0", - "typedoc": "^0.10.0", - "typescript": "2.7.2", + "ts-node": "6.0.3", + "typedoc": "^0.11.1", + "typescript": "2.8.3", "url-join": "^4.0.0", "wait-until": "0.0.2", "winston": "^2.4.0"