fix(all): Locale in Audio is dynamic.
This commit is contained in:
parent
d1c4c23fa1
commit
fb6e57b19a
3 changed files with 25 additions and 24 deletions
2
.wwebjs_cache/2.2407.3.html
Normal file
2
.wwebjs_cache/2.2407.3.html
Normal file
File diff suppressed because one or more lines are too long
|
@ -528,22 +528,22 @@ export class GBConversationalService {
|
||||||
}
|
}
|
||||||
public static getIBMAudioModelNameFromLocale = locale => {
|
public static getIBMAudioModelNameFromLocale = locale => {
|
||||||
const locales = {
|
const locales = {
|
||||||
"ar": "ar-MS_BroadbandModel",
|
"ar": "ar-MS_BroadbandModel",
|
||||||
"zh": "zh-CN_BroadbandModel",
|
"zh": "zh-CN_BroadbandModel",
|
||||||
"nl": "nl-NL_BroadbandModel",
|
"nl": "nl-NL_BroadbandModel",
|
||||||
"en": "en-US_BroadbandModel",
|
"en": "en-US_BroadbandModel",
|
||||||
"fr": "fr-FR_BroadbandModel",
|
"fr": "fr-FR_BroadbandModel",
|
||||||
"de": "de-DE_BroadbandModel",
|
"de": "de-DE_BroadbandModel",
|
||||||
"it": "it-IT_BroadbandModel",
|
"it": "it-IT_BroadbandModel",
|
||||||
"ja": "ja-JP_BroadbandModel",
|
"ja": "ja-JP_BroadbandModel",
|
||||||
"ko": "ko-KR_BroadbandModel",
|
"ko": "ko-KR_BroadbandModel",
|
||||||
"pt": "pt-BR_BroadbandModel",
|
"pt": "pt-BR_BroadbandModel",
|
||||||
"es": "es-ES_BroadbandModel"
|
"es": "es-ES_BroadbandModel"
|
||||||
};
|
};
|
||||||
|
|
||||||
const languageCode = locale.substring(0, 2);
|
const languageCode = locale.substring(0, 2);
|
||||||
return locales[languageCode] || "en-US_BroadbandModel";
|
return locales[languageCode] || "en-US_BroadbandModel";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
public async playMarkdown(min: GBMinInstance, answer: string, channel: string,
|
public async playMarkdown(min: GBMinInstance, answer: string, channel: string,
|
||||||
|
@ -989,7 +989,7 @@ export class GBConversationalService {
|
||||||
'api-version': '3.0',
|
'api-version': '3.0',
|
||||||
to: language
|
to: language
|
||||||
}).toString()
|
}).toString()
|
||||||
|
|
||||||
let options = {
|
let options = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -1006,10 +1006,10 @@ export class GBConversationalService {
|
||||||
let results = await fetch(url, options);
|
let results = await fetch(url, options);
|
||||||
results = await results.json();
|
results = await results.json();
|
||||||
|
|
||||||
if (results[0]){
|
if (results[0]) {
|
||||||
return results[0].translations[0].text;
|
return results[0].translations[0].text;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -1097,7 +1097,7 @@ export class GBConversationalService {
|
||||||
|
|
||||||
// Detects user typed language and updates their locale profile if applies.
|
// Detects user typed language and updates their locale profile if applies.
|
||||||
|
|
||||||
let locale = min.core.getParam(
|
let locale = user.locale ? user.locale : min.core.getParam(
|
||||||
min.instance,
|
min.instance,
|
||||||
'Default User Language',
|
'Default User Language',
|
||||||
GBConfigService.get('DEFAULT_USER_LANGUAGE'));
|
GBConfigService.get('DEFAULT_USER_LANGUAGE'));
|
||||||
|
@ -1108,13 +1108,13 @@ export class GBConversationalService {
|
||||||
'Language Detector',
|
'Language Detector',
|
||||||
false) != false;
|
false) != false;
|
||||||
|
|
||||||
|
|
||||||
if (text.indexOf(' ') !== -1 && detectLanguage) {
|
if (text.indexOf(' ') !== -1 && detectLanguage) {
|
||||||
locale = await min.conversationalService.getLanguage(min, text);
|
locale = await min.conversationalService.getLanguage(min, text);
|
||||||
if (user.locale != locale) {
|
if (user.locale != locale) {
|
||||||
user = await sec.updateUserLocale(user.userId, locale);
|
user = await sec.updateUserLocale(user.userId, locale);
|
||||||
await min.conversationalService.sendText(min,
|
await min.conversationalService.sendText(min,
|
||||||
step, `Changed language to: ${locale}`);
|
step, `Changed language to: ${locale}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -958,10 +958,7 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
private async WhatsAppCallback(req, res) {
|
private async WhatsAppCallback(req, res) {
|
||||||
try {
|
try {
|
||||||
if (req.body && req.body.webhook) {
|
if (!req.body) {
|
||||||
res.status(200);
|
|
||||||
res.end();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1068,7 +1065,9 @@ export class WhatsappDirectLine extends GBService {
|
||||||
|
|
||||||
user = await sec.ensureUser(urlMin, id, '', '', 'omnichannel', '', '');
|
user = await sec.ensureUser(urlMin, id, '', '', 'omnichannel', '', '');
|
||||||
user = await sec.updateUserInstance(id, urlMin.instance.instanceId);
|
user = await sec.updateUserInstance(id, urlMin.instance.instanceId);
|
||||||
user = await sec.updateUserLocale(user.userId, locale);
|
if (locale){
|
||||||
|
user = await sec.updateUserLocale(user.userId, locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue