diff --git a/packages/basic.gblib/services/DialogKeywords.ts b/packages/basic.gblib/services/DialogKeywords.ts index 2ea0b90ff..9138cbd78 100644 --- a/packages/basic.gblib/services/DialogKeywords.ts +++ b/packages/basic.gblib/services/DialogKeywords.ts @@ -41,6 +41,7 @@ import { SecService } from '../../security.gbapp/services/SecService'; import { SystemKeywords } from './SystemKeywords'; import { GBMinService } from '../../core.gbapp/services/GBMinService'; import { HubSpotServices } from '../../hubspot.gblib/services/HubSpotServices'; +import { WhatsappDirectLine } from '../../whatsapp.gblib/services/WhatsappDirectLine'; var DateDiff = require('date-diff'); @@ -414,7 +415,7 @@ export class DialogKeywords { * Returns the name of the user acquired by WhatsApp API. */ public async userName(step) { - return step ? step.context.activity.from.name : 'N/A'; + return step ? WhatsappDirectLine.usernames[await this.userMobile(step)] : 'N/A'; } /** diff --git a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts index 424595720..fb70b45c3 100644 --- a/packages/whatsapp.gblib/services/WhatsappDirectLine.ts +++ b/packages/whatsapp.gblib/services/WhatsappDirectLine.ts @@ -51,6 +51,7 @@ export class WhatsappDirectLine extends GBService { public static conversationIds = {}; public static mobiles = {}; public static chatIds = {}; + public static usernames = {}; public pollInterval = 3000; public directLineClientName = 'DirectLineClient'; @@ -371,7 +372,9 @@ export class WhatsappDirectLine extends GBService { WhatsappDirectLine.conversationIds[from + group] = generatedConversationId; WhatsappDirectLine.mobiles[generatedConversationId] = from; + WhatsappDirectLine.usernames[from] = fromName; WhatsappDirectLine.chatIds[generatedConversationId] = message.chatId; + this.pollMessages(client, generatedConversationId, from, fromName); this.inputMessage(client, generatedConversationId, text, from, fromName, group);