Skip to content

Commit ab89ef8

Browse files
committed
feat: whatsapp cloud api components in template
1 parent 9ef14d1 commit ab89ef8

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/validate/validate.schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export const templateMessageSchema: JSONSchema7 = {
288288
properties: {
289289
name: { type: 'string' },
290290
language: { type: 'string' },
291+
components: { type: 'array' },
291292
},
292293
required: ['name', 'language'],
293294
...isNotEmpty('name', 'language'),

src/whatsapp/dto/sendMessage.dto.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export class ContactMessage {
146146
export class TemplateMessage {
147147
name: string;
148148
language: string;
149+
components: any;
149150
}
150151

151152
export class SendTemplateDto extends Metadata {

src/whatsapp/services/whatsapp.business.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ export class BusinessStartupService extends WAStartupService {
685685
language: {
686686
code: message['template']['language'] || 'en_US',
687687
},
688+
components: message['template']['components'],
688689
},
689690
};
690691
quoted ? (content.context = { message_id: quoted.id }) : content;
@@ -693,6 +694,8 @@ export class BusinessStartupService extends WAStartupService {
693694
}
694695
})();
695696

697+
console.log(messageSent);
698+
696699
const messageRaw: MessageRaw = {
697700
key: { fromMe: true, id: messageSent?.messages[0]?.id, remoteJid: this.createJid(number) },
698701
//pushName: messageSent.pushName,
@@ -722,6 +725,7 @@ export class BusinessStartupService extends WAStartupService {
722725
return messageRaw;
723726
} catch (error) {
724727
this.logger.error(error);
728+
console.log(error.data);
725729
throw new BadRequestException(error.toString());
726730
}
727731
}
@@ -921,6 +925,7 @@ export class BusinessStartupService extends WAStartupService {
921925
template: {
922926
name: data.templateMessage.name,
923927
language: data.templateMessage.language,
928+
components: data.templateMessage.components,
924929
},
925930
},
926931
data?.options,

0 commit comments

Comments
 (0)