Skip to content

Commit

Permalink
fix(basic.gblib): #269 Fixing of group autostart behaviour.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed Mar 8, 2023
1 parent 45ad0c3 commit de77227
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 3 additions & 1 deletion packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {});
}
}

Expand Down
13 changes: 5 additions & 8 deletions packages/core.gbapp/services/GBMinService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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.
Expand Down
9 changes: 5 additions & 4 deletions packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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).`);
Expand Down
3 changes: 2 additions & 1 deletion packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,8 @@ export class WhatsappDirectLine extends GBService {
from: {
id: from,
channelIdEx: 'whatsapp',
name: fromName
name: fromName,
group: group
},
replyToId: from
}
Expand Down

0 comments on commit de77227

Please sign in to comment.