diff --git a/.env b/.env index d8f3822b..935c828f 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -ADMIN_PASS= -ADDITIONAL_DEPLOY_PATH= -DATABASE_DIALECT=sqlite -DATABASE_OBJECT_PREFIX=env1- -DATABASE_SYNC=false \ No newline at end of file +ADMIN_PASS=am!dslfkj82 +ADDITIONAL_DEPLOY_PATH=C:\Sources\pragmatismo.io\pgma-website +DATABASE_DIALECT= +DATABASE_OBJECT_PREFIX= +DATABASE_SYNC= \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index ab8fafb2..00000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "typescript", - "tsconfig": "tsconfig.json", - "problemMatcher": [ - "$tsc" - ], - "group": { - "kind": "build", - "isDefault": true - } - } - ] -} \ No newline at end of file diff --git a/README.md b/README.md index 064ae0c2..225745b1 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![General Bots Logo](https://github.com/pragmatismo-io/BotServer/blob/master/logo.png) +![General Bots Logo](//raw.githubusercontent.com/pragmatismo-io/BotServer/master/logo.png) Welcome to General Bots Community Edition! ------- @@ -29,6 +29,13 @@ Office tools like Word or Excel to edit your Bot - using code (JavaScript or Typ How To ------ +### Run the server + +1. `git clone https://github.com/pragmatismo-io/BotServer.git` or just download the files to a folder; +2. Run `npm install` on that folder; +3. Enter './deploy/default.gbui' folder and run `npm install` folled by `npm run build` (To build default Bot UI); +4. On the downloaded folder (../..), run the bot server by `npm start`. + ### Updating the Bot Knoledge Base (.gbkb folder) The subjects.json file contains all information related to the subject tree and can be used to build the menu carrousel as well give a set of words to be used as subject catcher in the conversation. A hierarchy can be specified. diff --git a/deploy/admin.gbapp/dialogs/AdminDialog.ts b/deploy/admin.gbapp/dialogs/AdminDialog.ts index c8cdc467..33127ada 100644 --- a/deploy/admin.gbapp/dialogs/AdminDialog.ts +++ b/deploy/admin.gbapp/dialogs/AdminDialog.ts @@ -150,8 +150,12 @@ export class AdminDialog extends IGBDialog { ) { let packageName = text.split(" ")[1]; session.send(`Deploying package ${packageName}... (It may take a few seconds)`); + + // TODO: Find packages in all posible locations. + let additionalPath = GBConfigService.get("ADDITIONAL_DEPLOY_PATH"); + deployer.deployPackageFromLocalPath( - UrlJoin("deploy", packageName), + UrlJoin(additionalPath, packageName), (data, err) => { session.send(`Package ${packageName} deployed... Please run rebuildIndex command.`); diff --git a/deploy/core.gbapp/services/GBMinService.ts b/deploy/core.gbapp/services/GBMinService.ts index ed9516bd..e053c33b 100644 --- a/deploy/core.gbapp/services/GBMinService.ts +++ b/deploy/core.gbapp/services/GBMinService.ts @@ -154,6 +154,9 @@ export class GBMinService { min.botId = instance.botId; min.core = _this.core; min.conversationalService = _this.conversationalService; + _this.core.loadInstance(min.botId, (data, err) => { + min.instance = data; + }); let connector = new gBuilder.ChatConnector({ appId: instance.marketplaceId, @@ -196,20 +199,20 @@ export class GBMinService { botbuilder: (session, next) => { if (!session.privateConversationData.loaded) { setTimeout( - () => - `Sending loading instance to client ${min.instance.ui}.`, - min.conversationalService.sendEvent( - session, - "loadInstance", - min.instance // TODO: Send a new thiner object. - ), - 500 + () => { + min.conversationalService.sendEvent( + session, + "loadInstance", + min.instance // TODO: Send a new thiner object. + ) + }, + 1500 ); session.privateConversationData.loaded = true; appPackages.forEach(e => { e.onNewSession(min, session) }); - // PACKAGE: min.subjects = []; + session.userData.subjects = []; } next(); }, diff --git a/deploy/default.gbui/public/index.html b/deploy/default.gbui/public/index.html index 3e47d45d..6d13aa1b 100644 --- a/deploy/default.gbui/public/index.html +++ b/deploy/default.gbui/public/index.html @@ -40,7 +40,6 @@ - General Bots Community Edition | pragmatismo.io diff --git a/deploy/default.gbui/src/index.js b/deploy/default.gbui/src/index.js index cf76dee8..e7820101 100644 --- a/deploy/default.gbui/src/index.js +++ b/deploy/default.gbui/src/index.js @@ -30,6 +30,12 @@ | | \*****************************************************************************/ -// TODO: runWithAdal(authContext, () => { - require('./indexApp'); -// DISABLED: }); +import React from "react"; +import ReactDOM from "react-dom"; +import GBUIApp from "./GBUIApp"; + + +ReactDOM.render( + , + document.getElementById("root") +); diff --git a/deploy/default.gbui/src/indexApp.js b/deploy/default.gbui/src/indexApp.js deleted file mode 100644 index f4ffc55c..00000000 --- a/deploy/default.gbui/src/indexApp.js +++ /dev/null @@ -1,41 +0,0 @@ -/*****************************************************************************\ -| ( )_ _ | -| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ | -| ( '_`\ ( '__)/'_` ) /'_ `\/' _ ` _ `\ /'_` )| | | |/',__)/' _ `\ /'_`\ | -| | (_) )| | ( (_| |( (_) || ( ) ( ) |( (_| || |_ | |\__, \| ( ) |( (_) ) | -| | ,__/'(_) `\__,_)`\__ |(_) (_) (_)`\__,_)`\__)(_)(____/(_) (_)`\___/' | -| | | ( )_) | | -| (_) \___/' | -| | -| General Bots Copyright (c) Pragmatismo.io. All rights reserved. | -| Licensed under the AGPL-3.0. | -| | -| 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, | -| but WITHOUT ANY WARRANTY; without even the implied warranty of | -| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | -| GNU Affero General Public License for more details. | -| | -| "General Bots" is a registered trademark of Pragmatismo.io. | -| 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. | -| | -\*****************************************************************************/ - -import React from "react"; -import ReactDOM from "react-dom"; -import GBUIApp from "./GBUIApp"; - - - ReactDOM.render( - , - document.getElementById("root") - ); diff --git a/deploy/default.gbui/src/players/GBVideoPlayer.js b/deploy/default.gbui/src/players/GBVideoPlayer.js index be650318..e10c279f 100644 --- a/deploy/default.gbui/src/players/GBVideoPlayer.js +++ b/deploy/default.gbui/src/players/GBVideoPlayer.js @@ -31,7 +31,6 @@ \*****************************************************************************/ import React, { Component } from "react"; -import {ReactPlayer} from 'react-player'; class GBVideoPlayer extends Component { constructor() { diff --git a/deploy/kb.gbapp/dialogs/MenuDialog.ts b/deploy/kb.gbapp/dialogs/MenuDialog.ts index 783fb6f5..b2f454c0 100644 --- a/deploy/kb.gbapp/dialogs/MenuDialog.ts +++ b/deploy/kb.gbapp/dialogs/MenuDialog.ts @@ -62,7 +62,7 @@ export class MenuDialog extends IGBDialog { .dialog("/menu", [ (session, args) => { var rootSubjectId = null; - var botId = min.instance.botId; + var botId = min.botId; var msg = session.message; if (msg.attachments && msg.attachments.length > 0) { @@ -146,7 +146,7 @@ export class MenuDialog extends IGBDialog { "/kb", min.instance.kb, "subjects", - "subject.png" // TODO: subject.internalId + ".png" or fallback to subject.png + subject.internalId + ".png" // TODO: or fallback to subject.png ) ) ]) // Using public dir of ui. diff --git a/deploy/kb.gbapp/services/KBService.ts b/deploy/kb.gbapp/services/KBService.ts index 04639c86..5627ecc6 100644 --- a/deploy/kb.gbapp/services/KBService.ts +++ b/deploy/kb.gbapp/services/KBService.ts @@ -40,7 +40,7 @@ const Walk = require("fs-walk"); const WaitUntil = require("wait-until"); const marked = require("marked"); -import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject }from "../models"; +import { GuaribasQuestion, GuaribasAnswer, GuaribasSubject } from "../models"; import { GBServiceCallback, IGBCoreService, IGBConversationalService, IGBInstance } from "botlib"; import { AzureSearch } from "pragmatismo-io-framework"; import { GBCoreService } from 'deploy/core.gbapp/services/GBCoreService'; @@ -74,16 +74,16 @@ export class KBService { GuaribasQuestion.findOne({ where: { instanceId: instanceId, - content: text + content: `${text.trim()}?` } }).then((question: GuaribasQuestion) => { - GuaribasAnswer.findOne({ + GuaribasAnswer.findAll({ where: { instanceId: instanceId, answerId: question.answerId } - }).then((answer: GuaribasAnswer) => { - cb({ question: question, answer: answer }, null); + }).then((answer: GuaribasAnswer[]) => { + cb({ question: question, answer: answer[0] }, null); }); }); } @@ -104,10 +104,6 @@ export class KBService { subjects: GuaribasSubject[], cb: GBServiceCallback ) { - if (instance.searchKey === "") { - cb(null, null); - return; - } // Builds search query. @@ -463,7 +459,7 @@ export class KBService { playerType: "video", data: answer.content }); - }else if (answer.content.length > 140) { + } else if (answer.content.length > 140) { let msgs = [ "Vou te responder na tela para melhor visualização...", "A resposta está na tela...", @@ -592,17 +588,7 @@ export class KBService { GuaribasPackage.destroy({ where: { instanceId: instance.instanceId, packageId: packageId } }).then(value => { - var search = new AzureSearch( - instance.searchKey, - instance.searchHost, - instance.searchIndex, - instance.searchIndexer - ); - logger.trace("rebuildIndex called."); - search.rebuildIndex(() => { - logger.trace("rebuildIndex done."); - cb(null, null); - }); + cb(null, null); }); }); }); diff --git a/package.json b/package.json index 6c359fd4..d052a942 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "botserver", - "version": "0.0.11", + "version": "0.0.14", "description": "General Bots Community Edition open-core server.", "author": "me@rodrigorodriguez.com", "license": "AGPL-3.0", @@ -28,7 +28,7 @@ "express": "^4.16.2", "fs-walk": "0.0.1", "marked": "^0.3.12", - "pragmatismo-io-framework": "^1.0.3", + "pragmatismo-io-framework": "^1.0.4", "reflect-metadata": "^0.1.12", "request-promise-native": "^1.0.5", "sequelize": "^4.37.6",