From ac9d065a61f5a9c50c185642e2b17c6fbb653fcd Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Sun, 9 May 2021 19:19:44 -0300 Subject: [PATCH] fix(whatsapp.gblib): Field mobile used instead of id in message. --- packages/basic.gblib/services/DialogKeywords.ts | 4 ++-- packages/core.gbapp/services/GBConversationalService.ts | 8 ++++---- packages/kb.gbapp/dialogs/AskDialog.ts | 2 +- packages/whatsapp.gblib/services/WhatsappDirectLine.ts | 1 + 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 4d876bd3..27c560c4 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -217,10 +217,10 @@ export class DialogKeywords { * */ public async userMobile(step) { - if (isNaN(step.context.activity.from.id)) { + if (isNaN(step.context.activity['mobile'])) { return 'No mobile available.'; } else { - return step.context.activity.from.id; + return step.context.activity['mobile']; } } diff --git a/packages/core.gbapp/services/GBConversationalService.ts b/packages/core.gbapp/services/GBConversationalService.ts index 937ed393..c8c07c17 100644 --- a/packages/core.gbapp/services/GBConversationalService.ts +++ b/packages/core.gbapp/services/GBConversationalService.ts @@ -220,14 +220,14 @@ export class GBConversationalService { caption: string ): Promise { if (step !== null) { - if (!isNaN(step.context.activity.from.id as any)) { - mobile = step.context.activity.from.id; + if (!isNaN(step.context.activity['mobile'] as any)) { + mobile = step.context.activity['mobile']; GBLog.info(`Sending file ${url} to ${mobile}...`); const filename = url.substring(url.lastIndexOf('/') + 1); await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption); } else { GBLog.info( - `Sending ${url} as file attachment not available in this channel ${step.context.activity.from.id}...` + `Sending ${url} as file attachment not available in this channel ${step.context.activity['mobile']}...` ); await min.conversationalService.sendText(min, step, url); } @@ -239,7 +239,7 @@ export class GBConversationalService { } public async sendAudio(min: GBMinInstance, step: GBDialogStep, url: string): Promise { - const mobile = step.context.activity.from.id; + const mobile = step.context.activity['mobile']; GBLog.info(`Sending audio to ${mobile} in URL: ${url}.`); await min.whatsAppDirectLine.sendAudioToDevice(mobile, url); } diff --git a/packages/kb.gbapp/dialogs/AskDialog.ts b/packages/kb.gbapp/dialogs/AskDialog.ts index 5991a8f7..060a0abf 100644 --- a/packages/kb.gbapp/dialogs/AskDialog.ts +++ b/packages/kb.gbapp/dialogs/AskDialog.ts @@ -253,7 +253,7 @@ export class AskDialog extends IGBDialog { } private static getChannel(step): string { - return !isNaN(step.context.activity.from.id) ? 'whatsapp' : step.context.activity.channelId; + return !isNaN(step.context.activity['mobile']) ? 'whatsapp' : step.context.activity.channelId; } private static getAnswerEventDialog(service: KBService, min: GBMinInstance) { diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index f8191e14..0a1033be 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -315,6 +315,7 @@ export class WhatsappDirectLine extends GBService { textFormat: 'plain', text: text, type: 'message', + mobile: from, from: { id: from, name: fromName