From 90cf855810b1c37b0e36d99205d60d37181fb21d Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Tue, 14 Jun 2022 11:38:45 -0300 Subject: [PATCH] new(whatsapp.gblib): New provider. --- .../basic.gblib/services/DialogKeywords.ts | 21 +++++++++++++++++++ .../services/GBConversationalService.ts | 12 ++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 59b9d5fa..f05d0136 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -218,6 +218,27 @@ export class DialogKeywords { ]); } + /** + * Returns the screenshot of page or element + * + * @example file = SCREENSHOT page + */ + public async getTableData(step, page, selector) { + + const data = await page.evaluate(() => { + const rows = document.querySelectorAll(`${selector} tr`); + return Array.from(rows, row => { + const columns = row.querySelectorAll('td'); + return Array.from(columns, column => column.innerText); + }); + }); + + //You will now have an array of strings + //[ 'One', 'Two', 'Three', 'Four' ] + console.log(data); + + + } /** * Returns the screenshot of page or element diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index 8eb2a239..6c9bd595 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -525,6 +525,12 @@ export class GBConversationalService { let currentCaption = ''; let currentEmbedUrl = ''; + let conversationId = null; + + if(step ){ + conversationId = step.context.activity.conversation.id; + } + //![General Bots](/instance/images/gb.png) for (let i = 0; i < text.length; i++) { const c = text.charAt(i); @@ -559,7 +565,7 @@ export class GBConversationalService { if (!mobile) { await step.context.sendActivity(currentText); } else { - await this.sendToMobile(min, mobile, currentText, step.context.activity.conversation.id); + await this.sendToMobile(min, mobile, currentText, conversationId); } await sleep(3000); currentText = ''; @@ -579,7 +585,7 @@ export class GBConversationalService { if (!mobile) { await step.context.sendActivity(currentText); } else { - await this.sendToMobile(min, mobile, currentText, step.context.activity.conversation.id); + await this.sendToMobile(min, mobile, currentText, conversationId); } await sleep(3000); } @@ -612,7 +618,7 @@ export class GBConversationalService { if (!mobile) { await step.context.sendActivity(currentText); } else { - await this.sendToMobile(min, mobile, currentText, step.context.activity.conversation.id); + await this.sendToMobile(min, mobile, currentText, conversationId); } await sleep(2900); }