fix(all): General Bots now can show Office documents on projector.
This commit is contained in:
parent
84fb0748d0
commit
21117c297c
1 changed files with 21 additions and 5 deletions
|
@ -45,6 +45,7 @@ const walkPromise = require('walk-promise');
|
||||||
const { SearchService } = require('azure-search-client');
|
const { SearchService } = require('azure-search-client');
|
||||||
const Excel = require('exceljs');
|
const Excel = require('exceljs');
|
||||||
const getSlug = require('speakingurl');
|
const getSlug = require('speakingurl');
|
||||||
|
import { GBServer } from '../../../src/app';
|
||||||
import {
|
import {
|
||||||
GBDialogStep,
|
GBDialogStep,
|
||||||
GBLog,
|
GBLog,
|
||||||
|
@ -503,8 +504,24 @@ export class KBService implements IGBKBService {
|
||||||
public async sendAnswer(min: GBMinInstance, channel: string, step: GBDialogStep, answer: GuaribasAnswer) {
|
public async sendAnswer(min: GBMinInstance, channel: string, step: GBDialogStep, answer: GuaribasAnswer) {
|
||||||
if (answer.content.endsWith('.mp4')) {
|
if (answer.content.endsWith('.mp4')) {
|
||||||
await this.playVideo(min, min.conversationalService, step, answer, channel);
|
await this.playVideo(min, min.conversationalService, step, answer, channel);
|
||||||
|
} else if (
|
||||||
|
answer.content.endsWith('.ppt') ||
|
||||||
|
answer.content.endsWith('.pptx') ||
|
||||||
|
answer.content.endsWith('.doc') ||
|
||||||
|
answer.content.endsWith('.docx') ||
|
||||||
|
answer.content.endsWith('.xls') ||
|
||||||
|
answer.content.endsWith('.xlsx')
|
||||||
|
|
||||||
|
) {
|
||||||
|
const doc = urlJoin(GBServer.globals.publicAddress, 'kb', `${min.instance.botId}.gbai`,
|
||||||
|
`${min.instance.botId}.gbkb`, 'assets', answer.content)
|
||||||
|
const url = `http://view.officeapps.live.com/op/view.aspx?src=${doc}`;
|
||||||
|
await this.playUrl(min, min.conversationalService, step, url, channel);
|
||||||
} else if (answer.content.endsWith('.pdf')) {
|
} else if (answer.content.endsWith('.pdf')) {
|
||||||
await this.playUrl(min, min.conversationalService, step, answer, channel);
|
|
||||||
|
const url = urlJoin('kb', `${min.instance.botId}.gbai`,
|
||||||
|
`${min.instance.botId}.gbkb`, 'assets', answer.content);
|
||||||
|
await this.playUrl(min, min.conversationalService, step, url, channel);
|
||||||
} else if (answer.format === '.md') {
|
} else if (answer.format === '.md') {
|
||||||
await this.playMarkdown(min, answer, channel, step, min.conversationalService);
|
await this.playMarkdown(min, answer, channel, step, min.conversationalService);
|
||||||
} else if (answer.content.endsWith('.ogg') && process.env.AUDIO_DISABLED !== 'true') {
|
} else if (answer.content.endsWith('.ogg') && process.env.AUDIO_DISABLED !== 'true') {
|
||||||
|
@ -721,16 +738,15 @@ export class KBService implements IGBKBService {
|
||||||
min,
|
min,
|
||||||
conversationalService: IGBConversationalService,
|
conversationalService: IGBConversationalService,
|
||||||
step: GBDialogStep,
|
step: GBDialogStep,
|
||||||
answer: GuaribasAnswer,
|
url: string,
|
||||||
channel: string
|
channel: string
|
||||||
) {
|
) {
|
||||||
if (channel === 'whatsapp') {
|
if (channel === 'whatsapp') {
|
||||||
await min.conversationalService.sendFile(min, step, null, answer.content, '');
|
await min.conversationalService.sendFile(min, step, null, url, '');
|
||||||
} else {
|
} else {
|
||||||
await conversationalService.sendEvent(min, step, 'play', {
|
await conversationalService.sendEvent(min, step, 'play', {
|
||||||
playerType: 'url',
|
playerType: 'url',
|
||||||
data: urlJoin('kb',`${min.instance.botId}.gbai`,
|
data: url
|
||||||
`${min.instance.botId}.gbkb`, 'assets', answer.content)
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue