whatsapp-nodejs-sdk
Advanced tools
Comparing version 1.0.11 to 1.0.12
@@ -55,2 +55,19 @@ import { AxiosInstance, AxiosResponse } from 'axios'; | ||
/** | ||
* Send a template message via WhatsApp. | ||
* | ||
* @param number - The recipient's WhatsApp number. | ||
* @param templateName - The name of the template to send. | ||
* @param templateLanguage - The language of the template to send. | ||
* @param components - The components of the template to send. | ||
* @param messageId - Optional WhatsApp message ID for context. | ||
* @returns {Promise<AxiosResponse<any, any>>} - Returns the response from the WhatsApp API, or throws an error. | ||
*/ | ||
sendTemplateMessage(number: string, templateName: string, templateLanguage: string, components: { | ||
type: string; | ||
parameters: { | ||
type: string; | ||
text: string; | ||
}[]; | ||
}[], messageId?: string): Promise<AxiosResponse<any, any>>; | ||
/** | ||
* Extract the contact's name from the WhatsApp webhook payload. | ||
@@ -57,0 +74,0 @@ * |
@@ -142,2 +142,26 @@ "use strict"; | ||
/** | ||
* Send a template message via WhatsApp. | ||
* | ||
* @param number - The recipient's WhatsApp number. | ||
* @param templateName - The name of the template to send. | ||
* @param templateLanguage - The language of the template to send. | ||
* @param components - The components of the template to send. | ||
* @param messageId - Optional WhatsApp message ID for context. | ||
* @returns {Promise<AxiosResponse<any, any>>} - Returns the response from the WhatsApp API, or throws an error. | ||
*/ | ||
sendTemplateMessage(number, templateName, templateLanguage, components, messageId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const data = { | ||
template: { | ||
name: templateName, | ||
language: { | ||
code: templateLanguage | ||
}, | ||
components, | ||
} | ||
}; | ||
return this.sendMessage(number, "template", data, messageId); | ||
}); | ||
} | ||
/** | ||
* Extract the contact's name from the WhatsApp webhook payload. | ||
@@ -144,0 +168,0 @@ * |
@@ -1,2 +0,2 @@ | ||
export type MessageType = "text" | "interactive" | "image" | "document"; | ||
export type MessageType = "text" | "interactive" | "image" | "document" | "template"; | ||
export type InteractiveMessageType = "button" | "list"; | ||
@@ -3,0 +3,0 @@ export type MediaMessageType = "image" | "document"; |
{ | ||
"name": "whatsapp-nodejs-sdk", | ||
"version": "1.0.11", | ||
"version": "1.0.12", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
23944
515