fix(basic.gblib): Goto dialog within web.

This commit is contained in:
Rodrigo Rodriguez 2021-09-13 18:36:26 -03:00
parent 1bf3176d59
commit 43a3d58cb5
5 changed files with 31 additions and 13 deletions

View file

@ -450,6 +450,25 @@ export class DialogKeywords {
}
}
/**
* Prepares the next dialog to be shown to the specified user.
*/
public async gotoDialog(step, fromOrDialogName: string, dialogName: string) {
if (dialogName) {
let sec = new SecService();
let user = await sec.getUserFromSystemId(fromOrDialogName);
if (!user) {
user = await sec.ensureUser(this.min.instance.instanceId, fromOrDialogName,
fromOrDialogName, null, 'whatsapp', 'from', null);
}
await sec.updateUserHearOnDialog(user.userId, dialogName);
}
else {
await step.beginDialog(dialogName);
}
}
/**
* Talks to the user by using the specified text.
*/

View file

@ -242,7 +242,7 @@ export class GBVMService extends GBService {
});
code = code.replace(/(go to)(\s)(.*)/gi, ($0, $1, $2, $3) => {
return `sys().gotoDialog(${$3})\n`;
return `sys().gotoDialog(step, ${$3})\n`;
});
code = code.replace(/(hear)\s*(\w+)/gi, ($0, $1, $2) => {

View file

@ -144,17 +144,6 @@ export class SystemKeywords {
return data;
}
/**
* Prepares the next dialog to be shown to the specified user.
*/
public async gotoDialog(from: string, dialogName: string) {
let sec = new SecService();
let user = await sec.getUserFromSystemId(from);
if (!user) {
user = await sec.ensureUser(this.min.instance.instanceId, from, from, null, 'whatsapp', 'from', null);
}
await sec.updateUserHearOnDialog(user.userId, dialogName);
}
/**
* Holds script execution for the number of seconds specified.

View file

@ -444,6 +444,10 @@ export class GBDeployer implements IGBDeployer {
*/
public async downloadFolder(min: GBMinInstance, localPath: string, remotePath: string,
baseUrl: string = null, client = null): Promise<any> {
GBLog.info(`downloadFolder: localPath=${localPath}, remotePath=${remotePath}, baseUrl=${baseUrl}`);
if (!baseUrl) {
[baseUrl, client] = await GBDeployer.internalGetDriveClient(min);
@ -470,6 +474,8 @@ export class GBDeployer implements IGBDeployer {
const path = urlJoin(`/${botId}.gbai`, remotePath);
let url = `${baseUrl}/drive/root:${path}:/children`;
GBLog.info(`Download URL: ${url}`);
const res = await client
.api(url)
.get();

View file

@ -894,7 +894,11 @@ export class GBMinService {
// Skips if the bot is talking.
const startDialog = min.core.getParam(min.instance, 'Start Dialog', null);
if (context.activity.type === 'conversationUpdate' &&
if (context.activity.type === 'conversationUpdate')
{
GBLog.info(`Bot installed on Teams.`);
}
else if (context.activity.type === 'conversationUpdate' &&
context.activity.membersAdded.length > 0) {
// Check if a bot or a human participant is being added to the conversation.