fix(whatsapp.gblib): Field mobile used instead of id in message.

This commit is contained in:
Rodrigo Rodriguez 2021-05-09 19:19:44 -03:00
parent 819b5937bb
commit ac9d065a61
4 changed files with 8 additions and 7 deletions

View file

@ -217,10 +217,10 @@ export class DialogKeywords {
* *
*/ */
public async userMobile(step) { public async userMobile(step) {
if (isNaN(step.context.activity.from.id)) { if (isNaN(step.context.activity['mobile'])) {
return 'No mobile available.'; return 'No mobile available.';
} else { } else {
return step.context.activity.from.id; return step.context.activity['mobile'];
} }
} }

View file

@ -220,14 +220,14 @@ export class GBConversationalService {
caption: string caption: string
): Promise<any> { ): Promise<any> {
if (step !== null) { if (step !== null) {
if (!isNaN(step.context.activity.from.id as any)) { if (!isNaN(step.context.activity['mobile'] as any)) {
mobile = step.context.activity.from.id; mobile = step.context.activity['mobile'];
GBLog.info(`Sending file ${url} to ${mobile}...`); GBLog.info(`Sending file ${url} to ${mobile}...`);
const filename = url.substring(url.lastIndexOf('/') + 1); const filename = url.substring(url.lastIndexOf('/') + 1);
await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption); await min.whatsAppDirectLine.sendFileToDevice(mobile, url, filename, caption);
} else { } else {
GBLog.info( 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); await min.conversationalService.sendText(min, step, url);
} }
@ -239,7 +239,7 @@ export class GBConversationalService {
} }
public async sendAudio(min: GBMinInstance, step: GBDialogStep, url: string): Promise<any> { 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}.`); GBLog.info(`Sending audio to ${mobile} in URL: ${url}.`);
await min.whatsAppDirectLine.sendAudioToDevice(mobile, url); await min.whatsAppDirectLine.sendAudioToDevice(mobile, url);
} }

View file

@ -253,7 +253,7 @@ export class AskDialog extends IGBDialog {
} }
private static getChannel(step): string { 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) { private static getAnswerEventDialog(service: KBService, min: GBMinInstance) {

View file

@ -315,6 +315,7 @@ export class WhatsappDirectLine extends GBService {
textFormat: 'plain', textFormat: 'plain',
text: text, text: text,
type: 'message', type: 'message',
mobile: from,
from: { from: {
id: from, id: from,
name: fromName name: fromName