fix(core.gbapp): SMS fix, Timezone on BASIC NOW, Order of welcome msg. fixed.
This commit is contained in:
parent
482f465509
commit
18b8bd9bdf
4 changed files with 47 additions and 14 deletions
|
@ -468,12 +468,17 @@ export class DialogClass {
|
|||
return [year, month, day].join('/');
|
||||
}
|
||||
}
|
||||
|
||||
public async isAffirmative(step, text) {
|
||||
return text.toLowerCase().match(Messages[step.context.activity.locale].affirmative_sentences);
|
||||
}
|
||||
|
||||
public async getNow(step) {
|
||||
var d = new Date();
|
||||
return d.getHours() + ':' + d.getMinutes();
|
||||
const nowUTC = new Date();
|
||||
const now = new Date((typeof nowUTC === "string" ?
|
||||
new Date(nowUTC) :
|
||||
nowUTC).toLocaleString("en-US", {timeZone: process.env.DEFAULT_TIMEZONE}));
|
||||
|
||||
// TODO: Choose Fuse with country code or consent IP.
|
||||
return now.getHours() + ':' + now.getMinutes();
|
||||
}
|
||||
|
||||
public async sendFileTo(step, mobile, filename, caption) {
|
||||
|
|
|
@ -145,9 +145,10 @@ export class GBConversationalService {
|
|||
});
|
||||
// tslint:disable-next-line:no-unsafe-any
|
||||
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, (err, data) => {
|
||||
if (data.messages[0]['error-text']) {
|
||||
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${data.messages[0]['error-text']}`);
|
||||
reject(data.messages[0]['error-text']);
|
||||
const message = data.messages ? data.messages[0] : {};
|
||||
if (err || message['error-text']) {
|
||||
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`);
|
||||
reject(message['error-text']);
|
||||
} else {
|
||||
resolve(data);
|
||||
}
|
||||
|
@ -467,6 +468,9 @@ export class GBConversationalService {
|
|||
return false;
|
||||
}
|
||||
|
||||
text = text.toLowerCase().replace('who\'s', 'who is');
|
||||
text = text.toLowerCase().replace('what\'s', 'what is');
|
||||
|
||||
const model = new LuisRecognizer({
|
||||
applicationId: min.instance.nlpAppId,
|
||||
endpointKey: min.instance.nlpKey,
|
||||
|
|
|
@ -186,18 +186,18 @@ export class GBMinService {
|
|||
await sec.updateUserInstance(id, instance.instanceId);
|
||||
|
||||
await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
||||
id,
|
||||
`Agora falando com ${activeMin.instance.title}...`
|
||||
);
|
||||
|
||||
let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
|
||||
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
|
||||
|
||||
if (startDialog) {
|
||||
req.body.messages[0].body = `${startDialog}`;
|
||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
else {
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
||||
id,
|
||||
`Agora falando com ${activeMin.instance.title}...`
|
||||
);
|
||||
res.end();
|
||||
}
|
||||
} else {
|
||||
|
@ -797,6 +797,14 @@ export class GBMinService {
|
|||
});
|
||||
}
|
||||
text = await min.conversationalService.spellCheck(min, text);
|
||||
if (keepText) {
|
||||
const list = keepText.split(';');
|
||||
let i = 0;
|
||||
await CollectionUtil.asyncForEach(list, item => {
|
||||
i++;
|
||||
text = text.replace(`KEEPTEXT${i}`, item.trim());
|
||||
});
|
||||
}
|
||||
// Detects user typed language and updates their locale profile if applies.
|
||||
|
||||
let locale = min.core.getParam<string>(
|
||||
|
@ -828,12 +836,28 @@ export class GBMinService {
|
|||
|
||||
// Translates the input text if is turned on instance params.
|
||||
|
||||
if (keepText) {
|
||||
const list = keepText.split(';');
|
||||
let i = 0;
|
||||
await CollectionUtil.asyncForEach(list, item => {
|
||||
i++;
|
||||
text = text.replace(new RegExp(item.trim(), 'gi'), `KEEPTEXT${i}`);
|
||||
});
|
||||
}
|
||||
|
||||
let contentLocale = min.core.getParam<string>(
|
||||
min.instance,
|
||||
'Default Content Language',
|
||||
GBConfigService.get('DEFAULT_CONTENT_LANGUAGE')
|
||||
);
|
||||
if (keepText) {
|
||||
const list = keepText.split(';');
|
||||
let i = 0;
|
||||
await CollectionUtil.asyncForEach(list, item => {
|
||||
i++;
|
||||
text = text.replace(new RegExp(item.trim(), 'gi'), `KEEPTEXT${i}`);
|
||||
});
|
||||
}
|
||||
|
||||
text = await min.conversationalService.translate(min, text, contentLocale);
|
||||
if (keepText) {
|
||||
|
|
|
@ -13,7 +13,7 @@ export const Messages = {
|
|||
which_language: "Please, type the language name you would like to talk through.",
|
||||
validation_enter_valid_email: "Please enter a valid e-mail." ,
|
||||
language_chosen: "Very good, so let's go..." ,
|
||||
affirmative_sentences: /^(sim|s|positivo|afirmativo|claro|evidente|sem dúvida|confirmo|confirmar|confirmado|uhum)/i,
|
||||
affirmative_sentences: /^(sim|s|positivo|afirmativo|claro|evidente|sem dúvida|confirmo|confirmar|confirmado|uhum|si|y|yes|sure)/i,
|
||||
|
||||
},
|
||||
'pt-BR': {
|
||||
|
@ -28,7 +28,7 @@ export const Messages = {
|
|||
which_language: "Por favor, digite o idioma que você gostaria de usar para conversarmos.",
|
||||
validation_enter_valid_email: "Por favor digite um email válido.",
|
||||
language_chosen: "Muito bem, então vamos lá..." ,
|
||||
affirmative_sentences: /^(sim|s|positivo|afirmativo|claro|evidente|sem dúvida|confirmo|confirmar|confirmado|uhum)/i,
|
||||
affirmative_sentences: /^(sim|s|positivo|afirmativo|claro|evidente|sem dúvida|confirmo|confirmar|confirmado|uhum|si|y|yes|sure)/i,
|
||||
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue