feat: whatsapp cloud api components in template

This commit is contained in:
Davidson Gomes 2024-02-17 18:41:35 -03:00
parent 9ef14d11f8
commit ab89ef8db3
3 changed files with 7 additions and 0 deletions

View File

@ -288,6 +288,7 @@ export const templateMessageSchema: JSONSchema7 = {
properties: {
name: { type: 'string' },
language: { type: 'string' },
components: { type: 'array' },
},
required: ['name', 'language'],
...isNotEmpty('name', 'language'),

View File

@ -146,6 +146,7 @@ export class ContactMessage {
export class TemplateMessage {
name: string;
language: string;
components: any;
}
export class SendTemplateDto extends Metadata {

View File

@ -685,6 +685,7 @@ export class BusinessStartupService extends WAStartupService {
language: {
code: message['template']['language'] || 'en_US',
},
components: message['template']['components'],
},
};
quoted ? (content.context = { message_id: quoted.id }) : content;
@ -693,6 +694,8 @@ export class BusinessStartupService extends WAStartupService {
}
})();
console.log(messageSent);
const messageRaw: MessageRaw = {
key: { fromMe: true, id: messageSent?.messages[0]?.id, remoteJid: this.createJid(number) },
//pushName: messageSent.pushName,
@ -722,6 +725,7 @@ export class BusinessStartupService extends WAStartupService {
return messageRaw;
} catch (error) {
this.logger.error(error);
console.log(error.data);
throw new BadRequestException(error.toString());
}
}
@ -921,6 +925,7 @@ export class BusinessStartupService extends WAStartupService {
template: {
name: data.templateMessage.name,
language: data.templateMessage.language,
components: data.templateMessage.components,
},
},
data?.options,