new(all): Facebook Workplace bot framework integration.

This commit is contained in:
Rodrigo Rodriguez 2021-06-09 16:03:46 -03:00
parent 9cb4d11505
commit d9e61157a2
4 changed files with 354 additions and 12 deletions

309
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "botserver",
"version": "2.0.113",
"version": "2.0.119",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@ -3019,7 +3019,6 @@
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
"integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
"dev": true,
"requires": {
"es6-promisify": "^5.0.0"
}
@ -4518,6 +4517,47 @@
}
}
},
"botbuilder-adapter-facebook": {
"version": "1.0.11",
"resolved": "https://registry.npmjs.org/botbuilder-adapter-facebook/-/botbuilder-adapter-facebook-1.0.11.tgz",
"integrity": "sha512-Pknl3Yr+jHnUcP//y1xjyBWyG0oImdlcLjcAnBSHIX1DIrMtzr22h+uwaB2WRzmHXxFtMYnIbl8qcg1uJweCzg==",
"requires": {
"botbuilder": "^4.10.1",
"botkit": "^4.10.0",
"debug": "^4.1.0"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": {
"ms": "2.1.2"
}
}
}
},
"botbuilder-adapter-hangouts": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/botbuilder-adapter-hangouts/-/botbuilder-adapter-hangouts-1.0.8.tgz",
"integrity": "sha512-KuwdTuEPcwcI8yCXW4wU/fd2QHsw/yXIMPZ3L5A7f7jW7Y8k6tLU37fljMbGnNW+GblnK5Hy7lFtfiPkXWyRvw==",
"requires": {
"botbuilder": "^4.10.1",
"botkit": "^4.10.0",
"debug": "^4.1.0",
"googleapis": "^34.0.0"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": {
"ms": "2.1.2"
}
}
}
},
"botbuilder-ai": {
"version": "4.11.0",
"resolved": "https://registry.npmjs.org/botbuilder-ai/-/botbuilder-ai-4.11.0.tgz",
@ -4684,6 +4724,33 @@
"ws": "^7.1.2"
}
},
"botkit": {
"version": "4.10.0",
"resolved": "https://registry.npmjs.org/botkit/-/botkit-4.10.0.tgz",
"integrity": "sha512-0++POhvSAy1KwjKLF6euxZ3sTXRk53/M1JBcLHwNRJ195EK97MvKdwocOoSe8MpXW2rFhcv3GZObEBBncNZq/Q==",
"requires": {
"body-parser": "^1.19.0",
"botbuilder": "^4.10.1",
"botbuilder-core": "^4.10.1",
"botbuilder-dialogs": "^4.10.1",
"botframework-connector": "^4.10.1",
"debug": "^4.1.0",
"express": "^4.17.1",
"mustache": "^4.0.1",
"path": "^0.12.7",
"ware": "^1.3.0"
},
"dependencies": {
"debug": {
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz",
"integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==",
"requires": {
"ms": "2.1.2"
}
}
}
},
"botlib": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/botlib/-/botlib-1.7.1.tgz",
@ -5585,6 +5652,11 @@
"shimmer": "^1.1.0"
}
},
"co": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/co/-/co-3.1.0.tgz",
"integrity": "sha1-TqVOpaCJOBUxheFSEMaNkJK8G3g="
},
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
@ -8922,6 +8994,54 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
"gaxios": {
"version": "1.8.4",
"resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.4.tgz",
"integrity": "sha512-BoENMnu1Gav18HcpV9IleMPZ9exM+AvUjrAOV4Mzs/vfz2Lu/ABv451iEXByKiMPn2M140uul1txXCg83sAENw==",
"requires": {
"abort-controller": "^3.0.0",
"extend": "^3.0.2",
"https-proxy-agent": "^2.2.1",
"node-fetch": "^2.3.0"
},
"dependencies": {
"https-proxy-agent": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz",
"integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==",
"requires": {
"agent-base": "^4.3.0",
"debug": "^3.1.0"
}
}
}
},
"gcp-metadata": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-0.7.0.tgz",
"integrity": "sha512-ffjC09amcDWjh3VZdkDngIo7WoluyC5Ag9PAYxZbmQLOLNI8lvPtoKTSCyU54j2gwy5roZh6sSMTfkY2ct7K3g==",
"requires": {
"axios": "^0.18.0",
"extend": "^3.0.1",
"retry-axios": "0.3.2"
},
"dependencies": {
"axios": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"is-buffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
}
}
},
"gensync": {
"version": "1.0.0-beta.1",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
@ -9312,11 +9432,122 @@
}
}
},
"google-auth-library": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-2.0.2.tgz",
"integrity": "sha512-FURxmo1hBVmcfLauuMRKOPYAPKht3dGuI2wjeJFalDUThO0HoYVjr4yxt5cgYSFm1dgUpmN9G/poa7ceTFAIiA==",
"requires": {
"axios": "^0.18.0",
"gcp-metadata": "^0.7.0",
"gtoken": "^2.3.0",
"https-proxy-agent": "^2.2.1",
"jws": "^3.1.5",
"lru-cache": "^5.0.0",
"semver": "^5.5.0"
},
"dependencies": {
"axios": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"https-proxy-agent": {
"version": "2.2.4",
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz",
"integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==",
"requires": {
"agent-base": "^4.3.0",
"debug": "^3.1.0"
}
},
"is-buffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
},
"lru-cache": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz",
"integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==",
"requires": {
"yallist": "^3.0.2"
}
},
"yallist": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz",
"integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g=="
}
}
},
"google-libphonenumber": {
"version": "3.2.15",
"resolved": "https://registry.npmjs.org/google-libphonenumber/-/google-libphonenumber-3.2.15.tgz",
"integrity": "sha512-tbCIuzMoH34RdrbFRw5kijAZn/p6JMQvsgtr1glg2ugbwqrMPlOL8pHNK8cyGo9B6SXpcMm4hdyDqwomR+HPRg=="
},
"google-p12-pem": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.4.tgz",
"integrity": "sha512-SwLAUJqUfTB2iS+wFfSS/G9p7bt4eWcc2LyfvmUXe7cWp6p3mpxDo6LLI29MXdU6wvPcQ/up298X7GMC5ylAlA==",
"requires": {
"node-forge": "^0.8.0",
"pify": "^4.0.0"
},
"dependencies": {
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
}
}
},
"googleapis": {
"version": "34.0.0",
"resolved": "https://registry.npmjs.org/googleapis/-/googleapis-34.0.0.tgz",
"integrity": "sha512-nGfTSrlQF77HDNOHDy0ii3ET1h8Yap6QXxkfMZsre+7hBg91g4RsgrA50BgrOXpbNlQCBOGXWhUsa267kVeA/Q==",
"requires": {
"google-auth-library": "^2.0.0",
"googleapis-common": "^0.3.0"
}
},
"googleapis-common": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/googleapis-common/-/googleapis-common-0.3.0.tgz",
"integrity": "sha512-OqQ2iskzjPHLoM+AXk7e/TmEsdgxyAk8PVbMg0S8v2wPhgMu2wTawEL7zH9QG236u/RqQ1Ak120oSWsamPnWGg==",
"requires": {
"axios": "^0.18.0",
"google-auth-library": "^2.0.0",
"pify": "^3.0.0",
"qs": "^6.5.2",
"url-template": "^2.0.8",
"uuid": "^3.2.1"
},
"dependencies": {
"axios": {
"version": "0.18.1",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.18.1.tgz",
"integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
}
},
"is-buffer": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz",
"integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ=="
},
"pify": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz",
"integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY="
}
}
},
"got": {
"version": "9.6.0",
"resolved": "https://registry.npmjs.org/got/-/got-9.6.0.tgz",
@ -9365,6 +9596,30 @@
"ul": "^5.0.0"
}
},
"gtoken": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.3.tgz",
"integrity": "sha512-EaB49bu/TCoNeQjhCYKI/CurooBKkGxIqFHsWABW0b25fobBYVTMe84A8EBVVZhl8emiUdNypil9huMOTmyAnw==",
"requires": {
"gaxios": "^1.0.4",
"google-p12-pem": "^1.0.0",
"jws": "^3.1.5",
"mime": "^2.2.0",
"pify": "^4.0.0"
},
"dependencies": {
"mime": {
"version": "2.5.2",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.5.2.tgz",
"integrity": "sha512-tqkh47FzKeCPD2PUiPB6pkbMzsCasjxAfC62/Wap5qrUWcb+sFasXUC5I3gYM5iBM8v/Qpn4UK0x+j0iHyFPDg=="
},
"pify": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz",
"integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g=="
}
}
},
"handlebars": {
"version": "4.7.6",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz",
@ -12555,6 +12810,11 @@
}
}
},
"mustache": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz",
"integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ=="
},
"mute-stream": {
"version": "0.0.8",
"resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz",
@ -12708,6 +12968,11 @@
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
},
"node-forge": {
"version": "0.8.5",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz",
"integrity": "sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q=="
},
"node-gyp-build": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.2.3.tgz",
@ -17236,6 +17501,15 @@
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=",
"dev": true
},
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
}
},
"path-exists": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-2.1.0.tgz",
@ -18234,6 +18508,11 @@
"resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.2.2.tgz",
"integrity": "sha512-I+nkWY212lJ500jLe4tN9tWO7nRiBAVdMv76P9kffZjYhw20raMlW1HSSvS+MLXC9MmbNZCazMrAr+5jEEgTuw=="
},
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@ -18879,6 +19158,11 @@
"any-promise": "^1.3.0"
}
},
"retry-axios": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/retry-axios/-/retry-axios-0.3.2.tgz",
"integrity": "sha512-jp4YlI0qyDFfXiXGhkCOliBN1G7fRH03Nqy8YdShzGqbY5/9S2x/IR6C88ls2DFkbWuL3ASkP7QD3pVrNpPgwQ=="
},
"reusify": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz",
@ -22204,6 +22488,11 @@
"prepend-http": "^2.0.0"
}
},
"url-template": {
"version": "2.0.8",
"resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz",
"integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE="
},
"use": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
@ -22404,6 +22693,14 @@
"lodash": "^4.5.0"
}
},
"ware": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/ware/-/ware-1.3.0.tgz",
"integrity": "sha1-0bFPOdLiy0q4xAmPdW/ksWTkc9Q=",
"requires": {
"wrap-fn": "^0.1.0"
}
},
"washyourmouthoutwithsoap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/washyourmouthoutwithsoap/-/washyourmouthoutwithsoap-1.0.2.tgz",
@ -22596,6 +22893,14 @@
}
}
},
"wrap-fn": {
"version": "0.1.5",
"resolved": "https://registry.npmjs.org/wrap-fn/-/wrap-fn-0.1.5.tgz",
"integrity": "sha1-8htuQQFv9KfjFyDbxjoJAWvfmEU=",
"requires": {
"co": "3.1.0"
}
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View file

@ -67,6 +67,8 @@
"bluebird": "3.7.2",
"body-parser": "1.19.0",
"botbuilder": "4.11.0",
"botbuilder-adapter-facebook": "^1.0.11",
"botbuilder-adapter-hangouts": "^1.0.8",
"botbuilder-ai": "4.11.0",
"botbuilder-dialogs": "4.11.0",
"botframework-connector": "4.11.0",

View file

@ -917,7 +917,7 @@ export class GBConversationalService {
const analytics = new AnalyticsService();
analytics.createMessage(min.instance.instanceId, user.conversation, null, text);
if (!isNaN(member.id)) {
if (!isNaN(member.id) && !member.id.startsWith('1000')) {
await min.whatsAppDirectLine.sendToDevice(member.id, text);
} else {
await step.context.sendActivity(text);

View file

@ -35,14 +35,14 @@
*/
'use strict';
import urlJoin = require('url-join');
const { DialogSet, TextPrompt } = require('botbuilder-dialogs');
const express = require('express');
const request = require('request-promise-native');
const removeRoute = require('express-remove-route');
const AuthenticationContext = require('adal-node').AuthenticationContext;
const wash = require('washyourmouthoutwithsoap');
const { FacebookAdapter } = require('botbuilder-adapter-facebook');
const { HangoutsAdapter } = require('botbuilder-adapter-hangouts');
import {
AutoSaveStateMiddleware,
BotFrameworkAdapter,
@ -63,9 +63,7 @@ import {
IGBPackage
} from 'botlib';
import { CollectionUtil } from 'pragmatismo-io-framework';
import { MicrosoftAppCredentials } from 'botframework-connector';
import fs = require('fs');
import { GBServer } from '../../../src/app';
import { GBAdminService } from '../../admin.gbapp/services/GBAdminService';
import { GuaribasConversationMessage } from '../../analytics.gblib/models';
@ -79,6 +77,8 @@ import { Messages } from '../strings';
import { GBConfigService } from './GBConfigService';
import { GBConversationalService } from './GBConversationalService';
import { GBDeployer } from './GBDeployer';
import urlJoin = require('url-join');
import fs = require('fs');
/**
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
@ -162,6 +162,8 @@ export class GBMinService {
});
}
/**
* Removes bot endpoint from web listeners and remove bot instance
* from list of global server bot instances.
@ -220,10 +222,22 @@ export class GBMinService {
// Serves individual URL for each bot conversational interface.
const receiver = async (req, res) => {
await this.receiver(adapter, req, res, conversationState, min, instance, GBServer.globals.appPackages);
await this.receiver(req, res, conversationState, min, instance, GBServer.globals.appPackages);
};
const url = `/api/messages/${instance.botId}`;
GBServer.globals.server.post(url, receiver);
GBServer.globals.server.get(url, (req, res) => {
if (req.query['hub.mode'] === 'subscribe') {
if (req.query['hub.verify_token'] === process.env.FACEBOOK_VERIFY_TOKEN) {
const val = req.query['hub.challenge'];
res.send(val);
} else {
GBLog.error('Failed to verify endpoint.');
res.send('OK');
}
}
res.end();
});
GBLog.info(`GeneralBots(${instance.engineName}) listening on: ${url}.`);
// Serves individual URL for each bot user interface.
@ -601,6 +615,8 @@ export class GBMinService {
new Date(new Date().setFullYear(new Date().getFullYear() + 10))
);
// The minimal bot is built here.
const min = new GBMinInstance();
@ -618,6 +634,15 @@ export class GBMinService {
min.sandBoxMap = {};
min.packages = sysPackages;
min.appPackages = appPackages;
min['fbAdapter'] = new FacebookAdapter({
verify_token: process.env.FACEBOOK_VERIFY_TOKEN,
app_secret: process.env.FACEBOOK_APP_SECRET,
access_token: process.env.FACEBOOK_ACCESS_TOKEN
});
min['ggAdapter'] = new HangoutsAdapter({
token: process.env.GOOGLE_TOKEN
});
if (GBServer.globals.minBoot === undefined) {
GBServer.globals.minBoot = min;
}
@ -734,8 +759,7 @@ export class GBMinService {
/**
* BOT Framework web service hook method.
*/
private async receiver(
adapter: BotFrameworkAdapter,
private async receiver(
req: any,
res: any,
conversationState: ConversationState,
@ -744,9 +768,17 @@ export class GBMinService {
appPackages: any[]
) {
let adapter = min.bot;
if (req.body.object)
{
req['rawBody']=JSON.stringify(req.body);
adapter = min['fbAdapter'];
}
// Default activity processing and handler.
await adapter.processActivity(req, res, async context => {
await adapter['processActivity'](req, res, async context => {
// Get loaded user state
@ -754,6 +786,7 @@ export class GBMinService {
step.context.activity.locale = 'pt-BR';
let firstTime = false;
try {
const user = await min.userProfile.get(context, {});
@ -837,6 +870,8 @@ export class GBMinService {
}
}
// Required for F0 handling of persisted conversations.
GBLog.info(`User>: text:${context.activity.text} (type: ${context.activity.type}, name: ${context.activity.name}, channelId: ${context.activity.channelId}, value: ${context.activity.value})`);
// Answer to specific BOT Framework event conversationUpdate to auto start dialogs.
@ -1016,7 +1051,7 @@ export class GBMinService {
const args = parts.join(' ');
if (cmdOrDialogName === '/start') {
// TODO: Args to BASIC.
} else if (cmdOrDialogName === '/call') {
} else if (cmdOrDialogName === '/call') {
await GBVMService.callVM(args, min, step, this.deployer);
} else {
await step.beginDialog(cmdOrDialogName, { args: args });