new(core.gblib): Teams support for SeeingAI.
This commit is contained in:
parent
bad8251385
commit
ab2851fafe
3 changed files with 48 additions and 9 deletions
|
@ -263,7 +263,12 @@ export class SystemKeywords {
|
||||||
return documents[0];
|
return documents[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the content of variable into the file in .gbdata default folder.
|
||||||
|
*
|
||||||
|
* @exaple SAVE variable as "my.txt"
|
||||||
|
*
|
||||||
|
*/
|
||||||
public async saveFile(file: string, data: any): Promise<any> {
|
public async saveFile(file: string, data: any): Promise<any> {
|
||||||
GBLog.info(`BASIC: Saving '${file}' (SAVE file).`);
|
GBLog.info(`BASIC: Saving '${file}' (SAVE file).`);
|
||||||
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
let [baseUrl, client] = await GBDeployer.internalGetDriveClient(this.min);
|
||||||
|
@ -948,21 +953,27 @@ export class SystemKeywords {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public async getByHttp(url: string, headers: any, username: string, ps: string, qs: any) {
|
public async getByHttp(url: string, headers: any, username: string, ps: string, qs: any) {
|
||||||
const options = {
|
let options = {
|
||||||
auth: {
|
|
||||||
user: username,
|
|
||||||
pass: ps
|
|
||||||
},
|
|
||||||
encoding: "binary",
|
encoding: "binary",
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers
|
||||||
qs: qs,
|
|
||||||
};
|
};
|
||||||
|
if (username) {
|
||||||
|
options['auth'] = {
|
||||||
|
user: username,
|
||||||
|
pass: ps
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (qs) {
|
||||||
|
options['qs'] = qs;
|
||||||
|
}
|
||||||
const isAO = (val) => {
|
const isAO = (val) => {
|
||||||
return val instanceof Array || val instanceof Object ? true : false;
|
return val instanceof Array || val instanceof Object ? true : false;
|
||||||
}
|
}
|
||||||
let result = await request.get(options);
|
let result = await request.get(options);
|
||||||
|
|
||||||
|
|
||||||
if (isAO(result)) {
|
if (isAO(result)) {
|
||||||
GBLog.info(`[GET]: ${url} : ${result}`);
|
GBLog.info(`[GET]: ${url} : ${result}`);
|
||||||
|
|
|
@ -842,6 +842,10 @@ export class GBDeployer implements IGBDeployer {
|
||||||
GBServer.globals.server.use(`/kb/${gbaiName}/${packageName}/videos`,
|
GBServer.globals.server.use(`/kb/${gbaiName}/${packageName}/videos`,
|
||||||
express.static(urlJoin('work', gbaiName, filename, 'videos')));
|
express.static(urlJoin('work', gbaiName, filename, 'videos')));
|
||||||
|
|
||||||
|
GBServer.globals.server.use(`/${botId}/cache`,
|
||||||
|
express.static(urlJoin('work', gbaiName, 'cache')));
|
||||||
|
|
||||||
|
|
||||||
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${botId}.gbai/${packageName}.`);
|
GBLog.info(`KB (.gbkb) assets accessible at: /kb/${botId}.gbai/${packageName}.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,13 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
const { DialogSet, TextPrompt } = require('botbuilder-dialogs');
|
const { DialogSet, TextPrompt } = require('botbuilder-dialogs');
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
|
const Fs = require('fs');
|
||||||
const request = require('request-promise-native');
|
const request = require('request-promise-native');
|
||||||
const removeRoute = require('express-remove-route');
|
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 path = require('path');
|
||||||
import {
|
import {
|
||||||
AutoSaveStateMiddleware,
|
AutoSaveStateMiddleware,
|
||||||
BotFrameworkAdapter,
|
BotFrameworkAdapter,
|
||||||
|
@ -80,6 +82,7 @@ import urlJoin = require('url-join');
|
||||||
import fs = require('fs');
|
import fs = require('fs');
|
||||||
import { GoogleChatDirectLine } from '../../google-chat.gblib/services/GoogleChatDirectLine';
|
import { GoogleChatDirectLine } from '../../google-chat.gblib/services/GoogleChatDirectLine';
|
||||||
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices';
|
import { ScheduleServices } from '../../basic.gblib/services/ScheduleServices';
|
||||||
|
import { SystemKeywords } from '../../basic.gblib/services/SystemKeywords';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
* Minimal service layer for a bot and encapsulation of BOT Framework calls.
|
||||||
|
@ -872,6 +875,27 @@ export class GBMinService {
|
||||||
// Required for MSTEAMS handling of persisted conversations.
|
// Required for MSTEAMS handling of persisted conversations.
|
||||||
|
|
||||||
if (step.context.activity.channelId === 'msteams') {
|
if (step.context.activity.channelId === 'msteams') {
|
||||||
|
|
||||||
|
if (step.context.activity.attachments && step.context.activity.attachments.length > 1) {
|
||||||
|
|
||||||
|
const file = context.activity.attachments[0];
|
||||||
|
const credentials = new MicrosoftAppCredentials(min.instance.marketplaceId, min.instance.marketplacePassword);
|
||||||
|
const botToken = await credentials.getToken();
|
||||||
|
const headers = { Authorization: `Bearer ${botToken}` };
|
||||||
|
const t = new SystemKeywords(null, null, null);
|
||||||
|
const data = await t.getByHttp(file.contentUrl, headers, null, null, null);
|
||||||
|
const folder = `work/${min.instance.botId}.gbai/cache`;
|
||||||
|
const filename =`${GBAdminService.generateUuid()}.png`;
|
||||||
|
|
||||||
|
if (!Fs.existsSync(folder))
|
||||||
|
{
|
||||||
|
Fs.mkdirSync(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
Fs.writeFileSync(path.join(folder, filename), data);
|
||||||
|
step.context.activity.text = urlJoin(GBServer.globals.publicAddress, `${min.instance.botId}`, 'cache', filename);
|
||||||
|
}
|
||||||
|
|
||||||
const conversationReference = JSON.stringify(
|
const conversationReference = JSON.stringify(
|
||||||
TurnContext.getConversationReference(context.activity)
|
TurnContext.getConversationReference(context.activity)
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Reference in a new issue