new(core.gbapp): Due to MSFT issue https://github.com/microsoft/cognitive-services-speech-sdk-js/issues/92 disabling AUDIO.
This commit is contained in:
parent
3abe85ca30
commit
e87031255e
7 changed files with 100 additions and 73 deletions
|
@ -534,7 +534,7 @@ export class GBConversationalService {
|
||||||
language: string
|
language: string
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
|
||||||
if (process.env.TRANSLATOR_DISABLED === "true") {
|
if (endPoint === null || process.env.TRANSLATOR_DISABLED === "true") {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -165,6 +165,7 @@ export class GBDeployer implements IGBDeployer {
|
||||||
instance.adminPass = GBAdminService.getRndPassword();
|
instance.adminPass = GBAdminService.getRndPassword();
|
||||||
instance.title = botId;
|
instance.title = botId;
|
||||||
instance.activationCode = instance.botId;
|
instance.activationCode = instance.botId;
|
||||||
|
instance.state = 'active';
|
||||||
|
|
||||||
await this.core.saveInstance(instance);
|
await this.core.saveInstance(instance);
|
||||||
|
|
||||||
|
|
|
@ -144,12 +144,12 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
let activeMin;
|
let activeMin;
|
||||||
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
|
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
|
||||||
// TODO: Active in two modes.
|
// TODO: Active in two modes.
|
||||||
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.botId === text)[0];
|
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.instance.botId === text)[0];
|
||||||
activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
||||||
|
|
||||||
let sec = new SecService();
|
let sec = new SecService();
|
||||||
|
|
||||||
let user = await sec.getUserFromSystemId(id);
|
let user = await sec.getUserFromSystemId(id);
|
||||||
|
|
||||||
if (user === null) {
|
if (user === null) {
|
||||||
|
@ -345,7 +345,7 @@ export class GBMinService {
|
||||||
}
|
}
|
||||||
let instance = await this.core.loadInstanceByBotId(botId);
|
let instance = await this.core.loadInstanceByBotId(botId);
|
||||||
|
|
||||||
if (instance === null){
|
if (instance === null) {
|
||||||
instance = await this.core.loadInstanceByActivationCode(botId);
|
instance = await this.core.loadInstanceByActivationCode(botId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -687,11 +687,14 @@ export class GBMinService {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
let query = context.activity.text;
|
let query = context.activity.text;
|
||||||
|
|
||||||
let locale = 'pt';
|
let locale = 'pt';
|
||||||
if (process.env.TRANSLATOR_DISABLED !== "true"){
|
if (process.env.TRANSLATOR_DISABLED !== "true") {
|
||||||
locale = await AzureText.getLocale(min.instance.textAnalyticsKey,
|
const minBoot = GBServer.globals.minBoot as any; // TODO: Switch keys automatically to master/per bot.
|
||||||
min.instance.textAnalyticsEndpoint, query);
|
locale = await AzureText.getLocale(minBoot.instance.textAnalyticsKey ?
|
||||||
|
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||||
|
minBoot.instance.textAnalyticsEndpoint ?
|
||||||
|
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sec = new SecService();
|
let sec = new SecService();
|
||||||
|
|
|
@ -43,7 +43,7 @@ import { AzureText } from 'pragmatismo-io-framework';
|
||||||
import { CSService } from '../services/CSService';
|
import { CSService } from '../services/CSService';
|
||||||
import { Messages } from '../strings';
|
import { Messages } from '../strings';
|
||||||
import { SecService } from '../../security.gblib/services/SecService';
|
import { SecService } from '../../security.gblib/services/SecService';
|
||||||
import { GBConversationalService } from '../../core.gbapp/services/GBConversationalService';
|
import { GBServer } from '../../../src/app';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dialog for feedback collecting.
|
* Dialog for feedback collecting.
|
||||||
|
@ -81,9 +81,9 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
await min.conversationalService.sendText(min, step, Messages[locale].please_wait_transfering);
|
||||||
let agentSystemId = await sec.assignHumanAgent(from, min.instance.instanceId);
|
let agentSystemId = await sec.assignHumanAgent(from, min.instance.instanceId);
|
||||||
|
|
||||||
await min.whatsAppDirectLine.sendToDevice(agentSystemId,
|
await min.whatsAppDirectLine.sendToDevice(agentSystemId,
|
||||||
Messages[locale].notify_agent(step.context.activity.from.name));
|
Messages[locale].notify_agent(step.context.activity.from.name));
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
@ -100,7 +100,7 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
|
|
||||||
await sec.updateCurrentAgent(from, min.instance.instanceId, null);
|
await sec.updateCurrentAgent(from, min.instance.instanceId, null);
|
||||||
await min.conversationalService.sendText(min, step, Messages[locale].notify_end_transfer(min.instance.botId));
|
await min.conversationalService.sendText(min, step, Messages[locale].notify_end_transfer(min.instance.botId));
|
||||||
|
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
|
@ -134,13 +134,17 @@ export class FeedbackDialog extends IGBDialog {
|
||||||
await min.conversationalService.sendText(min, step, Messages[locale].about_suggestions);
|
await min.conversationalService.sendText(min, step, Messages[locale].about_suggestions);
|
||||||
step.activeDialog.state.cbId = (step.options as any).id;
|
step.activeDialog.state.cbId = (step.options as any).id;
|
||||||
|
|
||||||
return await min.conversationalService.prompt (min, step, Messages[locale].what_about_service);
|
return await min.conversationalService.prompt(min, step, Messages[locale].what_about_service);
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
|
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
const rate = await AzureText.getSentiment(
|
const rate = await AzureText.getSentiment(
|
||||||
min.instance.textAnalyticsKey,
|
minBoot.instance.textAnalyticsKey ?
|
||||||
min.instance.textAnalyticsEndpoint,
|
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||||
|
minBoot.instance.textAnalyticsEndpoint ?
|
||||||
|
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint,
|
||||||
min.conversationalService.getCurrentLanguage(step),
|
min.conversationalService.getCurrentLanguage(step),
|
||||||
step.result
|
step.result
|
||||||
);
|
);
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
import { GBServer } from '../../../src/app';
|
||||||
import { BotAdapter } from 'botbuilder';
|
import { BotAdapter } from 'botbuilder';
|
||||||
import { WaterfallDialog } from 'botbuilder-dialogs';
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
import { GBLog, GBMinInstance, IGBDialog } from 'botlib';
|
||||||
|
@ -104,11 +105,14 @@ export class AskDialog extends IGBDialog {
|
||||||
let query = step.result;
|
let query = step.result;
|
||||||
|
|
||||||
let locale = 'pt';
|
let locale = 'pt';
|
||||||
if (process.env.TRANSLATOR_DISABLED !== "true"){
|
if (process.env.TRANSLATOR_DISABLED !== "true") {
|
||||||
locale = await AzureText.getLocale(min.instance.textAnalyticsKey,
|
const minBoot = GBServer.globals.minBoot as any;
|
||||||
min.instance.textAnalyticsEndpoint, query);
|
locale = await AzureText.getLocale(minBoot.instance.textAnalyticsKey ?
|
||||||
}
|
minBoot.instance.textAnalyticsKey : minBoot.instance.textAnalyticsKey,
|
||||||
|
minBoot.instance.textAnalyticsEndpoint ?
|
||||||
|
minBoot.instance.textAnalyticsEndpoint : minBoot.instance.textAnalyticsKeyEndpoint, query);
|
||||||
|
}
|
||||||
|
|
||||||
let sec = new SecService();
|
let sec = new SecService();
|
||||||
const member = step.context.activity.from;
|
const member = step.context.activity.from;
|
||||||
|
|
||||||
|
@ -146,7 +150,7 @@ export class AskDialog extends IGBDialog {
|
||||||
min.instance.translatorEndpoint,
|
min.instance.translatorEndpoint,
|
||||||
text,
|
text,
|
||||||
userDb.locale ? userDb.locale : 'pt'
|
userDb.locale ? userDb.locale : 'pt'
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!text) {
|
if (!text) {
|
||||||
throw new Error(`/answer being called with no args query text.`);
|
throw new Error(`/answer being called with no args query text.`);
|
||||||
|
|
|
@ -55,6 +55,7 @@ import { Messages } from '../strings';
|
||||||
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
import { GBConfigService } from './../../core.gbapp/services/GBConfigService';
|
||||||
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService';
|
import { CSService } from '../../customer-satisfaction.gbapp/services/CSService';
|
||||||
import { SecService } from '../../security.gblib/services/SecService';
|
import { SecService } from '../../security.gblib/services/SecService';
|
||||||
|
import { CollectionUtil } from 'pragmatismo-io-framework';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Result for quey on KB data.
|
* Result for quey on KB data.
|
||||||
|
@ -382,7 +383,7 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
await this.playMarkdown(min, answer, channel, step, min.conversationalService);
|
await this.playMarkdown(min, answer, channel, step, min.conversationalService);
|
||||||
|
|
||||||
} else if (answer.content.endsWith('.ogg')) {
|
} else if (answer.content.endsWith('.ogg') && process.env.AUDIO_DISABLED !== "true") {
|
||||||
|
|
||||||
await this.playAudio(min, answer, channel, step, min.conversationalService);
|
await this.playAudio(min, answer, channel, step, min.conversationalService);
|
||||||
} else {
|
} else {
|
||||||
|
@ -411,7 +412,7 @@ export class KBService implements IGBKBService {
|
||||||
html = marked(answer.content);
|
html = marked(answer.content);
|
||||||
if (channel === 'webchat' &&
|
if (channel === 'webchat' &&
|
||||||
GBConfigService.get('DISABLE_WEB') !== 'true') {
|
GBConfigService.get('DISABLE_WEB') !== 'true') {
|
||||||
|
|
||||||
await this.sendMarkdownToWeb(min, step, conversationalService, html, answer);
|
await this.sendMarkdownToWeb(min, step, conversationalService, html, answer);
|
||||||
}
|
}
|
||||||
else if (channel === 'whatsapp') {
|
else if (channel === 'whatsapp') {
|
||||||
|
@ -425,7 +426,7 @@ export class KBService implements IGBKBService {
|
||||||
answer.content,
|
answer.content,
|
||||||
user.locale ? user.locale : 'pt'
|
user.locale ? user.locale : 'pt'
|
||||||
);
|
);
|
||||||
|
|
||||||
await conversationalService.sendMarkdownToMobile(min, step, null, answer.content);
|
await conversationalService.sendMarkdownToMobile(min, step, null, answer.content);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -434,7 +435,7 @@ export class KBService implements IGBKBService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private async sendMarkdownToWeb(min, step: GBDialogStep, conversationalService: IGBConversationalService, html: string, answer: GuaribasAnswer) {
|
private async sendMarkdownToWeb(min, step: GBDialogStep, conversationalService: IGBConversationalService, html: string, answer: GuaribasAnswer) {
|
||||||
|
|
||||||
let sec = new SecService();
|
let sec = new SecService();
|
||||||
const member = step.context.activity.from;
|
const member = step.context.activity.from;
|
||||||
const user = await sec.ensureUser(min.instance.instanceId, member.id,
|
const user = await sec.ensureUser(min.instance.instanceId, member.id,
|
||||||
|
@ -447,7 +448,7 @@ export class KBService implements IGBKBService {
|
||||||
);
|
);
|
||||||
|
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
await min.conversationalService.sendText( min, step, Messages[locale].will_answer_projector);
|
await min.conversationalService.sendText(min, step, Messages[locale].will_answer_projector);
|
||||||
html = html.replace(/src\=\"kb\//g, `src=\"../kb/`);
|
html = html.replace(/src\=\"kb\//g, `src=\"../kb/`);
|
||||||
await conversationalService.sendEvent(min, step, 'play', {
|
await conversationalService.sendEvent(min, step, 'play', {
|
||||||
playerType: 'markdown',
|
playerType: 'markdown',
|
||||||
|
@ -476,7 +477,11 @@ export class KBService implements IGBKBService {
|
||||||
|
|
||||||
// Imports subjects tree into database and return it.
|
// Imports subjects tree into database and return it.
|
||||||
|
|
||||||
await this.importSubjectFile(packageStorage.packageId, urlJoin(localPath, 'subjects.json'), instance);
|
const subjectFile = urlJoin(localPath, 'subjects.json');
|
||||||
|
|
||||||
|
if (Fs.existsSync(subjectFile)) {
|
||||||
|
await this.importSubjectFile(packageStorage.packageId, subjectFile, instance);
|
||||||
|
}
|
||||||
|
|
||||||
// Import tabular files in the tabular directory.
|
// Import tabular files in the tabular directory.
|
||||||
|
|
||||||
|
@ -493,39 +498,45 @@ export class KBService implements IGBKBService {
|
||||||
public async importRemainingArticles(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
public async importRemainingArticles(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
||||||
const files = await walkPromise(urlJoin(localPath, 'articles'));
|
const files = await walkPromise(urlJoin(localPath, 'articles'));
|
||||||
|
|
||||||
return Promise.all(
|
await CollectionUtil.asyncForEach(files, async file => {
|
||||||
files.map(async file => {
|
if (file !== null && file.name.endsWith('.md')) {
|
||||||
if (file.name.endsWith('.md')) {
|
|
||||||
|
|
||||||
let content = await this.getAnswerTextByMediaName(instance.instanceId, file.name);
|
let content = await this.getAnswerTextByMediaName(instance.instanceId, file.name);
|
||||||
|
|
||||||
if (content === null) {
|
if (content === null) {
|
||||||
|
|
||||||
const fullFilename = urlJoin(file.root, file.name);
|
const fullFilename = urlJoin(file.root, file.name);
|
||||||
content = Fs.readFileSync(fullFilename, 'utf-8');
|
content = Fs.readFileSync(fullFilename, 'utf-8');
|
||||||
|
|
||||||
await GuaribasAnswer.create({
|
await GuaribasAnswer.create({
|
||||||
instanceId: instance.instanceId,
|
instanceId: instance.instanceId,
|
||||||
content: content,
|
content: content,
|
||||||
format: ".md",
|
format: ".md",
|
||||||
media: file.name,
|
media: file.name,
|
||||||
packageId: packageId,
|
packageId: packageId,
|
||||||
prevId: 0 // TODO: Calculate total rows and increment.
|
prevId: 0 // TODO: Calculate total rows and increment.
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}));
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
public async importKbTabularDirectory(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
public async importKbTabularDirectory(localPath: string, instance: IGBInstance, packageId: number): Promise<any> {
|
||||||
const files = await walkPromise(urlJoin(localPath, 'tabular'));
|
let files = await walkPromise(localPath);
|
||||||
|
|
||||||
|
await CollectionUtil.asyncForEach(files, async file => {
|
||||||
|
if (file !== null && file.name.endsWith('.xlsx')) {
|
||||||
|
return await this.importKbTabularFile(urlJoin(file.root, file.name), instance.instanceId, packageId);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
files = await walkPromise(urlJoin(localPath, 'tabular'));
|
||||||
|
|
||||||
|
await CollectionUtil.asyncForEach(files, async file => {
|
||||||
|
|
||||||
|
if (file !== null && file.name.endsWith('.xlsx')) {
|
||||||
|
return await this.importKbTabularFile(urlJoin(file.root, file.name), instance.instanceId, packageId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return Promise.all(
|
|
||||||
files.map(async file => {
|
|
||||||
if (file.name.endsWith('.xlsx')) {
|
|
||||||
return await this.importKbTabularFile(urlJoin(file.root, file.name), instance.instanceId, packageId);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async importSubjectFile(packageId: number, filename: string, instance: IGBInstance): Promise<any> {
|
public async importSubjectFile(packageId: number, filename: string, instance: IGBInstance): Promise<any> {
|
||||||
|
@ -582,7 +593,7 @@ export class KBService implements IGBKBService {
|
||||||
const packageType = Path.extname(localPath);
|
const packageType = Path.extname(localPath);
|
||||||
const packageName = Path.basename(localPath);
|
const packageName = Path.basename(localPath);
|
||||||
GBLog.info(`[GBDeployer] Opening package: ${localPath}`);
|
GBLog.info(`[GBDeployer] Opening package: ${localPath}`);
|
||||||
const packageObject = JSON.parse(Fs.readFileSync(urlJoin(localPath, 'package.json'), 'utf8'));
|
|
||||||
|
|
||||||
const instance = await core.loadInstanceByBotId(min.botId);
|
const instance = await core.loadInstanceByBotId(min.botId);
|
||||||
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
GBLog.info(`[GBDeployer] Importing: ${localPath}`);
|
||||||
|
|
|
@ -171,23 +171,27 @@ export class WhatsappDirectLine extends GBService {
|
||||||
const user = await sec.ensureUser(this.min.instance.instanceId, id,
|
const user = await sec.ensureUser(this.min.instance.instanceId, id,
|
||||||
senderName, "", "whatsapp", senderName);
|
senderName, "", "whatsapp", senderName);
|
||||||
|
|
||||||
const locale = user.locale ? user.locale : 'pt';
|
const locale = user.locale ? user.locale : 'pt';
|
||||||
if (message.type === "ptt") {
|
if (message.type === "ptt") {
|
||||||
|
|
||||||
const options = {
|
if (process.env.AUDIO_DISABLED !== "true") {
|
||||||
url: message.body,
|
const options = {
|
||||||
method: 'GET',
|
url: message.body,
|
||||||
encoding: 'binary'
|
method: 'GET',
|
||||||
};
|
encoding: 'binary'
|
||||||
|
};
|
||||||
const res = await request(options);
|
|
||||||
let buf = Buffer.from(res, 'binary');
|
|
||||||
text = await GBConversationalService.getTextFromAudioBuffer(
|
|
||||||
this.min.instance.speechKey,
|
|
||||||
this.min.instance.cloudLocation,
|
|
||||||
buf, locale
|
|
||||||
);
|
|
||||||
|
|
||||||
|
const res = await request(options);
|
||||||
|
let buf = Buffer.from(res, 'binary');
|
||||||
|
text = await GBConversationalService.getTextFromAudioBuffer(
|
||||||
|
this.min.instance.speechKey,
|
||||||
|
this.min.instance.cloudLocation,
|
||||||
|
buf, locale
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
await this.sendToDevice(user.userSystemId, `No momento estou apenas conseguindo ler mensagens de texto.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const conversationId = this.conversationIds[from];
|
const conversationId = this.conversationIds[from];
|
||||||
|
@ -207,7 +211,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
if (message === null) {
|
if (message === null) {
|
||||||
await this.sendToDeviceEx(user.userSystemId, `File ${filename} not found in any .gbkb published. Check the name or publish again the associated .gbkb.`,
|
await this.sendToDeviceEx(user.userSystemId, `File ${filename} not found in any .gbkb published. Check the name or publish again the associated .gbkb.`,
|
||||||
locale);
|
locale);
|
||||||
} else {
|
} else {
|
||||||
await this.min.conversationalService.sendMarkdownToMobile(this.min, null, user.userSystemId, message);
|
await this.min.conversationalService.sendMarkdownToMobile(this.min, null, user.userSystemId, message);
|
||||||
}
|
}
|
||||||
|
@ -271,7 +275,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
conversationId: conversationId,
|
conversationId: conversationId,
|
||||||
activity: {
|
activity: {
|
||||||
textFormat: 'plain',
|
textFormat: 'plain',
|
||||||
text: text,
|
text: text,
|
||||||
type: 'message',
|
type: 'message',
|
||||||
from: {
|
from: {
|
||||||
id: from,
|
id: from,
|
||||||
|
@ -369,7 +373,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
try {
|
try {
|
||||||
// tslint:disable-next-line: await-promise
|
// tslint:disable-next-line: await-promise
|
||||||
const result = await request.post(options);
|
const result = await request.post(options);
|
||||||
GBLog.info( `File ${url} sent to ${to}: ${result}`);
|
GBLog.info(`File ${url} sent to ${to}: ${result}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error sending file to Whatsapp provider ${error.message}`);
|
GBLog.error(`Error sending file to Whatsapp provider ${error.message}`);
|
||||||
}
|
}
|
||||||
|
@ -392,7 +396,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
try {
|
try {
|
||||||
// tslint:disable-next-line: await-promise
|
// tslint:disable-next-line: await-promise
|
||||||
const result = await request.post(options);
|
const result = await request.post(options);
|
||||||
GBLog.info( `Audio ${url} sent to ${to}: ${result}`);
|
GBLog.info(`Audio ${url} sent to ${to}: ${result}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error sending audio message to Whatsapp provider ${error.message}`);
|
GBLog.error(`Error sending audio message to Whatsapp provider ${error.message}`);
|
||||||
}
|
}
|
||||||
|
@ -422,7 +426,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
public async sendToDevice(to, msg) {
|
public async sendToDevice(to, msg) {
|
||||||
|
|
||||||
const cmd = '/audio ';
|
const cmd = '/audio ';
|
||||||
if (msg.startsWith(cmd)) {
|
if (msg.startsWith(cmd) && process.env.AUDIO_DISABLED !== 'true') {
|
||||||
msg = msg.substr(cmd.length);
|
msg = msg.substr(cmd.length);
|
||||||
return await this.sendTextAsAudioToDevice(to, msg);
|
return await this.sendTextAsAudioToDevice(to, msg);
|
||||||
}
|
}
|
||||||
|
@ -444,7 +448,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
try {
|
try {
|
||||||
// tslint:disable-next-line: await-promise
|
// tslint:disable-next-line: await-promise
|
||||||
const result = await request.post(options);
|
const result = await request.post(options);
|
||||||
GBLog.info( `Message [${msg}] sent to ${to}: ${result}`);
|
GBLog.info(`Message [${msg}] sent to ${to}: ${result}`);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
GBLog.error(`Error sending message to Whatsapp provider ${error.message}`);
|
GBLog.error(`Error sending message to Whatsapp provider ${error.message}`);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue