2018-04-21 02:59:30 -03:00
|
|
|
/*****************************************************************************\
|
2024-01-09 17:40:48 -03:00
|
|
|
| █████ █████ ██ █ █████ █████ ████ ██ ████ █████ █████ ███ ® |
|
|
|
|
| ██ █ ███ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
|
|
|
|
| ██ ███ ████ █ ██ █ ████ █████ ██████ ██ ████ █ █ █ ██ |
|
|
|
|
| ██ ██ █ █ ██ █ █ ██ ██ ██ ██ ██ ██ █ ██ ██ █ █ |
|
|
|
|
| █████ █████ █ ███ █████ ██ ██ ██ ██ █████ ████ █████ █ ███ |
|
2018-04-21 02:59:30 -03:00
|
|
|
| |
|
2024-01-10 15:01:02 -03:00
|
|
|
| General Bots Copyright (c) pragmatismo.com.br. All rights reserved. |
|
2018-04-21 02:59:30 -03:00
|
|
|
| Licensed under the AGPL-3.0. |
|
2018-11-11 19:09:18 -02:00
|
|
|
| |
|
2018-04-21 02:59:30 -03:00
|
|
|
| According to our dual licensing model, this program can be used either |
|
|
|
|
| under the terms of the GNU Affero General Public License, version 3, |
|
|
|
|
| or under a proprietary license. |
|
|
|
|
| |
|
|
|
|
| The texts of the GNU Affero General Public License with an additional |
|
|
|
|
| permission and of our proprietary license can be found at and |
|
|
|
|
| in the LICENSE file you have received along with this program. |
|
|
|
|
| |
|
|
|
|
| This program is distributed in the hope that it will be useful, |
|
2018-09-11 19:40:53 -03:00
|
|
|
| but WITHOUT ANY WARRANTY, without even the implied warranty of |
|
2018-04-21 02:59:30 -03:00
|
|
|
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
|
| GNU Affero General Public License for more details. |
|
|
|
|
| |
|
2024-01-10 14:52:01 -03:00
|
|
|
| "General Bots" is a registered trademark of pragmatismo.com.br. |
|
2018-04-21 02:59:30 -03:00
|
|
|
| The licensing of the program under the AGPLv3 does not imply a |
|
|
|
|
| trademark license. Therefore any rights, title and interest in |
|
|
|
|
| our trademarks remain entirely with us. |
|
|
|
|
| |
|
|
|
|
\*****************************************************************************/
|
|
|
|
|
2018-11-11 19:09:18 -02:00
|
|
|
/**
|
|
|
|
* @fileoverview General Bots server core.
|
|
|
|
*/
|
|
|
|
|
|
|
|
'use strict';
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2022-11-18 22:39:14 -03:00
|
|
|
import { GBServer } from '../../../src/app.js';
|
2018-11-12 12:20:44 -02:00
|
|
|
import { BotAdapter } from 'botbuilder';
|
|
|
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
2022-12-15 23:03:20 -03:00
|
|
|
import { ChatGPTAPIBrowser } from 'chatgpt';
|
2020-07-26 16:46:37 -03:00
|
|
|
import { GBLog, GBMinInstance, IGBDialog, IGBPackage } from 'botlib';
|
2022-11-18 22:39:14 -03:00
|
|
|
import { Messages } from '../strings.js';
|
|
|
|
import { KBService } from './../services/KBService.js';
|
|
|
|
import { GuaribasAnswer } from '../models/index.js';
|
|
|
|
import { SecService } from '../../security.gbapp/services/SecService.js';
|
2020-07-26 16:46:37 -03:00
|
|
|
import { CollectionUtil, AzureText } from 'pragmatismo-io-framework';
|
2022-11-18 22:39:14 -03:00
|
|
|
import { GBVMService } from '../../basic.gblib/services/GBVMService.js';
|
|
|
|
import { GBImporter } from '../../core.gbapp/services/GBImporterService.js';
|
|
|
|
import { GBDeployer } from '../../core.gbapp/services/GBDeployer.js';
|
|
|
|
import { GBConfigService } from '../../core.gbapp/services/GBConfigService.js';
|
2023-04-09 19:20:15 -03:00
|
|
|
import Fs from 'fs';
|
|
|
|
import urlJoin from 'url-join';
|
|
|
|
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords.js';
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
/**
|
|
|
|
* Dialog arguments.
|
|
|
|
*/
|
|
|
|
export class AskDialogArgs {
|
|
|
|
public questionId: number;
|
|
|
|
public fromFaq: boolean;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the ask loop on knowledge base data or delegate to other services.
|
|
|
|
*/
|
2018-04-21 02:59:30 -03:00
|
|
|
export class AskDialog extends IGBDialog {
|
2020-08-29 15:02:19 -03:00
|
|
|
static deployer: any;
|
2018-09-09 14:39:37 -03:00
|
|
|
/**
|
|
|
|
* Setup dialogs flows and define services call.
|
2018-09-14 12:56:54 -03:00
|
|
|
*
|
2018-09-09 14:39:37 -03:00
|
|
|
* @param bot The bot adapter.
|
|
|
|
* @param min The minimal bot instance data.
|
|
|
|
*/
|
2022-12-15 23:03:20 -03:00
|
|
|
public static setup(bot: BotAdapter, min: GBMinInstance) {
|
2018-09-14 12:56:54 -03:00
|
|
|
const service = new KBService(min.core.sequelize);
|
2020-08-29 15:02:19 -03:00
|
|
|
const importer = new GBImporter(min.core);
|
|
|
|
this.deployer = new GBDeployer(min.core, importer);
|
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
min.dialogs.add(new WaterfallDialog('/answerEvent', AskDialog.getAnswerEventDialog(service, min)));
|
|
|
|
min.dialogs.add(new WaterfallDialog('/answer', AskDialog.getAnswerDialog(min, service)));
|
|
|
|
min.dialogs.add(new WaterfallDialog('/ask', AskDialog.getAskDialog(min)));
|
2023-04-09 19:20:15 -03:00
|
|
|
min.dialogs.add(new WaterfallDialog('/dialog', AskDialog.getLLVMDialog(min, service)));
|
2019-03-09 16:59:31 -03:00
|
|
|
}
|
2018-04-21 02:59:30 -03:00
|
|
|
|
2022-12-15 23:03:20 -03:00
|
|
|
private static getAskDialog(min: GBMinInstance) {
|
2019-03-09 16:59:31 -03:00
|
|
|
return [
|
|
|
|
async step => {
|
2021-05-10 10:53:53 -03:00
|
|
|
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
|
|
|
|
return await step.beginDialog('/auth');
|
2022-11-19 23:34:58 -03:00
|
|
|
} else {
|
2021-05-10 10:53:53 -03:00
|
|
|
return await step.next(step.options);
|
|
|
|
}
|
|
|
|
},
|
2021-05-23 16:42:54 -03:00
|
|
|
async step => {
|
2019-03-09 16:59:31 -03:00
|
|
|
const locale = step.context.activity.locale;
|
|
|
|
const user = await min.userProfile.get(step.context, {});
|
|
|
|
user.isAsking = true;
|
|
|
|
if (!user.subjects) {
|
|
|
|
user.subjects = [];
|
|
|
|
}
|
2021-05-23 10:43:39 -03:00
|
|
|
let text: string;
|
2023-03-08 12:01:02 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
// Three forms of asking.
|
2023-03-08 12:01:02 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
if (step.options && step.options.firstTime) {
|
|
|
|
text = Messages[locale].ask_first_time;
|
2023-08-21 13:21:49 -03:00
|
|
|
} else if (step.options && step.options.isReturning && !step.context.activity.group) {
|
2023-08-10 22:28:59 -03:00
|
|
|
const askForMore = min.core.getParam(min.instance, 'Ask For More', null);
|
2024-02-16 21:26:11 -03:00
|
|
|
if (askForMore) {
|
|
|
|
text = askForMore;
|
2023-09-03 16:46:40 -03:00
|
|
|
}
|
2024-02-16 21:26:11 -03:00
|
|
|
else {
|
2023-08-10 22:28:59 -03:00
|
|
|
|
2023-09-03 16:46:40 -03:00
|
|
|
return await step.endDialog(null);
|
|
|
|
}
|
2023-08-21 13:21:49 -03:00
|
|
|
} else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
|
|
|
|
return await step.next();
|
2019-03-09 16:59:31 -03:00
|
|
|
} else if (user.subjects.length > 0) {
|
|
|
|
text = Messages[locale].which_question;
|
|
|
|
} else {
|
|
|
|
throw new Error('Invalid use of /ask');
|
|
|
|
}
|
2021-05-23 16:42:54 -03:00
|
|
|
|
2021-04-02 14:50:39 -03:00
|
|
|
return await min.conversationalService.prompt(min, step, text);
|
2019-03-09 16:59:31 -03:00
|
|
|
},
|
|
|
|
async step => {
|
|
|
|
if (step.result) {
|
2020-10-30 10:08:59 -03:00
|
|
|
let text = step.result;
|
2020-11-17 08:27:10 -03:00
|
|
|
text = text.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi, '');
|
2020-05-27 23:01:44 -03:00
|
|
|
|
2020-05-17 21:30:21 +00:00
|
|
|
let sec = new SecService();
|
|
|
|
const member = step.context.activity.from;
|
2022-11-19 23:34:58 -03:00
|
|
|
const user = await sec.ensureUser(
|
2024-02-05 12:36:20 -03:00
|
|
|
min,
|
2022-11-19 23:34:58 -03:00
|
|
|
member.id,
|
|
|
|
member.name,
|
|
|
|
'',
|
|
|
|
'web',
|
|
|
|
member.name,
|
|
|
|
null
|
|
|
|
);
|
2020-07-26 16:46:37 -03:00
|
|
|
|
|
|
|
let handled = false;
|
2021-01-03 18:29:41 -03:00
|
|
|
let nextDialog = null;
|
|
|
|
|
2021-07-29 12:21:05 -03:00
|
|
|
let data = {
|
|
|
|
query: text,
|
|
|
|
step: step,
|
|
|
|
message: text,
|
|
|
|
user: user ? user['dataValues'] : null
|
|
|
|
};
|
2020-07-26 16:46:37 -03:00
|
|
|
await CollectionUtil.asyncForEach(min.appPackages, async (e: IGBPackage) => {
|
2022-11-19 23:34:58 -03:00
|
|
|
if ((nextDialog = await e.onExchangeData(min, 'handleAnswer', data))) {
|
2020-07-26 16:46:37 -03:00
|
|
|
handled = true;
|
|
|
|
}
|
|
|
|
});
|
2023-08-21 13:21:49 -03:00
|
|
|
if (!handled) {
|
|
|
|
data.step = null;
|
|
|
|
GBLog.info(`/answer being called from getAskDialog.`);
|
|
|
|
await step.beginDialog(nextDialog ? nextDialog : '/answer', {
|
|
|
|
data: data,
|
|
|
|
query: text,
|
|
|
|
user: user ? user['dataValues'] : null,
|
|
|
|
message: text
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
return await step.next();
|
|
|
|
}
|
2019-03-09 16:59:31 -03:00
|
|
|
} else {
|
2018-11-04 09:19:03 -02:00
|
|
|
return await step.next();
|
2018-09-10 16:24:32 -03:00
|
|
|
}
|
2019-03-09 16:59:31 -03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2018-08-28 17:50:19 -03:00
|
|
|
|
2022-12-15 23:03:20 -03:00
|
|
|
private static getAnswerDialog(min: GBMinInstance, service: KBService) {
|
2019-03-09 16:59:31 -03:00
|
|
|
return [
|
|
|
|
async step => {
|
2021-05-10 10:53:53 -03:00
|
|
|
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
|
|
|
|
return await step.beginDialog('/auth');
|
2022-11-19 23:34:58 -03:00
|
|
|
} else {
|
2021-05-10 10:53:53 -03:00
|
|
|
return await step.next(step.options);
|
|
|
|
}
|
|
|
|
},
|
2021-05-23 16:42:54 -03:00
|
|
|
async step => {
|
2020-11-17 08:27:10 -03:00
|
|
|
let answer: GuaribasAnswer = null;
|
2023-02-22 16:06:57 -03:00
|
|
|
const member = step.context.activity.from;
|
|
|
|
const sec = new SecService();
|
2024-02-05 12:36:20 -03:00
|
|
|
let user = await sec.ensureUser(min, member.id, member.name, '', 'web', member.name, null);
|
2020-05-17 21:30:21 +00:00
|
|
|
|
2020-05-30 19:30:11 -03:00
|
|
|
const minBoot = GBServer.globals.minBoot as any;
|
2020-10-30 08:36:15 -03:00
|
|
|
|
2020-11-17 08:27:10 -03:00
|
|
|
let text = step.options.query;
|
|
|
|
text = text.replace(/<([^>]+?)([^>]*?)>(.*?)<\/\1>/gi, '');
|
2021-02-07 18:28:54 -03:00
|
|
|
|
2021-01-24 08:33:10 -03:00
|
|
|
// When no text is typed, the start dialog is invoked again
|
|
|
|
// when people type just the @botName in MSTEAMS for example.
|
|
|
|
|
2023-07-09 06:51:10 -03:00
|
|
|
if (!text && step.context.activity.channelId === 'msteams') {
|
2022-11-19 23:34:58 -03:00
|
|
|
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
|
2021-05-23 16:42:54 -03:00
|
|
|
if (startDialog) {
|
2024-03-04 20:05:56 -03:00
|
|
|
const pid = step.context.activity['pid'];
|
|
|
|
await GBVMService.callVM(startDialog.toLowerCase().trim(), min, step, pid);
|
2021-05-23 16:42:54 -03:00
|
|
|
}
|
2021-01-24 08:33:10 -03:00
|
|
|
|
2023-07-26 13:27:15 -03:00
|
|
|
return await step.endDialog();
|
2019-03-09 16:59:31 -03:00
|
|
|
}
|
2021-02-07 18:28:54 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
const locale = step.context.activity.locale;
|
2020-11-17 08:27:10 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
// Stops any content on projector.
|
2022-04-26 15:13:19 -03:00
|
|
|
if (step.context.activity.channelId !== 'msteams') {
|
2022-11-19 23:34:58 -03:00
|
|
|
await min.conversationalService.sendEvent(min, step, 'stop', undefined);
|
2022-04-26 15:13:19 -03:00
|
|
|
}
|
2019-03-09 16:59:31 -03:00
|
|
|
// Handle extra text from FAQ.
|
2020-11-17 08:27:10 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
if (step.options && step.options.query) {
|
|
|
|
text = step.options.query;
|
|
|
|
} else if (step.options && step.options.fromFaq) {
|
2020-05-17 21:30:21 +00:00
|
|
|
await min.conversationalService.sendText(min, step, Messages[locale].going_answer);
|
2019-03-09 16:59:31 -03:00
|
|
|
}
|
2018-08-28 17:50:19 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
// Searches KB for the first time.
|
2020-11-17 08:27:10 -03:00
|
|
|
|
2022-11-19 23:34:58 -03:00
|
|
|
const searchScore = min.core.getParam(
|
|
|
|
min.instance,
|
|
|
|
'Search Score',
|
|
|
|
min.instance.searchScore ? min.instance.searchScore : minBoot.instance.searchScore
|
|
|
|
);
|
2020-12-06 16:22:34 -03:00
|
|
|
|
2024-03-09 14:02:17 -03:00
|
|
|
const results = await service.ask(min,step.context.activity['pid'], text, searchScore, null /* user.subjects */);
|
2018-08-28 17:50:19 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
// If there is some result, answer immediately.
|
2020-11-17 08:27:10 -03:00
|
|
|
|
2024-03-09 14:02:17 -03:00
|
|
|
if (results !== undefined && results.answer !== undefined) {
|
2023-02-23 05:47:05 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
// Sends the answer to all outputs, including projector.
|
2019-08-24 12:22:52 -03:00
|
|
|
|
2024-03-09 14:02:17 -03:00
|
|
|
answer = results.answer;
|
2020-11-17 08:27:10 -03:00
|
|
|
|
2023-02-22 16:06:57 -03:00
|
|
|
return await AskDialog.handleAnswer(service, min, step, user, answer);
|
2021-08-31 15:40:21 -03:00
|
|
|
}
|
2021-07-16 08:12:58 -03:00
|
|
|
|
2024-03-09 14:02:17 -03:00
|
|
|
GBLog.info(`SEARCH called but NO answer could be found (zero results).`);
|
2021-08-31 15:40:21 -03:00
|
|
|
|
|
|
|
// Not found.
|
|
|
|
|
2022-11-19 23:34:58 -03:00
|
|
|
const message = min.core.getParam<string>(min.instance, 'Not Found Message', Messages[locale].did_not_find);
|
2021-08-31 15:40:21 -03:00
|
|
|
|
|
|
|
await min.conversationalService.sendText(min, step, message);
|
2024-03-09 14:02:17 -03:00
|
|
|
|
2021-08-31 15:40:21 -03:00
|
|
|
return await step.replaceDialog('/ask', { isReturning: true });
|
2019-03-09 16:59:31 -03:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2019-03-08 06:49:22 -03:00
|
|
|
|
2023-02-22 16:06:57 -03:00
|
|
|
private static async handleAnswer(service: KBService, min: GBMinInstance, step: any, user, answer: GuaribasAnswer) {
|
2024-02-16 21:26:11 -03:00
|
|
|
let text = typeof (answer) === 'string' ? answer : answer.content;
|
2020-11-06 17:06:22 -03:00
|
|
|
if (text.endsWith('.docx')) {
|
|
|
|
const mainName = GBVMService.getMethodNameFromVBSFilename(text);
|
2023-05-25 11:14:08 -03:00
|
|
|
await step.endDialog();
|
2024-03-04 20:05:56 -03:00
|
|
|
const pid = step.context.activity['pid'];
|
|
|
|
return await GBVMService.callVM(mainName, min, step, pid);
|
2023-08-21 13:21:49 -03:00
|
|
|
} else if (text.startsWith('/')) {
|
2023-07-25 08:00:43 -03:00
|
|
|
return await step.replaceDialog(text, { answer: answer });
|
2020-01-10 10:04:26 -03:00
|
|
|
} else {
|
2024-02-16 21:26:11 -03:00
|
|
|
await service.sendAnswer(min, AskDialog.getChannel(step), step, text);
|
2020-06-05 14:40:21 -03:00
|
|
|
return await step.replaceDialog('/ask', { isReturning: true });
|
2020-01-10 10:04:26 -03:00
|
|
|
}
|
|
|
|
}
|
2024-02-17 20:33:08 -03:00
|
|
|
|
2022-12-15 23:03:20 -03:00
|
|
|
private static getChannel(step): string {
|
2021-05-09 19:19:44 -03:00
|
|
|
return !isNaN(step.context.activity['mobile']) ? 'whatsapp' : step.context.activity.channelId;
|
2019-08-24 12:22:52 -03:00
|
|
|
}
|
|
|
|
|
2022-12-15 23:03:20 -03:00
|
|
|
private static getAnswerEventDialog(service: KBService, min: GBMinInstance) {
|
2019-03-09 16:59:31 -03:00
|
|
|
return [
|
2021-05-10 10:53:53 -03:00
|
|
|
async step => {
|
|
|
|
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
|
|
|
|
return await step.beginDialog('/auth');
|
2022-11-19 23:34:58 -03:00
|
|
|
} else {
|
2021-05-10 10:53:53 -03:00
|
|
|
return await step.next(step.options);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
async step => {
|
|
|
|
const data = step.options as AskDialogArgs;
|
|
|
|
if (data !== undefined && data.questionId !== undefined) {
|
|
|
|
const question = await service.getQuestionById(min.instance.instanceId, data.questionId);
|
2022-11-19 23:34:58 -03:00
|
|
|
const answer = await service.getAnswerById(min.instance.instanceId, question.answerId);
|
2019-03-09 16:59:31 -03:00
|
|
|
// Sends the answer to all outputs, including projector.
|
2019-08-24 18:46:04 -03:00
|
|
|
await service.sendAnswer(min, AskDialog.getChannel(step), step, answer);
|
2019-03-09 16:59:31 -03:00
|
|
|
await step.replaceDialog('/ask', { isReturning: true });
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
2019-02-28 15:15:51 -03:00
|
|
|
|
2019-03-09 16:59:31 -03:00
|
|
|
return await step.next();
|
|
|
|
}
|
|
|
|
];
|
2018-04-21 02:59:30 -03:00
|
|
|
}
|
2023-04-09 19:20:15 -03:00
|
|
|
|
|
|
|
private static getLLVMDialog(min: GBMinInstance, service: KBService) {
|
|
|
|
return [
|
|
|
|
async step => {
|
|
|
|
if (step.context.activity.channelId !== 'msteams' && process.env.ENABLE_AUTH) {
|
|
|
|
return await step.beginDialog('/auth');
|
|
|
|
} else {
|
|
|
|
return await step.next(step.options);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
async step => {
|
|
|
|
return await min.conversationalService.prompt(min, step, 'Please, describe the dialog scene.');
|
|
|
|
},
|
|
|
|
async step => {
|
|
|
|
step.options.dialog = step.result;
|
|
|
|
return await min.conversationalService.prompt(min, step, 'How would you call this?');
|
|
|
|
},
|
|
|
|
async step => {
|
|
|
|
if (GBServer.globals.chatGPT) {
|
|
|
|
let input = `Write a BASIC program that ${step.options.dialog.toLowerCase()}. And does not explain.`;
|
2023-05-25 21:20:40 -03:00
|
|
|
|
2023-04-09 19:20:15 -03:00
|
|
|
await min.conversationalService.sendText(min, step, 'Thank you. The dialog is being written right now...');
|
|
|
|
|
|
|
|
const CHATGPT_TIMEOUT = 3 * 60 * 1000;
|
|
|
|
GBLog.info(`ChatGPT Code: ${input}`);
|
|
|
|
let response = await GBServer.globals.chatGPT.sendMessage(input, {
|
|
|
|
timeoutMs: CHATGPT_TIMEOUT
|
2023-05-25 21:20:40 -03:00
|
|
|
});
|
2023-04-09 19:20:15 -03:00
|
|
|
|
|
|
|
// Removes instructions, just code.
|
|
|
|
|
|
|
|
response = response.replace(/Copy code/gim, '\n');
|
2023-08-21 13:21:49 -03:00
|
|
|
let lines = response.split('\n');
|
|
|
|
let filteredLines = lines.filter(line => /\s*\d+\s*.*/.test(line));
|
2023-04-09 19:20:15 -03:00
|
|
|
response = filteredLines.join('\n');
|
|
|
|
|
|
|
|
// Gets dialog name and file handling
|
|
|
|
|
2023-05-25 21:20:40 -03:00
|
|
|
let dialogName = step.result.replace('.', '');
|
2023-04-09 19:20:15 -03:00
|
|
|
const docx = urlJoin(`${min.botId}.gbdialog`, `${dialogName}.docx`);
|
|
|
|
const sys = new SystemKeywords();
|
|
|
|
const document = await sys.internalCreateDocument(min, docx, response);
|
2023-05-25 21:20:40 -03:00
|
|
|
await service.addQA(min, dialogName, dialogName);
|
2023-04-09 19:20:15 -03:00
|
|
|
|
|
|
|
let message = `Waiting for publishing...`;
|
|
|
|
await min.conversationalService.sendText(min, step, message);
|
|
|
|
|
|
|
|
await step.replaceDialog('/publish', { confirm: true });
|
2023-05-25 21:20:40 -03:00
|
|
|
|
2023-04-09 19:20:15 -03:00
|
|
|
message = `Dialog is ready! Let's run:`;
|
|
|
|
await min.conversationalService.sendText(min, step, message);
|
|
|
|
|
|
|
|
let sec = new SecService();
|
|
|
|
const member = step.context.activity.from;
|
|
|
|
const user = await sec.ensureUser(
|
2024-02-05 12:36:20 -03:00
|
|
|
min,
|
2023-04-09 19:20:15 -03:00
|
|
|
member.id,
|
|
|
|
member.name,
|
|
|
|
'',
|
|
|
|
'web',
|
|
|
|
member.name,
|
|
|
|
null
|
|
|
|
);
|
|
|
|
|
|
|
|
await step.endDialog();
|
2024-03-04 20:05:56 -03:00
|
|
|
const pid = step.context.activity['pid'];
|
2023-04-09 19:20:15 -03:00
|
|
|
|
2024-03-04 20:05:56 -03:00
|
|
|
await GBVMService.callVM(dialogName.toLowerCase(), min, step, pid);
|
2023-04-09 19:20:15 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|
2019-05-25 15:22:51 -03:00
|
|
|
}
|