Skip to content

Commit

Permalink
fix(whatsapp.gblib): Field mobile used instead of id in message.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigorodriguez committed May 9, 2021
1 parent 819b593 commit ac9d065
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/basic.gblib/services/DialogKeywords.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
}

Expand Down
8 changes: 4 additions & 4 deletions packages/core.gbapp/services/GBConversationalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,14 @@ export class GBConversationalService {
caption: string
): Promise<any> {
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);
}
Expand All @@ -239,7 +239,7 @@ export class GBConversationalService {
}

public async sendAudio(min: GBMinInstance, step: GBDialogStep, url: string): Promise<any> {
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);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/kb.gbapp/dialogs/AskDialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions packages/whatsapp.gblib/services/WhatsappDirectLine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ export class WhatsappDirectLine extends GBService {
textFormat: 'plain',
text: text,
type: 'message',
mobile: from,
from: {
id: from,
name: fromName
Expand Down

0 comments on commit ac9d065

Please sign in to comment.