fix(basic.gblib): #269 Fixing of group autostart behaviour.

This commit is contained in:
rodrigorodriguez 2023-03-08 12:01:02 -03:00
parent 45ad0c3894
commit de77227945
4 changed files with 15 additions and 14 deletions

View file

@ -992,9 +992,11 @@ export class GBConversationalService {
GBLog.verbose(`Translated text(prompt): ${text}.`);
}
if (step.activeDialog.state.options['kind'] === 'file') {
return await step.prompt('attachmentPrompt', {});
} else {
return await step.prompt('textPrompt', text ? text : {});
await this.sendText(min, step, text);
return await step.prompt('textPrompt', {});
}
}

View file

@ -831,10 +831,10 @@ export class GBMinService {
adapter = min['fbAdapter'];
}
// Unifies channel detection.
// Unifies channel detection. Unmarshalls group information.
req.body.channelId =
(req.body.from.channelIdEx === 'whatsapp' ? 'omnichannel' : req.body.channelId);
req.body.channelId = req.body.from.channelIdEx === 'whatsapp' ? 'omnichannel' : req.body.channelId;
req.body.group = req.body.from.group;
// Default activity processing and handler.
@ -1322,11 +1322,8 @@ export class GBMinService {
// If it is a group, spells and sends them back.
const group = step.context.activity['group'];
if (textProcessed !== text && group){
await min.whatsAppDirectLine.sendToDevice(
group,
`Spell: ${text}`
);
if (textProcessed !== text && group) {
await min.whatsAppDirectLine.sendToDevice(group, `Spell: ${text}`);
}
// Detects user typed language and updates their locale profile if applies.

View file

@ -97,12 +97,14 @@ export class AskDialog extends IGBDialog {
user.subjects = [];
}
let text: string;
// Three forms of asking.
if (step.options && step.options.firstTime) {
text = Messages[locale].ask_first_time;
} else if (step.options && step.options.isReturning) {
} else if (step.options && step.options.isReturning && !step.context.activity.group) {
text = Messages[locale].anything_else;
} else if (step.options && step.options.emptyPrompt) {
} else if (step.context.activity.group || (step.options && step.options.emptyPrompt)) {
text = '';
} else if (user.subjects.length > 0) {
text = Messages[locale].which_question;
@ -302,8 +304,7 @@ export class AskDialog extends IGBDialog {
}
const CHATGPT_TIMEOUT = 60 * 1000;
GBLog.info(`ChatGPT being used...`);
const response = await GBServer.globals.chatGPT.sendMessage(text,
{ timeoutMs: CHATGPT_TIMEOUT });
const response = await GBServer.globals.chatGPT.sendMessage(text, { timeoutMs: CHATGPT_TIMEOUT });
if (!response) {
GBLog.info(`SEARCH called but NO answer could be found (zero results).`);

View file

@ -618,7 +618,8 @@ export class WhatsappDirectLine extends GBService {
from: {
id: from,
channelIdEx: 'whatsapp',
name: fromName
name: fromName,
group: group
},
replyToId: from
}