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('/');
|
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) {
|
public async getNow(step) {
|
||||||
var d = new Date();
|
const nowUTC = new Date();
|
||||||
return d.getHours() + ':' + d.getMinutes();
|
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) {
|
public async sendFileTo(step, mobile, filename, caption) {
|
||||||
|
|
|
@ -145,9 +145,10 @@ export class GBConversationalService {
|
||||||
});
|
});
|
||||||
// tslint:disable-next-line:no-unsafe-any
|
// tslint:disable-next-line:no-unsafe-any
|
||||||
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, (err, data) => {
|
nexmo.message.sendSms(min.instance.smsServiceNumber, mobile, text, (err, data) => {
|
||||||
if (data.messages[0]['error-text']) {
|
const message = data.messages ? data.messages[0] : {};
|
||||||
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${data.messages[0]['error-text']}`);
|
if (err || message['error-text']) {
|
||||||
reject(data.messages[0]['error-text']);
|
GBLog.error(`BASIC: error sending SMS to ${mobile}: ${message['error-text']}`);
|
||||||
|
reject(message['error-text']);
|
||||||
} else {
|
} else {
|
||||||
resolve(data);
|
resolve(data);
|
||||||
}
|
}
|
||||||
|
@ -467,6 +468,9 @@ export class GBConversationalService {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text = text.toLowerCase().replace('who\'s', 'who is');
|
||||||
|
text = text.toLowerCase().replace('what\'s', 'what is');
|
||||||
|
|
||||||
const model = new LuisRecognizer({
|
const model = new LuisRecognizer({
|
||||||
applicationId: min.instance.nlpAppId,
|
applicationId: min.instance.nlpAppId,
|
||||||
endpointKey: min.instance.nlpKey,
|
endpointKey: min.instance.nlpKey,
|
||||||
|
|
|
@ -186,18 +186,18 @@ export class GBMinService {
|
||||||
await sec.updateUserInstance(id, instance.instanceId);
|
await sec.updateUserInstance(id, instance.instanceId);
|
||||||
|
|
||||||
await (activeMin as any).whatsAppDirectLine.resetConversationId(id);
|
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);
|
let startDialog = activeMin.core.getParam(activeMin.instance, 'Start Dialog', null);
|
||||||
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
|
GBLog.info(`Auto start dialog is now being called: ${startDialog}...`);
|
||||||
|
|
||||||
if (startDialog) {
|
if (startDialog) {
|
||||||
req.body.messages[0].body = `${startDialog}`;
|
req.body.messages[0].body = `${startDialog}`;
|
||||||
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
await (activeMin as any).whatsAppDirectLine.received(req, res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
await (activeMin as any).whatsAppDirectLine.sendToDevice(
|
||||||
|
id,
|
||||||
|
`Agora falando com ${activeMin.instance.title}...`
|
||||||
|
);
|
||||||
res.end();
|
res.end();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -797,6 +797,14 @@ export class GBMinService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
text = await min.conversationalService.spellCheck(min, text);
|
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.
|
// Detects user typed language and updates their locale profile if applies.
|
||||||
|
|
||||||
let locale = min.core.getParam<string>(
|
let locale = min.core.getParam<string>(
|
||||||
|
@ -828,12 +836,28 @@ export class GBMinService {
|
||||||
|
|
||||||
// Translates the input text if is turned on instance params.
|
// 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>(
|
let contentLocale = min.core.getParam<string>(
|
||||||
min.instance,
|
min.instance,
|
||||||
'Default Content Language',
|
'Default Content Language',
|
||||||
GBConfigService.get('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);
|
text = await min.conversationalService.translate(min, text, contentLocale);
|
||||||
if (keepText) {
|
if (keepText) {
|
||||||
|
|
|
@ -13,7 +13,7 @@ export const Messages = {
|
||||||
which_language: "Please, type the language name you would like to talk through.",
|
which_language: "Please, type the language name you would like to talk through.",
|
||||||
validation_enter_valid_email: "Please enter a valid e-mail." ,
|
validation_enter_valid_email: "Please enter a valid e-mail." ,
|
||||||
language_chosen: "Very good, so let's go..." ,
|
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': {
|
'pt-BR': {
|
||||||
|
@ -28,7 +28,7 @@ export const Messages = {
|
||||||
which_language: "Por favor, digite o idioma que você gostaria de usar para conversarmos.",
|
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.",
|
validation_enter_valid_email: "Por favor digite um email válido.",
|
||||||
language_chosen: "Muito bem, então vamos lá..." ,
|
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