new(core.gbapp): New param for disabling welcome messages.
This commit is contained in:
parent
9e15b03d04
commit
134cf31695
1 changed files with 26 additions and 19 deletions
|
@ -137,33 +137,40 @@ export class GBMinService {
|
|||
res.end();
|
||||
return; // Exit here.
|
||||
}
|
||||
let activeMin;
|
||||
if (process.env.WHATSAPP_WELCOME_DISABLED !== "true") {
|
||||
|
||||
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.botId === text)[0];
|
||||
let activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
||||
const toSwitchMin = GBServer.globals.minInstances.filter(p => p.botId === text)[0];
|
||||
activeMin = toSwitchMin ? toSwitchMin : GBServer.globals.minBoot;
|
||||
|
||||
let sec = new SecService();
|
||||
let user = await sec.getUserFromPhone(id);
|
||||
let sec = new SecService();
|
||||
let user = await sec.getUserFromPhone(id);
|
||||
|
||||
if (user === null) {
|
||||
user = await sec.ensureUser(activeMin.instance.instanceId, id,
|
||||
activeMin.botId, id, "", "whatsapp", id, id);
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar?`);
|
||||
res.end();
|
||||
} else {
|
||||
// User wants to switch bots.
|
||||
if (toSwitchMin !== undefined) {
|
||||
await sec.updateCurrentBotId(id, text);
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `Agora falando com ${activeMin.instance.title}...`);
|
||||
if (user === null) {
|
||||
user = await sec.ensureUser(activeMin.instance.instanceId, id,
|
||||
activeMin.botId, id, "", "whatsapp", id, id);
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `Olá! Seja bem-vinda(o)!\nMe chamo ${activeMin.instance.title}. Como posso ajudar?`);
|
||||
res.end();
|
||||
} else {
|
||||
// User wants to switch bots.
|
||||
if (toSwitchMin !== undefined) {
|
||||
await sec.updateCurrentBotId(id, text);
|
||||
await (activeMin as any).whatsAppDirectLine.sendToDevice(id, `Agora falando com ${activeMin.instance.title}...`);
|
||||
res.end();
|
||||
}
|
||||
else {
|
||||
activeMin = GBServer.globals.minInstances.filter(p => p.botId === user.currentBotId)[0];;
|
||||
(activeMin as any).whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
activeMin = GBServer.globals.minInstances.filter(p => p.botId === user.currentBotId)[0];;
|
||||
(activeMin as any).whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
(GBServer.globals.minBoot as any).whatsAppDirectLine.received(req, res);
|
||||
}
|
||||
} catch (error) {
|
||||
GBLog.error(`Error on Whatsapp callback: ${error.message}`);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
|
@ -554,7 +561,7 @@ export class GBMinService {
|
|||
user.conversation, user.systemUser,
|
||||
context.activity.text);
|
||||
}
|
||||
|
||||
|
||||
// Checks for global exit kewywords cancelling any active dialogs.
|
||||
|
||||
const globalQuit = (locale, utterance) => {
|
||||
|
|
Loading…
Add table
Reference in a new issue