fix(all): Packages updated and new DirectLine behaviour fixed.
This commit is contained in:
parent
9ab73495fb
commit
517689fafe
12 changed files with 13033 additions and 11419 deletions
|
@ -97,3 +97,11 @@ ALTER TABLE dbo.GuaribasQuestion ADD
|
||||||
skipIndex bit NULL
|
skipIndex bit NULL
|
||||||
GO
|
GO
|
||||||
|
|
||||||
|
# 2.0.116 >
|
||||||
|
|
||||||
|
|
||||||
|
ALTER TABLE dbo.GuaribasInstance ADD
|
||||||
|
googleBotKey nvarchar(255) NULL,
|
||||||
|
googleChatApiKey nvarchar(255) NULL,
|
||||||
|
googleChatSubscriptionName nvarchar(255) NULL,
|
||||||
|
GO
|
||||||
|
|
13
google-chat.json
Normal file
13
google-chat.json
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"type": "service_account",
|
||||||
|
"project_id": "eastern-amp-316323",
|
||||||
|
"private_key_id": "4105f7f4cf2293adf2f561f7649449dedf9ab839",
|
||||||
|
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCfIuztkRf8AZOr\ngOS8TDghQdme7eyvnT2Z+ly+9Q9D51frqsoKtbPJJSO9l3vX1qYGGEWHZlaPX5n6\nP1uTfYv9jjW9A2/oKZW/cV70O5wdFonn0sQblzC2+ZhlHuS6MQN0PqUvLNFGF57U\n5NCG3JUx1qhBHCPP5a/MXSXsvXTxngRtHfpKo2JbhsYXDHJl0+2DRJvx3+0WeIxW\ni7J2I0UXX4WlTORj9yaN4xVe/C2NPvQ+k9WGt1d2ql+F5w0ndnegOUOI8ZhQ3les\nw9KA0k1/ImC3q57+BIN5Xeg+NaY7r2gCEROqeDEs2v1TK9JsFhQJyvmLgjV64iLO\nogt677b5AgMBAAECggEAAymoCM6t6dnELA/rO9zN7sdGwnRbFGBtJX7G0hq/u2tB\nIZNq4Yyb7p74119H3FHNSei4lQjRJpdRUZppwQQpQJhPdBq54iTVb5EawILgxuk4\nQ226bQvzsWdDgpr7E8I+ndRS5x2eaSS2COglRtDifDOWc3jSM2MOu+KMCuj3BohD\n6NSnvewRqpaVQlpz5uqsPzZn77xyqW7xhpKPvU43RpBO1oSVWplX1nT65KpQjjC0\no+ry2bLRPtYq8SYWRXXTRaw4GkSZmam+QNxkDhGJzept38RcOQwjO5YOpfKDxcAp\nlgCPmq+DlhIHYWxgYEPyINXmU8UrUyD57LmSxKuUswKBgQDUKcXQHybOMyBjkAW+\nUh9zGaR0XegNgq3dpiN7cf9Z0ChghRVXTKuFP5GE08+5btcXbrCabmtZg1CM3BHL\nQ1Muj2xPHpMhE0+pjeFpSNljpyufyjActyfvbYH6CuaYnJKOrhce+FaMhIFRXsqI\no86tJxV3slglAj6bCY0WvSJ51wKBgQDABFbGT0uF+cUNJB9R1IBDZwpbom/iWi7t\nrbyR2J1FC1naxItN9tOm2Taq2iTX3UxIAM9Tu36dBgoq2ZZ6GAG6kiEFnaChDYho\nOnh9X1x9EJ8JnFyOFnDRB5OOSRfhDUn89/bjcx2Pgy4+r1eZQcdfqAjom6V52+7l\nFthSvYlbrwKBgFd89k5xWh4zpQqJbGTkFoXvMAqwYq2XkrzQ8tbH1oWhudS7bGZ4\nfk5PPWGpuoH7/AR0p6y3Fdtus/uyEEBifd24VPB3ajJ8dSA1GpvA56wZVnro9FgT\nCwvHe46xig+qmSDvFye1PnNpfK4iSaB49BQhBtA6IfD48PobwSt8SMg3AoGAIOod\nfczl40dXUdNZUwucGPG2wtJrX1+aH7/iTRXWj5lMg8WhI3ImAbnGNy9BlYcnpkgN\nQgsnvv7kC0hVFQS8dyDJbE8C09igA03SjZslHYMV3+3fp7ONDye/UWqSH0/J2QUg\nWwjGjm0sJi6kU28FIA6LyGO1z9e1caui1TwMKZ0CgYEAte4JER5zi/Gmb0Q/05XP\np7UHYjMbkpOW5FMp7aE5rd4LtCZrGDhZUhhKwHPNDIL5uirYQC4dkpGbbPRlmTy+\nXmvjSaqrlLWzvYK9o98a7f12AwxTEmULXd4U/eR4zbZuxpXrlD36YPONA7cbGQ4J\n/5RAByRbjc1dDtaI/m5BssQ=\n-----END PRIVATE KEY-----\n",
|
||||||
|
"client_email": "starting-account-otllxgcv9auu@eastern-amp-316323.iam.gserviceaccount.com",
|
||||||
|
"client_id": "103388169832798500398",
|
||||||
|
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
||||||
|
"token_uri": "https://oauth2.googleapis.com/token",
|
||||||
|
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
||||||
|
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/starting-account-otllxgcv9auu%40eastern-amp-316323.iam.gserviceaccount.com"
|
||||||
|
}
|
||||||
|
|
7325
package-lock.json
generated
7325
package-lock.json
generated
File diff suppressed because it is too large
Load diff
65
package.json
65
package.json
|
@ -48,15 +48,15 @@
|
||||||
"commit": "git-cz"
|
"commit": "git-cz"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@azure/ms-rest-js": "2.1.0",
|
"@azure/ms-rest-js": "2.5.1",
|
||||||
"@google-cloud/pubsub": "^2.13.0",
|
"@google-cloud/pubsub": "^2.13.0",
|
||||||
"@microsoft/microsoft-graph-client": "2.1.1",
|
"@microsoft/microsoft-graph-client": "2.2.1",
|
||||||
"@semantic-release/changelog": "5.0.1",
|
"@semantic-release/changelog": "5.0.1",
|
||||||
"@semantic-release/exec": "5.0.0",
|
"@semantic-release/exec": "5.0.0",
|
||||||
"@semantic-release/git": "9.0.0",
|
"@semantic-release/git": "9.0.0",
|
||||||
"@sendgrid/mail": "^7.4.2",
|
"@sendgrid/mail": "^7.4.4",
|
||||||
"@types/validator": "13.1.0",
|
"@types/validator": "13.1.4",
|
||||||
"adal-node": "0.2.1",
|
"adal-node": "0.2.2",
|
||||||
"any-shell-escape": "0.1.1",
|
"any-shell-escape": "0.1.1",
|
||||||
"async-promises": "0.2.3",
|
"async-promises": "0.2.3",
|
||||||
"azure-arm-cognitiveservices": "3.0.0",
|
"azure-arm-cognitiveservices": "3.0.0",
|
||||||
|
@ -67,34 +67,33 @@
|
||||||
"azure-search-client": "3.1.5",
|
"azure-search-client": "3.1.5",
|
||||||
"bluebird": "3.7.2",
|
"bluebird": "3.7.2",
|
||||||
"body-parser": "1.19.0",
|
"body-parser": "1.19.0",
|
||||||
"botbuilder": "4.11.0",
|
"botbuilder": "4.13.5",
|
||||||
"botbuilder-adapter-facebook": "^1.0.11",
|
"botbuilder-adapter-facebook": "^1.0.11",
|
||||||
"botbuilder-adapter-hangouts": "^1.0.8",
|
"botbuilder-ai": "4.13.5",
|
||||||
"botbuilder-ai": "4.11.0",
|
"botbuilder-dialogs": "4.13.5",
|
||||||
"botbuilder-dialogs": "4.11.0",
|
"botframework-connector": "4.13.5",
|
||||||
"botframework-connector": "4.11.0",
|
"botlib": "1.8.1",
|
||||||
"botlib": "1.7.1",
|
|
||||||
"cli-spinner": "0.2.10",
|
"cli-spinner": "0.2.10",
|
||||||
"core-js": "3.7.0",
|
"core-js": "3.14.0",
|
||||||
"dotenv-extended": "2.9.0",
|
"dotenv-extended": "2.9.0",
|
||||||
"exceljs": "4.2.0",
|
"exceljs": "4.2.1",
|
||||||
"express": "4.17.1",
|
"express": "4.17.1",
|
||||||
"express-remove-route": "1.0.0",
|
"express-remove-route": "1.0.0",
|
||||||
"ffmpeg-static": "4.2.7",
|
"ffmpeg-static": "4.3.0",
|
||||||
"google-libphonenumber": "3.2.15",
|
"google-libphonenumber": "3.2.21",
|
||||||
"googleapis": "^76.0.0",
|
"googleapis": "^76.0.0",
|
||||||
"ibm-watson": "5.7.1",
|
"ibm-watson": "6.1.1",
|
||||||
"js-beautify": "1.13.0",
|
"js-beautify": "1.13.13",
|
||||||
"marked": "1.2.5",
|
"marked": "2.0.7",
|
||||||
"microsoft-cognitiveservices-speech-sdk": "1.14.1",
|
"microsoft-cognitiveservices-speech-sdk": "1.17.0",
|
||||||
"ms-rest-azure": "3.0.0",
|
"ms-rest-azure": "3.0.0",
|
||||||
"nexmo": "2.9.1",
|
"nexmo": "2.9.1",
|
||||||
"node-cron": "2.0.3",
|
"node-cron": "3.0.0",
|
||||||
"opn": "6.0.0",
|
"opn": "6.0.0",
|
||||||
"phone": "2.4.17",
|
"phone": "2.4.21",
|
||||||
"pragmatismo-io-framework": "1.0.20",
|
"pragmatismo-io-framework": "1.0.20",
|
||||||
"prism-media": "1.2.2",
|
"prism-media": "1.3.1",
|
||||||
"public-ip": "4.0.2",
|
"public-ip": "4.0.4",
|
||||||
"readline": "1.3.0",
|
"readline": "1.3.0",
|
||||||
"reflect-metadata": "0.1.13",
|
"reflect-metadata": "0.1.13",
|
||||||
"request-promise": "4.2.5",
|
"request-promise": "4.2.5",
|
||||||
|
@ -104,14 +103,14 @@
|
||||||
"scanf": "1.1.2",
|
"scanf": "1.1.2",
|
||||||
"sequelize": "5.21.5",
|
"sequelize": "5.21.5",
|
||||||
"sequelize-typescript": "1.1.0",
|
"sequelize-typescript": "1.1.0",
|
||||||
"simple-git": "2.23.0",
|
"simple-git": "2.39.1",
|
||||||
"speakingurl": "^14.0.1",
|
"speakingurl": "^14.0.1",
|
||||||
"sppull": "2.6.7",
|
"sppull": "2.7.0",
|
||||||
"strict-password-generator": "1.1.2",
|
"strict-password-generator": "1.1.2",
|
||||||
"swagger-client": "2.1.18",
|
"swagger-client": "2.1.18",
|
||||||
"tedious": "9.2.1",
|
"tedious": "9.2.1",
|
||||||
"textract": "2.5.0",
|
"textract": "2.5.0",
|
||||||
"typescript": "4.1.2",
|
"typescript": "4.3.2",
|
||||||
"url-join": "4.0.1",
|
"url-join": "4.0.1",
|
||||||
"vbscript-to-typescript": "1.0.8",
|
"vbscript-to-typescript": "1.0.8",
|
||||||
"walk-promise": "0.2.0",
|
"walk-promise": "0.2.0",
|
||||||
|
@ -120,22 +119,22 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/url-join": "4.0.0",
|
"@types/url-join": "4.0.0",
|
||||||
"@types/winston": "2.4.4",
|
"@types/winston": "2.4.4",
|
||||||
"ban-sensitive-files": "1.9.14",
|
"ban-sensitive-files": "1.9.15",
|
||||||
"commitizen": "4.2.2",
|
"commitizen": "4.2.4",
|
||||||
"cz-conventional-changelog": "3.3.0",
|
"cz-conventional-changelog": "3.3.0",
|
||||||
"dependency-check": "4.1.0",
|
"dependency-check": "4.1.0",
|
||||||
"git-issues": "1.3.1",
|
"git-issues": "1.3.1",
|
||||||
"license-checker": "25.0.1",
|
"license-checker": "25.0.1",
|
||||||
"ngrok": "3.3.0",
|
"ngrok": "4.0.1",
|
||||||
"nsp": "3.2.1",
|
"nsp": "3.2.1",
|
||||||
"prettier-standard": "16.4.1",
|
"prettier-standard": "16.4.1",
|
||||||
"semantic-release": "17.2.4",
|
"semantic-release": "17.4.3",
|
||||||
"simple-commit-message": "4.0.13",
|
"simple-commit-message": "4.1.2",
|
||||||
"travis-deploy-once": "5.0.11",
|
"travis-deploy-once": "5.0.11",
|
||||||
"ts-node": "9.0.0",
|
"ts-node": "10.0.0",
|
||||||
"tslint": "6.1.2",
|
"tslint": "6.1.2",
|
||||||
"tslint-microsoft-contrib": "^6.2.0",
|
"tslint-microsoft-contrib": "^6.2.0",
|
||||||
"typedoc": "0.19.2"
|
"typedoc": "0.20.36"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"env": {
|
"env": {
|
||||||
|
|
|
@ -83,8 +83,7 @@ export class SystemKeywords {
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
encoding: 'binary'
|
encoding: 'binary'
|
||||||
};
|
};
|
||||||
const res = await request(options);
|
return await request(options); // TODO: Check this.
|
||||||
Buffer.from(res, 'binary').toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -133,6 +133,15 @@ export class GuaribasInstance extends Model<GuaribasInstance>
|
||||||
@Column
|
@Column
|
||||||
public cloudLocation: string;
|
public cloudLocation: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
public googleBotKey: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
public googleChatApiKey: string;
|
||||||
|
|
||||||
|
@Column
|
||||||
|
public googleChatSubscriptionName: string;
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
public whatsappBotKey: string;
|
public whatsappBotKey: string;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ const removeRoute = require('express-remove-route');
|
||||||
const AuthenticationContext = require('adal-node').AuthenticationContext;
|
const AuthenticationContext = require('adal-node').AuthenticationContext;
|
||||||
const wash = require('washyourmouthoutwithsoap');
|
const wash = require('washyourmouthoutwithsoap');
|
||||||
const { FacebookAdapter } = require('botbuilder-adapter-facebook');
|
const { FacebookAdapter } = require('botbuilder-adapter-facebook');
|
||||||
const { HangoutsAdapter } = require('botbuilder-adapter-hangouts');
|
|
||||||
import {
|
import {
|
||||||
AutoSaveStateMiddleware,
|
AutoSaveStateMiddleware,
|
||||||
BotFrameworkAdapter,
|
BotFrameworkAdapter,
|
||||||
|
@ -652,14 +651,13 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let GoogleChatSubscriptionName = '';
|
|
||||||
let GoogleWebChatKey = '';
|
|
||||||
|
|
||||||
min['googleDirectLine'] = new GoogleChatDirectLine(
|
min['googleDirectLine'] = new GoogleChatDirectLine(
|
||||||
min,
|
min,
|
||||||
min.botId,
|
min.botId,
|
||||||
GoogleWebChatKey,
|
min.instance.googleBotKey,
|
||||||
GoogleChatSubscriptionName
|
min.instance.googleChatSubscriptionName,
|
||||||
|
min.instance.googleChatApiKey
|
||||||
);
|
);
|
||||||
await min['googleDirectLine'].setup(true);
|
await min['googleDirectLine'].setup(true);
|
||||||
|
|
||||||
|
@ -807,14 +805,6 @@ export class GBMinService {
|
||||||
|
|
||||||
firstTime = true;
|
firstTime = true;
|
||||||
|
|
||||||
// Sends loadInstance event to .gbui clients and loads FAQ.
|
|
||||||
|
|
||||||
await min.conversationalService.sendEvent(min, step, 'loadInstance', {
|
|
||||||
instanceId: instance.instanceId,
|
|
||||||
botId: instance.botId,
|
|
||||||
theme: instance.theme ? instance.theme : 'default.gbtheme',
|
|
||||||
secret: instance.webchatKey
|
|
||||||
});
|
|
||||||
const service = new KBService(min.core.sequelize);
|
const service = new KBService(min.core.sequelize);
|
||||||
const data = await service.getFaqBySubjectArray(instance.instanceId, 'faq', undefined);
|
const data = await service.getFaqBySubjectArray(instance.instanceId, 'faq', undefined);
|
||||||
await min.conversationalService.sendEvent(min, step, 'play', {
|
await min.conversationalService.sendEvent(min, step, 'play', {
|
||||||
|
|
16856
packages/default.gbui/package-lock.json
generated
16856
packages/default.gbui/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -8,22 +8,22 @@
|
||||||
"homepage": ".",
|
"homepage": ".",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@midudev/react-static-content": "^1.0.4",
|
"@midudev/react-static-content": "^1.0.4",
|
||||||
"ajv": "^6.10.2",
|
"ajv": "^8.6.0",
|
||||||
"botframework-directlinejs": "0.11.6",
|
"botframework-directlinejs": "0.14.1",
|
||||||
"botframework-webchat": "^4.7.1",
|
"botframework-webchat": "^4.13.0",
|
||||||
"deep-extend": "0.6.0",
|
"deep-extend": "0.6.0",
|
||||||
"fetch": "1.1.0",
|
"fetch": "1.1.0",
|
||||||
"msal": "^1.2.0",
|
"msal": "^1.4.11",
|
||||||
"powerbi-client": "2.10.2",
|
"powerbi-client": "2.18.0",
|
||||||
"react": "^16.12.0",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^16.12.0",
|
"react-dom": "^17.0.2",
|
||||||
"react-helmet": "5.2.1",
|
"react-helmet": "6.1.0",
|
||||||
"react-player": "^1.14.2",
|
"react-player": "^2.9.0",
|
||||||
"react-powerbi": "0.5.2",
|
"react-powerbi": "0.9.1",
|
||||||
"react-scripts": "^3.3.0",
|
"react-scripts": "^4.0.3",
|
||||||
"react-super-seo": "^1.0.5",
|
"react-super-seo": "^1.0.6",
|
||||||
"react-transition-group": "^4.3.0",
|
"react-transition-group": "^4.4.2",
|
||||||
"rxjs": "^6.5.4",
|
"rxjs": "^7.1.0",
|
||||||
"url-join": "4.0.1"
|
"url-join": "4.0.1"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
|
@ -52,7 +52,6 @@ class GBUIApp extends React.Component {
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
line: null,
|
line: null,
|
||||||
instance: null,
|
|
||||||
token: null,
|
token: null,
|
||||||
instanceClient: null
|
instanceClient: null
|
||||||
};
|
};
|
||||||
|
@ -132,8 +131,7 @@ class GBUIApp extends React.Component {
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
.then(
|
.then(
|
||||||
result => {
|
result => {
|
||||||
this.setState({ instanceClient: result });
|
this.setupBotConnection(result);
|
||||||
this.setupBotConnection();
|
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -166,7 +164,8 @@ class GBUIApp extends React.Component {
|
||||||
);
|
);
|
||||||
window.userAgentApplication = userAgentApplication;
|
window.userAgentApplication = userAgentApplication;
|
||||||
|
|
||||||
if (!userAgentApplication.isCallback(window.location.hash) && window.parent === window && !window.opener) {
|
if (!userAgentApplication.isCallback(window.location.hash) && window.parent === window
|
||||||
|
&& !window.opener && userAgentApplication.getUser) {
|
||||||
var user = userAgentApplication.getUser();
|
var user = userAgentApplication.getUser();
|
||||||
if (user) {
|
if (user) {
|
||||||
userAgentApplication.acquireTokenSilent(graphScopes).then(
|
userAgentApplication.acquireTokenSilent(graphScopes).then(
|
||||||
|
@ -181,32 +180,32 @@ class GBUIApp extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setupBotConnection() {
|
setupBotConnection(instanceClient) {
|
||||||
let _this_ = this;
|
let _this_ = this;
|
||||||
window['botchatDebug'] = true;
|
window['botchatDebug'] = true;
|
||||||
|
|
||||||
const line = new DirectLine({
|
const line = new DirectLine({
|
||||||
token: this.state.instanceClient.webchatToken
|
token: instanceClient.webchatToken
|
||||||
});
|
});
|
||||||
|
_this_.setState({ line: line});
|
||||||
|
|
||||||
line.connectionStatus$.subscribe(connectionStatus => {
|
line.connectionStatus$.subscribe(connectionStatus => {
|
||||||
if (connectionStatus === ConnectionStatus.Online) {
|
if (connectionStatus === ConnectionStatus.Online) {
|
||||||
_this_.setState({ line: line });
|
_this_.setState({ instanceClient: instanceClient});
|
||||||
window['botConnection'] = line;
|
window['botConnection'] = line;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.line = line;
|
window.line = line;
|
||||||
|
|
||||||
line.activity$
|
line.activity$
|
||||||
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
.filter(activity => activity.type === 'event' && activity.name === 'loadInstance')
|
||||||
.subscribe(activity => {
|
.subscribe(activity => {
|
||||||
this.postEvent('startGB', true);
|
this.postEvent('startGB', true);
|
||||||
_this_.setState({ instance: activity.value });
|
_this_.authenticate();
|
||||||
_this_.authenticate();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
line.activity$
|
line.activity$
|
||||||
.filter(activity => activity.type === 'event' && activity.name === 'stop')
|
.filter(activity => activity.type === 'event' && activity.name === 'stop')
|
||||||
.subscribe(activity => {
|
.subscribe(activity => {
|
||||||
if (_this_.player) {
|
if (_this_.player) {
|
||||||
|
@ -313,16 +312,17 @@ class GBUIApp extends React.Component {
|
||||||
|
|
||||||
let sideBar = (
|
let sideBar = (
|
||||||
<div className="sidebar">
|
<div className="sidebar">
|
||||||
<SidebarMenu chat={this.chat} instance={this.state.instance} />
|
<SidebarMenu chat={this.chat} instance={this.state.instanceClient} />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.state.line && this.state.instance) {
|
if (this.state.instanceClient) {
|
||||||
|
|
||||||
gbCss = <GBCss instance={this.state.instance} />;
|
gbCss = <GBCss instance={this.state.instanceClient} />;
|
||||||
seo = <SEO instance={this.state.instance} />;
|
seo = <SEO instance={this.state.instanceClient} />;
|
||||||
|
}
|
||||||
// let speechOptions;
|
if (this.state.line) {
|
||||||
|
// let speechOptions;
|
||||||
// let token = this.state.instanceClient.speechToken;
|
// let token = this.state.instanceClient.speechToken;
|
||||||
|
|
||||||
// speechOptions = {
|
// speechOptions = {
|
||||||
|
@ -352,7 +352,7 @@ class GBUIApp extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.state.instance) {
|
if (!this.state.instanceClient) {
|
||||||
sideBar = '';
|
sideBar = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class GBUrlPlayer extends Component {
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="gb-video-player-wrapper">
|
<div className="gb-video-player-wrapper">
|
||||||
<iframe ref="video"
|
<iframe title="Video" ref="video"
|
||||||
className="gb-video-react-player"
|
className="gb-video-react-player"
|
||||||
src={this.state.src}
|
src={this.state.src}
|
||||||
width="100%"
|
width="100%"
|
||||||
|
|
|
@ -43,6 +43,9 @@ import { GBConversationalService } from '../../core.gbapp/services/GBConversatio
|
||||||
import { SecService } from '../../security.gbapp/services/SecService';
|
import { SecService } from '../../security.gbapp/services/SecService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
const { google } = require('googleapis')
|
const { google } = require('googleapis')
|
||||||
|
const chat = google.chat('v1');
|
||||||
|
const { promisify } = require('util');
|
||||||
|
chat.spaces.messages.createAsync = promisify(chat.spaces.messages.create);
|
||||||
const { PubSub } = require('@google-cloud/pubsub');
|
const { PubSub } = require('@google-cloud/pubsub');
|
||||||
|
|
||||||
// Creates a client; cache this for further use
|
// Creates a client; cache this for further use
|
||||||
|
@ -64,12 +67,14 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
public min: GBMinInstance;
|
public min: GBMinInstance;
|
||||||
private directLineSecret: string;
|
private directLineSecret: string;
|
||||||
pubSubClient: any;
|
pubSubClient: any;
|
||||||
|
GoogleChatApiKey: any;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
min: GBMinInstance,
|
min: GBMinInstance,
|
||||||
botId,
|
botId,
|
||||||
directLineSecret,
|
directLineSecret,
|
||||||
GoogleChatSubscriptionName
|
GoogleChatSubscriptionName,
|
||||||
|
GoogleChatApiKey,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
@ -78,6 +83,7 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
this.directLineSecret = directLineSecret;
|
this.directLineSecret = directLineSecret;
|
||||||
this.GoogleChatSubscriptionName = GoogleChatSubscriptionName;
|
this.GoogleChatSubscriptionName = GoogleChatSubscriptionName;
|
||||||
this.pubSubClient = new PubSub();
|
this.pubSubClient = new PubSub();
|
||||||
|
this.GoogleChatApiKey = GoogleChatApiKey;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +113,7 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const subscription = this.pubSubClient.subscription(this.GoogleChatSubscriptionName);
|
const subscription = this.pubSubClient.subscription(this.GoogleChatSubscriptionName);
|
||||||
subscription.on('message', this.receiver);
|
subscription.on('message', this.receiver.bind(this));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error initializing 3rd party GoogleChat provider(1) ${error.message}`);
|
GBLog.error(`Error initializing 3rd party GoogleChat provider(1) ${error.message}`);
|
||||||
|
@ -116,8 +122,8 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async resetConversationId(number) {
|
public async resetConversationId(key) {
|
||||||
GoogleChatDirectLine.conversationIds[number] = undefined;
|
GoogleChatDirectLine.conversationIds[key] = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async check() {
|
public async check() {
|
||||||
|
@ -127,30 +133,36 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
|
|
||||||
public async receiver(message) {
|
public async receiver(message) {
|
||||||
|
|
||||||
GBLog.info(`Received message ${message.id}:`);
|
const event = JSON.parse(Buffer.from(message.data, 'binary').toString());
|
||||||
GBLog.info(`\tData: ${message.data}`);
|
|
||||||
GBLog.info(`\tAttributes: ${message.attributes}`);
|
let from = '';
|
||||||
|
let fromName='';
|
||||||
|
let text;
|
||||||
|
const threadName = event.message.thread.name;
|
||||||
|
|
||||||
|
if (event['type'] === 'ADDED_TO_SPACE' && event['space']['singleUserBotDm'])
|
||||||
|
{
|
||||||
|
|
||||||
|
}else if(event['type'] === 'MESSAGE')
|
||||||
|
{
|
||||||
|
text = event.message.text;
|
||||||
|
fromName = event.message.sender.displayName;
|
||||||
|
from = event.message.sender.email;
|
||||||
|
GBLog.info(`Received message from ${from} (${fromName}): ${text}.`);
|
||||||
|
}
|
||||||
message.ack();
|
message.ack();
|
||||||
|
|
||||||
let from = message.id; // TODO: update.
|
|
||||||
let text = message.data;
|
|
||||||
let fromName = 'GB';
|
|
||||||
|
|
||||||
GBLog.info(`GBGoogleChat: RCV ${from}: ${text})`);
|
GBLog.info(`GBGoogleChat: RCV ${from}: ${text})`);
|
||||||
|
|
||||||
await CollectionUtil.asyncForEach(this.min.appPackages, async (e: IGBPackage) => {
|
|
||||||
await e.onExchangeData(this.min, 'GoogleChatMessage', message);
|
|
||||||
});
|
|
||||||
|
|
||||||
const client = await this.directLineClient;
|
const client = await this.directLineClient;
|
||||||
const conversationId = GoogleChatDirectLine.conversationIds[from];
|
const conversationId = GoogleChatDirectLine.conversationIds[threadName];
|
||||||
|
|
||||||
if (GoogleChatDirectLine.conversationIds[from] === undefined) {
|
if (GoogleChatDirectLine.conversationIds[threadName] === undefined) {
|
||||||
GBLog.info(`GBGoogleChat: Starting new conversation on Bot.`);
|
GBLog.info(`GBGoogleChat: Starting new conversation on Bot.`);
|
||||||
const response = await client.Conversations.Conversations_StartConversation();
|
const response = await client.Conversations.Conversations_StartConversation();
|
||||||
const generatedConversationId = response.obj.conversationId;
|
const generatedConversationId = response.obj.conversationId;
|
||||||
|
|
||||||
GoogleChatDirectLine.conversationIds[from] = generatedConversationId;
|
GoogleChatDirectLine.conversationIds[threadName] = generatedConversationId;
|
||||||
|
|
||||||
this.pollMessages(client, generatedConversationId, from, fromName);
|
this.pollMessages(client, generatedConversationId, from, fromName);
|
||||||
this.inputMessage(client, generatedConversationId, text, from, fromName);
|
this.inputMessage(client, generatedConversationId, text, from, fromName);
|
||||||
|
@ -237,29 +249,26 @@ export class GoogleChatDirectLine extends GBService {
|
||||||
await this.sendToDevice(from, output);
|
await this.sendToDevice(from, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async sendToDevice(to: string, msg: string) {
|
public async sendToDevice(threadName: string, msg: string) {
|
||||||
|
|
||||||
const privatekey = require('./a.json')
|
|
||||||
const scopes = ['https://www.googleapis.com/auth/chat.bot'];
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const jwtClient = new google.auth.JWT(
|
|
||||||
privatekey.client_email,
|
let threadParts = threadName.split('/');
|
||||||
null,
|
let spaces = threadParts[1];
|
||||||
privatekey.private_key,
|
let threadKey = threadParts[3];
|
||||||
scopes,
|
|
||||||
'adminEmail@org.com'
|
const res = await chat.spaces.messages.createAsync({
|
||||||
);
|
auth: this.GoogleChatApiKey,
|
||||||
await jwtClient.authorize();
|
parent: `spaces/${spaces}`,
|
||||||
const chat = google.chat({ version: 'v1', auth: jwtClient });
|
threadKey: threadKey,
|
||||||
const res = await chat.spaces.messages.get({ name: 'spaces/XXX/messages/XX.XX' })
|
body: {
|
||||||
GBLog.info(res)
|
text: msg
|
||||||
|
}
|
||||||
GBLog.info(`Message [${msg}] sent to ${to}: `);
|
});
|
||||||
|
GBLog.info(res);
|
||||||
|
GBLog.info(`Message [${msg}] sent to ${threadName}: `);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error sending message to GoogleChat provider ${error.message}`);
|
GBLog.error(`Error sending message to GoogleChat provider ${error.message}`);
|
||||||
|
|
||||||
// TODO: Handle Error: socket hang up and retry.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue