diff --git a/.github/workflows/docker-community-push-latest.yaml b/.github/workflows/docker-community-push-latest.yaml new file mode 100644 index 0000000..6ef8af4 --- /dev/null +++ b/.github/workflows/docker-community-push-latest.yaml @@ -0,0 +1,35 @@ +name: Docker Image Community latest CI - Tiledesk Chatbot + +env: + REGISTRY: tiledeskrepo + IMAGE_NAME: tiledesk-chatbot + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \ No newline at end of file diff --git a/.github/workflows/docker-image-tag-community-tag-push.yaml b/.github/workflows/docker-image-tag-community-tag-push.yaml new file mode 100644 index 0000000..d0181e8 --- /dev/null +++ b/.github/workflows/docker-image-tag-community-tag-push.yaml @@ -0,0 +1,48 @@ +name: Publish Docker Community image tags - Tiledesk Chatbot + +env: + REGISTRY: tiledeskrepo + IMAGE_NAME: tiledesk-chatbot + +on: + push: + tags: + - '**' # Push events to every tag including hierarchical tags like + +jobs: + push_to_registry: + name: Push Docker image to Docker Hub + runs-on: ubuntu-latest + + steps: + - name: Check out the repo + uses: actions/checkout@v4 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tag_with_ref: true + + - name: Generate Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + + - name: Build and push + uses: docker/build-push-action@v4 + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 64f0806..d10ad87 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ # Tiledesk native chatbot -### 0.1.1 updated MarckbotPlugs.js & DirectivesPlug.js \ No newline at end of file + +# 1.0.2 +- bug-fixed: default engine for DirAskGPTV2 +- bug-fixed: block only hidden message + +# 1.0.1 +- first deploy of Chatbot Plugs + +### 0.1.1 updated MarckbotPlugs.js & DirectivesPlug.js diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..8382ab2 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,34 @@ +FROM node:16 + +RUN sed -i 's/stable\/updates/stable-security\/updates/' /etc/apt/sources.list + + +RUN apt-get update + +# Create app directory +WORKDIR /usr/src/app + +ARG NPM_TOKEN + +RUN if [ "$NPM_TOKEN" ]; \ + then RUN COPY .npmrc_ .npmrc \ + else export SOMEVAR=world; \ + fi + + +# Install app dependencies +# A wildcard is used to ensure both package.json AND package-lock.json are copied +# where available (npm@5+) +COPY package*.json ./ + +RUN npm install --production + +RUN rm -f .npmrc + +# Bundle app source +COPY . . + +EXPOSE 3000 + +CMD [ "npm", "start" ] + diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..0c3ec47 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,20 @@ +#npm version patch +version=`node -e 'console.log(require("./package.json").version)'` +echo "version $version" + +## Update package-lock.json +npm install + +## Push commit to git +git add . +git commit -m "version added: ### $version" +git push remote master + +## Create tag and npm +if [ "$version" != "" ]; then + git tag -a "$version" -m "`git log -1 --format=%s`" + echo "Created a new tag, $version" + git push --tags + cd ./tybotRoute + npm publish --access public +fi \ No newline at end of file diff --git a/index.js b/index.js index d5de91a..a6f8a9e 100644 --- a/index.js +++ b/index.js @@ -4,28 +4,30 @@ var app = express(); var cors = require('cors'); app.use(cors()); -//const tybot = require("@tiledesk/tiledesk-tybot-connector"); +// const tybot = require("@tiledesk/tiledesk-tybot-connector"); const tybot = require("./tybotRoute"); -const templates = require("./templatesRoute"); -const chooser_bot = require("./chooserChatbotRoute"); const tybotRoute = tybot.router; -const templatesRoute = templates.router; -const chooserRoute = chooser_bot.router; app.use("/", tybotRoute); // /tybot + +const templates = require("./templatesRoute"); +const templatesRoute = templates.router; app.use("/chatbots", templatesRoute); -app.use("/langbot", chooserRoute); + +// const chooser_bot = require("./chooserChatbotRoute"); +// const chooserRoute = chooser_bot.router; +// app.use("/langbot", chooserRoute); // TEMP // const bots_data = require('./tybotRoute/test/conversation-actions_bot.js').bots_data; tybot.startApp( { - MONGODB_URI: process.env.mongoUrl, + MONGODB_URI: process.env.MONGODB_URI, // bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, - REDIS_HOST: process.env.REDIS_HOST, - REDIS_PORT: process.env.REDIS_PORT, - REDIS_PASSWORD: process.env.REDIS_PASSWORD, + REDIS_HOST: process.env.CACHE_REDIS_HOST, + REDIS_PORT: process.env.CACHE_REDIS_PORT, + REDIS_PASSWORD: process.env.CACHE_REDIS_PASSWORD, // CACHE_ENABLED: process.env.CACHE_ENABLED, log: process.env.TILEBOT_LOG }, () => { diff --git a/package-lock.json b/package-lock.json index 5dfcbce..adb49b4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { - "name": "tiledesk-bot-web-sandbox", - "version": "1.0.0", + "name": "@tiledesk/tiledesk-chatbot", + "version": "1.0.6", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "tiledesk-bot-web-sandbox", - "version": "1.0.0", + "name": "@tiledesk/tiledesk-chatbot", + "version": "1.0.6", "license": "ISC", "dependencies": { "@tiledesk/helpcenter-query-client": "^0.1.8", @@ -28,7 +28,7 @@ "mongoose": "^6.6.1", "nanoid": "^3.3.4", "npm": "^6.14.11", - "redis": "^3.1.2", + "redis": "^4.7.0", "uuid": "^9.0.0", "vm2": "^3.9.13" }, @@ -36,6 +36,59 @@ "mocha": "^8.4.0" } }, + "node_modules/@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/client": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz", + "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==", + "dependencies": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/json": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz", + "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/search": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz", + "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/time-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz", + "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, "node_modules/@tiledesk/helpcenter-query-client": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@tiledesk/helpcenter-query-client/-/helpcenter-query-client-0.1.8.tgz", @@ -198,6 +251,14 @@ "form-data": "^4.0.0" } }, + "node_modules/@tiledesk/tiledesk-tybot-connector/node_modules/denque": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", + "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==", + "engines": { + "node": ">=0.10" + } + }, "node_modules/@tiledesk/tiledesk-tybot-connector/node_modules/dotenv": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", @@ -206,6 +267,24 @@ "node": ">=10" } }, + "node_modules/@tiledesk/tiledesk-tybot-connector/node_modules/redis": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", + "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", + "dependencies": { + "denque": "^1.5.0", + "redis-commands": "^1.7.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/node-redis" + } + }, "node_modules/@tiledesk/tiledesk-tybot-connector/node_modules/uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -691,6 +770,14 @@ "node": ">=8" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1114,6 +1201,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==", + "engines": { + "node": ">= 4" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -4026,6 +4121,7 @@ }, "node_modules/npm/node_modules/lodash._baseindexof": { "version": "3.1.0", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -4040,16 +4136,19 @@ }, "node_modules/npm/node_modules/lodash._bindcallback": { "version": "3.0.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._cacheindexof": { "version": "3.0.2", + "extraneous": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/lodash._createcache": { "version": "3.1.2", + "extraneous": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -4063,6 +4162,7 @@ }, "node_modules/npm/node_modules/lodash._getnative": { "version": "3.9.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -4078,6 +4178,7 @@ }, "node_modules/npm/node_modules/lodash.restparam": { "version": "3.6.1", + "extraneous": true, "inBundle": true, "license": "MIT" }, @@ -6247,21 +6348,16 @@ } }, "node_modules/redis": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", - "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz", + "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==", "dependencies": { - "denque": "^1.5.0", - "redis-commands": "^1.7.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-redis" + "@redis/bloom": "1.2.0", + "@redis/client": "1.6.0", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.7", + "@redis/search": "1.2.0", + "@redis/time-series": "1.1.0" } }, "node_modules/redis-commands": { @@ -6288,14 +6384,6 @@ "node": ">=4" } }, - "node_modules/redis/node_modules/denque": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", - "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==", - "engines": { - "node": ">=0.10" - } - }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -6745,6 +6833,11 @@ "node": ">=10" } }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "node_modules/yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", @@ -6845,6 +6938,46 @@ } }, "dependencies": { + "@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "requires": {} + }, + "@redis/client": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz", + "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==", + "requires": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + } + }, + "@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "requires": {} + }, + "@redis/json": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz", + "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==", + "requires": {} + }, + "@redis/search": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz", + "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==", + "requires": {} + }, + "@redis/time-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz", + "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==", + "requires": {} + }, "@tiledesk/helpcenter-query-client": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@tiledesk/helpcenter-query-client/-/helpcenter-query-client-0.1.8.tgz", @@ -6997,11 +7130,27 @@ "form-data": "^4.0.0" } }, + "denque": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", + "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==" + }, "dotenv": { "version": "10.0.0", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" }, + "redis": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", + "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", + "requires": { + "denque": "^1.5.0", + "redis-commands": "^1.7.0", + "redis-errors": "^1.2.0", + "redis-parser": "^3.0.0" + } + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -7360,6 +7509,11 @@ } } }, + "cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==" + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -7671,6 +7825,11 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==" + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -9797,7 +9956,8 @@ }, "lodash._baseindexof": { "version": "3.1.0", - "bundled": true + "bundled": true, + "extraneous": true }, "lodash._baseuniq": { "version": "4.6.0", @@ -9809,15 +9969,18 @@ }, "lodash._bindcallback": { "version": "3.0.1", - "bundled": true + "bundled": true, + "extraneous": true }, "lodash._cacheindexof": { "version": "3.0.2", - "bundled": true + "bundled": true, + "extraneous": true }, "lodash._createcache": { "version": "3.1.2", "bundled": true, + "extraneous": true, "requires": { "lodash._getnative": "^3.0.0" } @@ -9828,7 +9991,8 @@ }, "lodash._getnative": { "version": "3.9.1", - "bundled": true + "bundled": true, + "extraneous": true }, "lodash._root": { "version": "3.0.1", @@ -9840,7 +10004,8 @@ }, "lodash.restparam": { "version": "3.6.1", - "bundled": true + "bundled": true, + "extraneous": true }, "lodash.union": { "version": "4.6.0", @@ -11467,21 +11632,16 @@ } }, "redis": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", - "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz", + "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==", "requires": { - "denque": "^1.5.0", - "redis-commands": "^1.7.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0" - }, - "dependencies": { - "denque": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", - "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==" - } + "@redis/bloom": "1.2.0", + "@redis/client": "1.6.0", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.7", + "@redis/search": "1.2.0", + "@redis/time-series": "1.1.0" } }, "redis-commands": { @@ -11832,6 +11992,11 @@ "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", "dev": true }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" + }, "yargs": { "version": "16.2.0", "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", diff --git a/package.json b/package.json index 5145db8..c2acf09 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "tiledesk-bot-web-sandbox", - "version": "1.0.0", + "name": "@tiledesk/tiledesk-chatbot", + "version": "1.0.6", "description": "", "main": "index.js", "scripts": { @@ -27,7 +27,7 @@ "minimist-string": "^1.0.2", "mongoose": "^6.6.1", "nanoid": "^3.3.4", - "redis": "^3.1.2", + "redis": "^4.7.0", "uuid": "^9.0.0", "vm2": "^3.9.13", "npm": "^6.14.11", diff --git a/tybotRoute/CHANGELOG.md b/tybotRoute/CHANGELOG.md index e0599e1..3baff27 100644 --- a/tybotRoute/CHANGELOG.md +++ b/tybotRoute/CHANGELOG.md @@ -24,6 +24,13 @@ available on: - Bug-fixed: hiddenMessage not blocked - Bug-fixed: DirAskGPTV2 has hardcoded engine +# v0.2.138-rc8 +- Updated redis to 4.7.0 +- Updated tdCache + +# v0.2.138-rc6 +- First deploy external + # v0.2.138-rc1 - Updated redis to 4.7.0 - Updated tdCache diff --git a/tybotRoute/TdCache.js b/tybotRoute/TdCache.js index 62f8f69..49b07be 100644 --- a/tybotRoute/TdCache.js +++ b/tybotRoute/TdCache.js @@ -3,38 +3,63 @@ const redis = require('redis'); class TdCache { constructor(config) { + console.log("TdCache config: ", config); this.redis_host = config.host; this.redis_port = config.port; this.redis_password = config.password; + console.log("TdCache this.redis_host: ", this.redis_host); + console.log("TdCache this.redis_port: ", this.redis_port); + console.log("TdCache this.redis_password: ", this.redis_password); this.client = null; + this.redis_sub = null; } async connect(callback) { - // client = redis.createClient(); + return new Promise( async (resolve, reject) => { + /** + * Connect redis client + */ this.client = redis.createClient( - { - host: this.redis_host, - port: this.redis_port, - password: this.redis_password - }); + { + url: `redis://${this.redis_host}:${this.redis_port}`, + password: this.redis_password + }); this.client.on('error', err => { reject(err); if (callback) { callback(err); } }); - // this.client.on('connect', function() { - // console.log('Redis Connected!'); - // }); this.client.on('ready',function() { - // console.log("connected") resolve(); if (callback) { callback(); } - //console.log("Redis is ready."); }); + await this.client.connect(); + + /** + * Connect redis subscription client + */ + this.redis_sub = redis.createClient( + { + url: `redis://${this.redis_host}:${this.redis_port}`, + password: this.redis_password + }); + this.redis_sub.on('error', err => { + reject(err); + if (callback) { + callback(err); + } + }); + this.redis_sub.on('ready',function() { + resolve(); + if (callback) { + callback(); + } + }); + await this.redis_sub.connect(); }); } @@ -43,202 +68,59 @@ class TdCache { if (!options) { options = {EX: 86400} } - return new Promise( async (resolve, reject) => { - if (options && options.EX) { - //console.log("expires:", options.EX) - try { - this.client.set( - key, - value, - 'EX', options.EX, - (err) => { - if (err) { - reject(err); - } - else { - return resolve(); - } - } - ); - } - catch(error) { - reject(error) - } - } - else { - try { - //console.log("setting here...key", key, value) - await this.client.set( - key, - value, - (err) => { - if (err) { - reject(err); - } - else { - return resolve(); - } - } - ); - } - catch(error) { - console.error("TdCache Error:", error); - reject(error) - } - } - // if (options && options.callback) { - // options.callback(); - // } - //console.log("resolving...", key); - // return resolve(); - }); + await this.client.set( + key, + value, + options); } async incr(key) { - // console.log("incr key:", key) - return new Promise( async (resolve, reject) => { - try { - // console.log("incr here...key", key) - await this.client.incr(key); - } - catch(error) { - console.error("Error on incr:", error); - reject(error) - } - return resolve(); - }); + await this.client.incr(key); } async hset(dict_key, key, value, options) { - //console.log("hsetting dict_key key value", dict_key, key, value) - return new Promise( async (resolve, reject) => { - if (options && options.EX) { - //console.log("expires:", options.EX) - try { - await this.client.hset( - dict_key, - key, - value, - 'EX', options.EX); - } - catch(error) { - reject(error) - } - } - else { - try { - //console.log("setting here...key", key, value) - await this.client.hset( - dict_key, - key, - value); - } - catch(error) { - console.error("Error", error); - reject(error) - } - } - if (options && options.callback) { - options.callback(); - } - return resolve(); - }); + if (!value) { + return; + } + if (!options) { + options = {EX: 86400} + } + await this.client.HSET( + dict_key, + key, + value, + options); } - async hdel(dict_key, key, options) { - //console.log("hsetting dict_key key value", dict_key, key, value) - return new Promise( async (resolve, reject) => { - if (options && options.EX) { - //console.log("expires:", options.EX) - try { - await this.client.hdel( - dict_key, - key, - 'EX', options.EX); - } - catch(error) { - reject(error) - } - } - else { - try { - //console.log("setting here...key", key, value) - await this.client.hdel( - dict_key, - key); - } - catch(error) { - console.error("Error", error); - reject(error); - } - } - if (options && options.callback) { - options.callback(); - } - return resolve(); - }); + async hdel(dict_key, key) { + await this.client.HDEL(dict_key, key); } async setJSON(key, value, options) { + if (!value) { + return; + } + if (!options) { + options = {EX: 86400} + } const _string = JSON.stringify(value); return await this.set(key, _string, options); } - async get(key, callback) { - //console.log("getting key", key) - return new Promise( async (resolve, reject) => { - this.client.get(key, (err, value) => { - if (err) { - reject(err); - } - else { - if (callback) { - callback(value); - } - return resolve(value); - } - }); - }); + async get(key) { + const value = await this.client.GET(key); + return value; } - async hgetall(dict_key, callback) { - //console.log("hgetting dics", dict_key); - return new Promise( async (resolve, reject) => { - this.client.hgetall(dict_key, (err, value) => { - if (err) { - reject(err); - if (callback) { - callback(err, null); - } - } - else { - if (callback) { - callback(null, value); - } - resolve(value); - } - }); - }); + async hgetall(dict_key) { + const all = await this.client.HGETALL(dict_key); + return all; } - async hget(dict_key, key, callback) { - //console.log("hgetting dics", dict_key); - return new Promise( async (resolve, reject) => { - this.client.hget(dict_key, key, (err, value) => { - if (err) { - reject(err); - if (callback) { - callback(err, null); - } - } - else { - if (callback) { - callback(null, value); - } - resolve(value); - } - }); - }); + async hget(dict_key, key) { + // console.log("hgetting dics", dict_key); + const value = await this.client.HGET(dict_key, key); + return value; } async getJSON(key, callback) { @@ -246,16 +128,19 @@ class TdCache { return JSON.parse(value); } - async del(key, callback) { - return new Promise( async (resolve, reject) => { - this.client.del(key, () => { - if (callback) { - callback(); - } - return resolve(); - }); - }) + async del(key) { + await this.client.del(key); } + + async publish(key, value) { + await this.redis_sub.publish(key, value); + } + + // subscribe(key, callback) { + // this.redis_sub.subscribe(key, (message) => { + // callback(message); + // }); + // } } module.exports = { TdCache }; \ No newline at end of file diff --git a/tybotRoute/TdCache_v3.js b/tybotRoute/TdCache_v3.js new file mode 100644 index 0000000..62f8f69 --- /dev/null +++ b/tybotRoute/TdCache_v3.js @@ -0,0 +1,261 @@ +const redis = require('redis'); + +class TdCache { + + constructor(config) { + this.redis_host = config.host; + this.redis_port = config.port; + this.redis_password = config.password; + this.client = null; + } + + async connect(callback) { + // client = redis.createClient(); + return new Promise( async (resolve, reject) => { + this.client = redis.createClient( + { + host: this.redis_host, + port: this.redis_port, + password: this.redis_password + }); + this.client.on('error', err => { + reject(err); + if (callback) { + callback(err); + } + }); + // this.client.on('connect', function() { + // console.log('Redis Connected!'); + // }); + this.client.on('ready',function() { + // console.log("connected") + resolve(); + if (callback) { + callback(); + } + //console.log("Redis is ready."); + }); + }); + } + + async set(key, value, options) { + //console.log("setting key value", key, value) + if (!options) { + options = {EX: 86400} + } + return new Promise( async (resolve, reject) => { + if (options && options.EX) { + //console.log("expires:", options.EX) + try { + this.client.set( + key, + value, + 'EX', options.EX, + (err) => { + if (err) { + reject(err); + } + else { + return resolve(); + } + } + ); + } + catch(error) { + reject(error) + } + } + else { + try { + //console.log("setting here...key", key, value) + await this.client.set( + key, + value, + (err) => { + if (err) { + reject(err); + } + else { + return resolve(); + } + } + ); + } + catch(error) { + console.error("TdCache Error:", error); + reject(error) + } + } + // if (options && options.callback) { + // options.callback(); + // } + //console.log("resolving...", key); + // return resolve(); + }); + } + + async incr(key) { + // console.log("incr key:", key) + return new Promise( async (resolve, reject) => { + try { + // console.log("incr here...key", key) + await this.client.incr(key); + } + catch(error) { + console.error("Error on incr:", error); + reject(error) + } + return resolve(); + }); + } + + async hset(dict_key, key, value, options) { + //console.log("hsetting dict_key key value", dict_key, key, value) + return new Promise( async (resolve, reject) => { + if (options && options.EX) { + //console.log("expires:", options.EX) + try { + await this.client.hset( + dict_key, + key, + value, + 'EX', options.EX); + } + catch(error) { + reject(error) + } + } + else { + try { + //console.log("setting here...key", key, value) + await this.client.hset( + dict_key, + key, + value); + } + catch(error) { + console.error("Error", error); + reject(error) + } + } + if (options && options.callback) { + options.callback(); + } + return resolve(); + }); + } + + async hdel(dict_key, key, options) { + //console.log("hsetting dict_key key value", dict_key, key, value) + return new Promise( async (resolve, reject) => { + if (options && options.EX) { + //console.log("expires:", options.EX) + try { + await this.client.hdel( + dict_key, + key, + 'EX', options.EX); + } + catch(error) { + reject(error) + } + } + else { + try { + //console.log("setting here...key", key, value) + await this.client.hdel( + dict_key, + key); + } + catch(error) { + console.error("Error", error); + reject(error); + } + } + if (options && options.callback) { + options.callback(); + } + return resolve(); + }); + } + + async setJSON(key, value, options) { + const _string = JSON.stringify(value); + return await this.set(key, _string, options); + } + + async get(key, callback) { + //console.log("getting key", key) + return new Promise( async (resolve, reject) => { + this.client.get(key, (err, value) => { + if (err) { + reject(err); + } + else { + if (callback) { + callback(value); + } + return resolve(value); + } + }); + }); + } + + async hgetall(dict_key, callback) { + //console.log("hgetting dics", dict_key); + return new Promise( async (resolve, reject) => { + this.client.hgetall(dict_key, (err, value) => { + if (err) { + reject(err); + if (callback) { + callback(err, null); + } + } + else { + if (callback) { + callback(null, value); + } + resolve(value); + } + }); + }); + } + + async hget(dict_key, key, callback) { + //console.log("hgetting dics", dict_key); + return new Promise( async (resolve, reject) => { + this.client.hget(dict_key, key, (err, value) => { + if (err) { + reject(err); + if (callback) { + callback(err, null); + } + } + else { + if (callback) { + callback(null, value); + } + resolve(value); + } + }); + }); + } + + async getJSON(key, callback) { + const value = await this.get(key); + return JSON.parse(value); + } + + async del(key, callback) { + return new Promise( async (resolve, reject) => { + this.client.del(key, () => { + if (callback) { + callback(); + } + return resolve(); + }); + }) + } +} + +module.exports = { TdCache }; \ No newline at end of file diff --git a/tybotRoute/TdCache_v4.js b/tybotRoute/TdCache_v4.js deleted file mode 100644 index bbe7454..0000000 --- a/tybotRoute/TdCache_v4.js +++ /dev/null @@ -1,146 +0,0 @@ -const redis = require('redis'); - -class TdCache { - - constructor(config) { - console.log("TdCache config: ", config); - this.redis_host = config.host; - this.redis_port = config.port; - this.redis_password = config.password; - console.log("TdCache this.redis_host: ", this.redis_host); - console.log("TdCache this.redis_port: ", this.redis_port); - console.log("TdCache this.redis_password: ", this.redis_password); - this.client = null; - this.redis_sub = null; - } - - async connect(callback) { - - return new Promise( async (resolve, reject) => { - /** - * Connect redis client - */ - this.client = redis.createClient( - { - url: `redis://${this.redis_host}:${this.redis_port}`, - password: this.redis_password - }); - this.client.on('error', err => { - reject(err); - if (callback) { - callback(err); - } - }); - this.client.on('ready',function() { - resolve(); - if (callback) { - callback(); - } - }); - await this.client.connect(); - - /** - * Connect redis subscription client - */ - this.redis_sub = redis.createClient( - { - url: `redis://${this.redis_host}:${this.redis_port}`, - password: this.redis_password - }); - this.redis_sub.on('error', err => { - reject(err); - if (callback) { - callback(err); - } - }); - this.redis_sub.on('ready',function() { - resolve(); - if (callback) { - callback(); - } - }); - await this.redis_sub.connect(); - }); - } - - async set(key, value, options) { - //console.log("setting key value", key, value) - if (!options) { - options = {EX: 86400} - } - await this.client.set( - key, - value, - options); - } - - async incr(key) { - await this.client.incr(key); - } - - async hset(dict_key, key, value, options) { - if (!value) { - return; - } - if (!options) { - options = {EX: 86400} - } - await this.client.HSET( - dict_key, - key, - value, - options); - } - - async hdel(dict_key, key) { - await this.client.HDEL(dict_key, key); - } - - async setJSON(key, value, options) { - if (!value) { - return; - } - if (!options) { - options = {EX: 86400} - } - const _string = JSON.stringify(value); - return await this.set(key, _string, options); - } - - async get(key) { - const value = await this.client.GET(key); - return value; - } - - async hgetall(dict_key) { - const all = await this.client.HGETALL(dict_key); - return all; - } - - async hget(dict_key, key) { - // console.log("hgetting dics", dict_key); - const value = await this.client.HGET(dict_key, key); - return value; - } - - async getJSON(key, callback) { - const value = await this.get(key); - return JSON.parse(value); - } - - async del(key) { - await this.client.del(key); - } - - async publish(key, value) { - await this.redis_sub.publish(key, value); - } - - // subscribe(key, callback) { - // this.redis_sub.subscribe(key, (message) => { - // callback(message); - // }); - // } -} - -module.exports = { TdCache }; \ No newline at end of file diff --git a/tybotRoute/index.js b/tybotRoute/index.js index a4158dc..1688604 100644 --- a/tybotRoute/index.js +++ b/tybotRoute/index.js @@ -609,6 +609,7 @@ router.post('/block/:project_id/:bot_id/:block_id', async (req, res) => { async function startApp(settings, completionCallback) { console.log("Starting Tilebot..."); + // console.log("Starting Tilebot with Settings:", settings); if (settings.bots) { // static bots data source staticBots = settings.bots; } diff --git a/tybotRoute/models/TiledeskChatbotUtil.js b/tybotRoute/models/TiledeskChatbotUtil.js index fd87c7c..cef6f86 100644 --- a/tybotRoute/models/TiledeskChatbotUtil.js +++ b/tybotRoute/models/TiledeskChatbotUtil.js @@ -699,7 +699,6 @@ class TiledeskChatbotUtil { await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_ID_KEY, message.attributes.departmentId); await chatbot.addParameter(TiledeskChatbotConst.REQ_DEPARTMENT_NAME_KEY, message.attributes.departmentName); } - if (message.attributes) { if (chatbot.log) {console.log("Ok message.attributes", JSON.stringify(message.attributes));} // if (projectId === "641864da99c1fb00131ba495") {console.log("641864da99c1fb00131ba495 > Ok message.attributes", JSON.stringify(message.attributes));} @@ -920,6 +919,7 @@ class TiledeskChatbotUtil { } /** + * DEPRECATED * A stub to get the request parameters, hosted by tilebot on: * /${TILEBOT_ROUTE}/ext/parameters/requests/${requestId}?all * diff --git a/tybotRoute/package-lock.json b/tybotRoute/package-lock.json index b3ebbb1..597a847 100644 --- a/tybotRoute/package-lock.json +++ b/tybotRoute/package-lock.json @@ -27,7 +27,7 @@ "mongoose": "^6.3.5", "multer": "^1.4.5-lts.1", "nanoid": "^3.1.25", - "redis": "^3.1.2", + "redis": "^4.7.0", "uuid": "^3.3.3", "vm2": "^3.9.13" }, @@ -35,6 +35,59 @@ "mocha": "^8.4.0" } }, + "node_modules/@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/client": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz", + "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==", + "dependencies": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + }, + "engines": { + "node": ">=14" + } + }, + "node_modules/@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/json": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz", + "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/search": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz", + "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, + "node_modules/@redis/time-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz", + "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==", + "peerDependencies": { + "@redis/client": "^1.0.0" + } + }, "node_modules/@tiledesk/helpcenter-query-client": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@tiledesk/helpcenter-query-client/-/helpcenter-query-client-0.1.8.tgz", @@ -637,6 +690,14 @@ "node": ">=8" } }, + "node_modules/cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -1132,6 +1193,14 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==", + "engines": { + "node": ">= 4" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -2416,53 +2485,16 @@ } }, "node_modules/redis": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", - "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz", + "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==", "dependencies": { - "denque": "^1.5.0", - "redis-commands": "^1.7.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/node-redis" - } - }, - "node_modules/redis-commands": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", - "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" - }, - "node_modules/redis-errors": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", - "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", - "engines": { - "node": ">=4" - } - }, - "node_modules/redis-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", - "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", - "dependencies": { - "redis-errors": "^1.0.0" - }, - "engines": { - "node": ">=4" - } - }, - "node_modules/redis/node_modules/denque": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", - "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==", - "engines": { - "node": ">=0.10" + "@redis/bloom": "1.2.0", + "@redis/client": "1.6.0", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.7", + "@redis/search": "1.2.0", + "@redis/time-series": "1.1.0" } }, "node_modules/reinterval": { @@ -3250,6 +3282,46 @@ } }, "dependencies": { + "@redis/bloom": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/bloom/-/bloom-1.2.0.tgz", + "integrity": "sha512-HG2DFjYKbpNmVXsa0keLHp/3leGJz1mjh09f2RLGGLQZzSHpkmZWuwJbAvo3QcRY8p80m5+ZdXZdYOSBLlp7Cg==", + "requires": {} + }, + "@redis/client": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@redis/client/-/client-1.6.0.tgz", + "integrity": "sha512-aR0uffYI700OEEH4gYnitAnv3vzVGXCFvYfdpu/CJKvk4pHfLPEy/JSZyrpQ+15WhXe1yJRXLtfQ84s4mEXnPg==", + "requires": { + "cluster-key-slot": "1.1.2", + "generic-pool": "3.9.0", + "yallist": "4.0.0" + } + }, + "@redis/graph": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@redis/graph/-/graph-1.1.1.tgz", + "integrity": "sha512-FEMTcTHZozZciLRl6GiiIB4zGm5z5F3F6a6FZCyrfxdKOhFlGkiAqlexWMBzCi4DcRoyiOsuLfW+cjlGWyExOw==", + "requires": {} + }, + "@redis/json": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@redis/json/-/json-1.0.7.tgz", + "integrity": "sha512-6UyXfjVaTBTJtKNG4/9Z8PSpKE6XgSyEb8iwaqDcy+uKrd/DGYHTWkUdnQDyzm727V7p21WUMhsqz5oy65kPcQ==", + "requires": {} + }, + "@redis/search": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@redis/search/-/search-1.2.0.tgz", + "integrity": "sha512-tYoDBbtqOVigEDMAcTGsRlMycIIjwMCgD8eR2t0NANeQmgK/lvxNAvYyb6bZDD4frHRhIHkJu2TBRvB0ERkOmw==", + "requires": {} + }, + "@redis/time-series": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@redis/time-series/-/time-series-1.1.0.tgz", + "integrity": "sha512-c1Q99M5ljsIuc4YdaCwfUEXsofakb9c8+Zse2qxTadu8TalLXuAESzLvFAvNVbkmSlvlzIQOLpBCmWI9wTOt+g==", + "requires": {} + }, "@tiledesk/helpcenter-query-client": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/@tiledesk/helpcenter-query-client/-/helpcenter-query-client-0.1.8.tgz", @@ -3727,6 +3799,11 @@ } } }, + "cluster-key-slot": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", + "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==" + }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -4100,6 +4177,11 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "generic-pool": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/generic-pool/-/generic-pool-3.9.0.tgz", + "integrity": "sha512-hymDOu5B53XvN4QT9dBmZxPX4CWhBPPLguTZ9MMFeFa/Kg0xWVfylOVNlJji/E7yTZWFd/q9GO5TxDLq156D7g==" + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -5071,39 +5153,16 @@ } }, "redis": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/redis/-/redis-3.1.2.tgz", - "integrity": "sha512-grn5KoZLr/qrRQVwoSkmzdbw6pwF+/rwODtrOr6vuBRiR/f3rjSTGupbF90Zpqm2oenix8Do6RV7pYEkGwlKkw==", - "requires": { - "denque": "^1.5.0", - "redis-commands": "^1.7.0", - "redis-errors": "^1.2.0", - "redis-parser": "^3.0.0" - }, - "dependencies": { - "denque": { - "version": "1.5.1", - "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.1.tgz", - "integrity": "sha512-XwE+iZ4D6ZUB7mfYRMb5wByE8L74HCn30FBN7sWnXksWc1LO1bPDl67pBR9o/kC4z/xSNAwkMYcGgqDV3BE3Hw==" - } - } - }, - "redis-commands": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", - "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" - }, - "redis-errors": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", - "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==" - }, - "redis-parser": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", - "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/redis/-/redis-4.7.0.tgz", + "integrity": "sha512-zvmkHEAdGMn+hMRXuMBtu4Vo5P6rHQjLoHftu+lBqq8ZTA3RCVC/WzD790bkKKiNFp7d5/9PcSD19fJyyRvOdQ==", "requires": { - "redis-errors": "^1.0.0" + "@redis/bloom": "1.2.0", + "@redis/client": "1.6.0", + "@redis/graph": "1.1.1", + "@redis/json": "1.0.7", + "@redis/search": "1.2.0", + "@redis/time-series": "1.1.0" } }, "reinterval": { diff --git a/tybotRoute/package.json b/tybotRoute/package.json index d35028c..9a1d49f 100644 --- a/tybotRoute/package.json +++ b/tybotRoute/package.json @@ -29,7 +29,7 @@ "mongoose": "^6.3.5", "multer": "^1.4.5-lts.1", "nanoid": "^3.1.25", - "redis": "^3.1.2", + "redis": "^4.7.0", "uuid": "^3.3.3", "vm2": "^3.9.13" }, diff --git a/tybotRoute/test/anomaly-detection-test.js b/tybotRoute/test/anomaly-detection-test.js index 71b51b1..df2310a 100644 --- a/tybotRoute/test/anomaly-detection-test.js +++ b/tybotRoute/test/anomaly-detection-test.js @@ -27,7 +27,7 @@ describe('Conversation for anomaly detection test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-actions-test.js_ b/tybotRoute/test/conversation-actions-test.js_ index 4bd7d08..024da9d 100644 --- a/tybotRoute/test/conversation-actions-test.js_ +++ b/tybotRoute/test/conversation-actions-test.js_ @@ -27,7 +27,7 @@ describe('Conversation for actions test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-add-tags_test.js b/tybotRoute/test/conversation-add-tags_test.js index 378e078..85ee353 100644 --- a/tybotRoute/test/conversation-add-tags_test.js +++ b/tybotRoute/test/conversation-add-tags_test.js @@ -32,7 +32,7 @@ describe('Conversation for AddTags test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-askgpt_test.js b/tybotRoute/test/conversation-askgpt_test.js index 21737aa..1f524de 100644 --- a/tybotRoute/test/conversation-askgpt_test.js +++ b/tybotRoute/test/conversation-askgpt_test.js @@ -31,7 +31,7 @@ describe('Conversation for AskGPT test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-askgptv2_test.js b/tybotRoute/test/conversation-askgptv2_test.js index 0a46bbd..dcdd992 100644 --- a/tybotRoute/test/conversation-askgptv2_test.js +++ b/tybotRoute/test/conversation-askgptv2_test.js @@ -31,7 +31,7 @@ describe('Conversation for AskGPTV2 test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-brevo_test.js b/tybotRoute/test/conversation-brevo_test.js index 128e131..54557fc 100644 --- a/tybotRoute/test/conversation-brevo_test.js +++ b/tybotRoute/test/conversation-brevo_test.js @@ -31,7 +31,7 @@ describe('Conversation for brevo test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-capture_test.js b/tybotRoute/test/conversation-capture_test.js index a156e3f..5d9d624 100644 --- a/tybotRoute/test/conversation-capture_test.js +++ b/tybotRoute/test/conversation-capture_test.js @@ -31,7 +31,7 @@ describe('Conversation for capture test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-code_action_test.js b/tybotRoute/test/conversation-code_action_test.js index 258662b..468289a 100644 --- a/tybotRoute/test/conversation-code_action_test.js +++ b/tybotRoute/test/conversation-code_action_test.js @@ -29,7 +29,7 @@ describe('Conversation for Code Action test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-customerio_test.js b/tybotRoute/test/conversation-customerio_test.js index 30aac65..a16b0aa 100644 --- a/tybotRoute/test/conversation-customerio_test.js +++ b/tybotRoute/test/conversation-customerio_test.js @@ -31,7 +31,7 @@ describe('Conversation for customerio test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-empty_text_in_reply_bug_test.js b/tybotRoute/test/conversation-empty_text_in_reply_bug_test.js index 8bac845..3984a59 100644 --- a/tybotRoute/test/conversation-empty_text_in_reply_bug_test.js +++ b/tybotRoute/test/conversation-empty_text_in_reply_bug_test.js @@ -29,7 +29,7 @@ describe('Conversation for test text empty bug', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-filters_in_reply_test.js b/tybotRoute/test/conversation-filters_in_reply_test.js index 33a0988..ff8325f 100644 --- a/tybotRoute/test/conversation-filters_in_reply_test.js +++ b/tybotRoute/test/conversation-filters_in_reply_test.js @@ -29,7 +29,7 @@ describe('Conversation for Filters in reply test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-form-test.js b/tybotRoute/test/conversation-form-test.js index f7a2909..f25bc0f 100644 --- a/tybotRoute/test/conversation-form-test.js +++ b/tybotRoute/test/conversation-form-test.js @@ -50,7 +50,7 @@ describe('Conversation1 - Form filling', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, @@ -278,7 +278,7 @@ describe('Conversation1 - Form filling', async () => { }); it('(intent-to-intent) /move_to => /target_intent', (done) => { - console.log("ALWAYS PASSES: (intent-to-intent) /move_to => /target_intent"); + // console.log("ALWAYS PASSES: (intent-to-intent) /move_to => /target_intent"); try { let listener; let endpointServer = express(); diff --git a/tybotRoute/test/conversation-gpt_assistant_test.js_ b/tybotRoute/test/conversation-gpt_assistant_test.js_ index e4754b4..c8a31f5 100644 --- a/tybotRoute/test/conversation-gpt_assistant_test.js_ +++ b/tybotRoute/test/conversation-gpt_assistant_test.js_ @@ -29,7 +29,7 @@ describe('Conversation for DirAssistant test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-gpt_task_test.js b/tybotRoute/test/conversation-gpt_task_test.js index 1408f44..913f661 100644 --- a/tybotRoute/test/conversation-gpt_task_test.js +++ b/tybotRoute/test/conversation-gpt_task_test.js @@ -31,7 +31,7 @@ describe('Conversation for GptTask test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-hubspot_test.js b/tybotRoute/test/conversation-hubspot_test.js index b7bfe8b..ae47fe1 100644 --- a/tybotRoute/test/conversation-hubspot_test.js +++ b/tybotRoute/test/conversation-hubspot_test.js @@ -31,7 +31,7 @@ describe('Conversation for hubspot test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-intent_with_json_attributes_test.js b/tybotRoute/test/conversation-intent_with_json_attributes_test.js index 361fa08..e1b2f5f 100644 --- a/tybotRoute/test/conversation-intent_with_json_attributes_test.js +++ b/tybotRoute/test/conversation-intent_with_json_attributes_test.js @@ -29,7 +29,7 @@ describe('Conversation for Intent JSON Attributes test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-locked-intent-test.js b/tybotRoute/test/conversation-locked-intent-test.js index 908cbd3..6edf515 100644 --- a/tybotRoute/test/conversation-locked-intent-test.js +++ b/tybotRoute/test/conversation-locked-intent-test.js @@ -27,7 +27,7 @@ describe('Conversation1 - Form filling', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-make_test.js b/tybotRoute/test/conversation-make_test.js index 7cdc40d..2206a4e 100644 --- a/tybotRoute/test/conversation-make_test.js +++ b/tybotRoute/test/conversation-make_test.js @@ -31,7 +31,7 @@ describe('Conversation for make test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-message_metadata_test.js b/tybotRoute/test/conversation-message_metadata_test.js index cfa73a3..943ad4b 100644 --- a/tybotRoute/test/conversation-message_metadata_test.js +++ b/tybotRoute/test/conversation-message_metadata_test.js @@ -29,7 +29,7 @@ describe('Conversation for message.metadata test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-native_block_connector_test.js b/tybotRoute/test/conversation-native_block_connector_test.js index 333352b..7d65ecf 100644 --- a/tybotRoute/test/conversation-native_block_connector_test.js +++ b/tybotRoute/test/conversation-native_block_connector_test.js @@ -29,7 +29,7 @@ describe('Conversation for Intent JSON Attributes test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-open_hours_test.js b/tybotRoute/test/conversation-open_hours_test.js index 2c1523c..5874bce 100644 --- a/tybotRoute/test/conversation-open_hours_test.js +++ b/tybotRoute/test/conversation-open_hours_test.js @@ -32,7 +32,7 @@ describe('Conversation for Operating Hours test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-qapla_test.js b/tybotRoute/test/conversation-qapla_test.js index 118ec2a..e207311 100644 --- a/tybotRoute/test/conversation-qapla_test.js +++ b/tybotRoute/test/conversation-qapla_test.js @@ -31,7 +31,7 @@ describe('Conversation for Qapla test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-reply_test.js b/tybotRoute/test/conversation-reply_test.js index 57ec84a..0a057b3 100644 --- a/tybotRoute/test/conversation-reply_test.js +++ b/tybotRoute/test/conversation-reply_test.js @@ -31,7 +31,7 @@ describe('Conversation for Reply test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-replyv2_button_match_test.js b/tybotRoute/test/conversation-replyv2_button_match_test.js index 66fcb56..b82a69d 100644 --- a/tybotRoute/test/conversation-replyv2_button_match_test.js +++ b/tybotRoute/test/conversation-replyv2_button_match_test.js @@ -31,7 +31,7 @@ describe('Conversation for Reply v2 test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-replyv2_noinput_test.js b/tybotRoute/test/conversation-replyv2_noinput_test.js index 70e7e46..f37db92 100644 --- a/tybotRoute/test/conversation-replyv2_noinput_test.js +++ b/tybotRoute/test/conversation-replyv2_noinput_test.js @@ -31,7 +31,7 @@ describe('Conversation for Reply v2 test (noInput)', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-send_whatsapp_test.js b/tybotRoute/test/conversation-send_whatsapp_test.js index 111da9d..d923955 100644 --- a/tybotRoute/test/conversation-send_whatsapp_test.js +++ b/tybotRoute/test/conversation-send_whatsapp_test.js @@ -31,7 +31,7 @@ describe('Conversation for GptTask test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-set_attributev2_action_test.js b/tybotRoute/test/conversation-set_attributev2_action_test.js index 9e52628..1c1ce96 100644 --- a/tybotRoute/test/conversation-set_attributev2_action_test.js +++ b/tybotRoute/test/conversation-set_attributev2_action_test.js @@ -29,7 +29,7 @@ describe('Conversation for Set Attribute (v2) Action test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-web_request_assign_json_test.js b/tybotRoute/test/conversation-web_request_assign_json_test.js index 1e0d085..a1d5000 100644 --- a/tybotRoute/test/conversation-web_request_assign_json_test.js +++ b/tybotRoute/test/conversation-web_request_assign_json_test.js @@ -29,7 +29,7 @@ describe('Conversation for WebRequest assign test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-web_request_test_DEPRECATED.js_ b/tybotRoute/test/conversation-web_request_test_DEPRECATED.js_ index 827669b..02a56a6 100644 --- a/tybotRoute/test/conversation-web_request_test_DEPRECATED.js_ +++ b/tybotRoute/test/conversation-web_request_test_DEPRECATED.js_ @@ -27,7 +27,7 @@ describe('DEPRECATED TEST', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-web_requestv2_test.js b/tybotRoute/test/conversation-web_requestv2_test.js index 4747ac1..527400a 100644 --- a/tybotRoute/test/conversation-web_requestv2_test.js +++ b/tybotRoute/test/conversation-web_requestv2_test.js @@ -29,7 +29,7 @@ describe('Conversation for WebRequestV2 test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/conversation-webhook_test.js b/tybotRoute/test/conversation-webhook_test.js index 4d9194c..5345ff9 100644 --- a/tybotRoute/test/conversation-webhook_test.js +++ b/tybotRoute/test/conversation-webhook_test.js @@ -32,7 +32,7 @@ describe('Conversation for Webhook test', async () => { try { tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/json_condition-conversation_test.js b/tybotRoute/test/json_condition-conversation_test.js index fd939e2..c79529e 100644 --- a/tybotRoute/test/json_condition-conversation_test.js +++ b/tybotRoute/test/json_condition-conversation_test.js @@ -29,7 +29,7 @@ describe('Conversation for JSONCondition test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/test/json_condition-with-intent-params-conversation_test.js b/tybotRoute/test/json_condition-with-intent-params-conversation_test.js index f40cb84..e4f14f3 100644 --- a/tybotRoute/test/json_condition-with-intent-params-conversation_test.js +++ b/tybotRoute/test/json_condition-with-intent-params-conversation_test.js @@ -29,7 +29,7 @@ describe('Conversation for JSONCondition with intent params test', async () => { console.log("Starting tilebot server..."); tybot.startApp( { - // MONGODB_URI: process.env.mongoUrl, + // MONGODB_URI: process.env.MONGODB_URI, bots: bots_data, API_ENDPOINT: process.env.API_ENDPOINT, REDIS_HOST: process.env.REDIS_HOST, diff --git a/tybotRoute/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js b/tybotRoute/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js index 504b1d7..aee2a57 100644 --- a/tybotRoute/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js +++ b/tybotRoute/tiledeskChatbotPlugs/directives/DirReplaceBotV2.js @@ -2,6 +2,9 @@ const { TiledeskClient } = require('@tiledesk/tiledesk-client'); const { TiledeskChatbot } = require('../../models/TiledeskChatbot'); const { Filler } = require('../Filler'); +const axios = require("axios").default; +let https = require("https"); + class DirReplaceBotV2 { constructor(context) { @@ -52,30 +55,132 @@ class DirReplaceBotV2 { ); const filler = new Filler(); botName = filler.fill(botName, variables); - this.tdClient.replaceBotByName(this.requestId, botName, () => { - if (blockName) { - if (this.log) {console.log("Sending hidden /start message to bot in dept");} - const message = { - type: "text", - text: "/" + blockName, - attributes : { - subtype: "info" + + let data = {}; + if (action.nameAsSlug && action.nameAsSlug === true) { + data.slug = botName; + } else { + data.name = botName; + } + + const HTTPREQUEST = { + url: this.API_ENDPOINT + "/" + this.context.projectId + "/requests/" + this.requestId + "/replace", + headers: { + 'Content-Type': 'application/json', + 'Authorization': 'JWT ' + this.context.token + }, + json: data, + method: 'PUT' + } + + this.#myrequest( + HTTPREQUEST, async (err, resbody) => { + if (err) { + console.log("DirReplaceBot error: ", err); + if (callback) { + callback(); + return; } } - this.tdClient.sendSupportMessage( - this.requestId, - message, (err) => { - if (err) { - console.error("Error sending hidden message:", err.message); + + if (this.log) { console.log("DirReplaceBot replace resbody: ", resbody) }; + if (blockName) { + if (this.log) { console.log("Sending hidden /start message to bot in dept"); } + const message = { + type: "text", + text: "/" + blockName, + attributes: { + subtype: "info" } - if (this.log) {console.log("Hidden message sent.");} - callback(); - }); - } - else { - callback(); + } + this.tdClient.sendSupportMessage( + this.requestId, + message, (err) => { + if (err) { + console.error("Error sending hidden message:", err.message); + } + if (this.log) { console.log("Hidden message sent."); } + callback(); + }); + } + else { + callback(); + } } - }); + ) + + // this.tdClient.replaceBotByName(this.requestId, botName, () => { + // if (blockName) { + // if (this.log) {console.log("Sending hidden /start message to bot in dept");} + // const message = { + // type: "text", + // text: "/" + blockName, + // attributes : { + // subtype: "info" + // } + // } + // this.tdClient.sendSupportMessage( + // this.requestId, + // message, (err) => { + // if (err) { + // console.error("Error sending hidden message:", err.message); + // } + // if (this.log) {console.log("Hidden message sent.");} + // callback(); + // }); + // } + // else { + // callback(); + // } + // }); + } + + #myrequest(options, callback) { + if (this.log) { + console.log("API URL:", options.url); + console.log("** Options:", JSON.stringify(options)); + } + let axios_options = { + url: options.url, + method: options.method, + params: options.params, + headers: options.headers + } + if (options.json !== null) { + axios_options.data = options.json + } + if (this.log) { + console.log("axios_options:", JSON.stringify(axios_options)); + } + if (options.url.startsWith("https:")) { + const httpsAgent = new https.Agent({ + rejectUnauthorized: false, + }); + axios_options.httpsAgent = httpsAgent; + } + axios(axios_options) + .then((res) => { + if (this.log) { + console.log("Response for url:", options.url); + console.log("Response headers:\n", JSON.stringify(res.headers)); + } + if (res && res.status == 200 && res.data) { + if (callback) { + callback(null, res.data); + } + } + else { + if (callback) { + callback(new Error("Response status is not 200"), null); + } + } + }) + .catch((error) => { + console.error("(DirAskGPT) Axios error: ", JSON.stringify(error)); + if (callback) { + callback(error, null); + } + }); } }