@adlanarifzr/whatsapp-sdk
Advanced tools
Comparing version 0.0.8 to 0.1.0
@@ -1,4 +0,6 @@ | ||
import type { ContactObject, InteractiveObject, LocationObject, MediaObject, ReactionObject, TemplateObject, TextObject } from './message.ts'; | ||
import type { ContactObject, InteractiveObject, LocationObject, MediaObject, MessageRequestBody, MessageResponseSuccess, ReactionObject, TemplateObject, TextObject } from './message.ts'; | ||
import type { WebhookPayloadObject, WebhookValueObject, WebhookStatusObject, WebhookMessageObject, WebhookErrorObject } from './webhook.js'; | ||
import { TemplateCreateRequestBody, TemplateUpdateRequestBody, TemplateLanguage } from './messageTemplate.js'; | ||
export type { WebhookPayloadObject, WebhookValueObject, WebhookStatusObject, WebhookMessageObject, WebhookErrorObject }; | ||
export { TemplateLanguage }; | ||
export type WhatsappSdkConfig = { | ||
@@ -43,218 +45,2 @@ /** | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages#parameters}. | ||
*/ | ||
export type MessageRequestBody = { | ||
/** | ||
* **Required when type=audio.** | ||
* | ||
* A media object containing audio. | ||
*/ | ||
audio?: MediaObject; | ||
/** | ||
* **Optional.** | ||
* | ||
* An arbitrary string, useful for tracking. | ||
* | ||
* For example, you could pass the message template ID in this field to track your customer's journey starting from the first message you send. | ||
* You could then track the ROI of different message template types to determine the most effective one. | ||
* | ||
* Any app subscribed to the messages webhook field on the WhatsApp Business Account can get this string, | ||
* as it is included in [statuses object](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#statuses-object) | ||
* within webhook payloads. | ||
* | ||
* Cloud API does not process this field, it just returns it as part of sent/delivered/read message webhooks. | ||
* | ||
* Maximum 512 characters. | ||
* | ||
* Cloud API only. | ||
*/ | ||
biz_opaque_callback_data?: string; | ||
/** | ||
* **Required when type=contacts.** | ||
* | ||
* A contacts object. | ||
*/ | ||
contacts?: Array<ContactObject>; | ||
/** | ||
* **Required if replying to any message in the conversation.** | ||
* | ||
* An object containing the ID of a previous message you are replying to. For example: | ||
*/ | ||
context?: { | ||
/** | ||
* **Required.** | ||
* | ||
* The ID of the message you are replying to. | ||
*/ | ||
message_id: string; | ||
}; | ||
/** | ||
* **Required when type=document.** | ||
* | ||
* A media object containing a document. | ||
*/ | ||
document?: MediaObject; | ||
/** | ||
* **Required when type=image.** | ||
* | ||
* A media object containing a image. | ||
*/ | ||
image?: MediaObject; | ||
/** | ||
* **Required when type=interactive.** | ||
* | ||
* An interactive object. The components of each interactive object generally follow a consistent pattern: header, body, footer, and action. | ||
*/ | ||
interactive?: InteractiveObject; | ||
/** | ||
* **Required when type=location.** | ||
* | ||
* A location object. | ||
*/ | ||
location?: LocationObject; | ||
/** | ||
* **Required.** | ||
* | ||
* Messaging service used for the request. Use "whatsapp". | ||
* | ||
* Cloud API only. | ||
*/ | ||
messaging_product: 'whatsapp'; | ||
/** | ||
* **Required if type=text.** | ||
* | ||
* Allows for URL previews in text messages — See the [Sending URLs in Text Messages](https://developers.facebook.com/docs/whatsapp/api/messages/text#urls). | ||
* This field is optional if not including a URL in your message. Values: false (default), true. | ||
* | ||
* On-Premises API only. Cloud API users can use the same functionality with the preview_url field inside a text object. | ||
*/ | ||
preview_url?: boolean; | ||
/** | ||
* **Optional.** | ||
* | ||
* Currently, you can only send messages to individuals. Set this as individual. | ||
* | ||
* Default: individual | ||
*/ | ||
recipient_type?: 'individual'; | ||
/** | ||
* **Optional.** | ||
* | ||
* A message's status. You can use this field to mark a message as read. See the following guides for information: | ||
* - Cloud API: [Mark Messages as Read](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/mark-message-as-read) | ||
* - On-Premises API: [Mark Messages as Read](https://developers.facebook.com/docs/whatsapp/on-premises/guides/mark-as-read) | ||
*/ | ||
status?: 'read'; | ||
/** | ||
* **Required when type=sticker.** | ||
* | ||
* A media object containing a sticker. | ||
* | ||
* Cloud API: Static and animated third-party outbound stickers are supported in addition to all types of inbound stickers. | ||
* A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. | ||
* An animated sticker must be 512x512 pixels and cannot exceed 500 KB. | ||
* | ||
* On-Premises API: Only static third-party outbound stickers are supported in addition to all types of inbound stickers. | ||
* A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. Animated stickers are not supported. | ||
*/ | ||
sticker?: MediaObject; | ||
/** | ||
* **Required when type=template.** | ||
* | ||
* A template object. | ||
*/ | ||
template?: TemplateObject; | ||
/** | ||
* **Required for text messages.** | ||
* | ||
* A text object. | ||
*/ | ||
text?: TextObject; | ||
/** | ||
* **Required.** | ||
* | ||
* WhatsApp ID or phone number of the customer you want to send a message to. | ||
* See [Phone Number Formats](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#phone-number-formats). | ||
* | ||
* If needed, On-Premises API users can get this number by calling the [contacts endpoint](https://developers.facebook.com/docs/whatsapp/on-premises/reference/contacts). | ||
* | ||
* With the Cloud API, there is no longer a way to explicitly check if a phone number has a WhatsApp ID. | ||
* To send someone a message using the Cloud API, just send it directly to the customer's phone number —after they have [opted-in](https://developers.facebook.com/docs/whatsapp/overview/getting-opt-in). | ||
* See [Reference, Messages](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#examples) for examples. | ||
*/ | ||
to: string; | ||
/** | ||
* **Optional.** | ||
* | ||
* The type of message you want to send. If omitted, defaults to text. | ||
*/ | ||
type?: 'text' | 'template' | 'video' | 'document' | 'image' | 'contacts' | 'interactive' | 'location' | 'reaction' | 'sticker' | 'audio'; | ||
/** | ||
* **Required when type=video.** | ||
* | ||
* A media object containing video. | ||
*/ | ||
video?: MediaObject; | ||
/** | ||
* **Required when type=reaction.** | ||
* | ||
* A reaction object. | ||
*/ | ||
reaction?: ReactionObject; | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages/#successful-response}. | ||
*/ | ||
export type MessageResponseSuccess = { | ||
/** | ||
* A string that represents the messaging service used for the request. | ||
* This will always be "whatsapp". | ||
*/ | ||
messaging_product: 'whatsapp'; | ||
/** | ||
* An array of objects containing the input phone number and the WhatsApp ID of the recipient. | ||
* This is useful for tracking the status of the message. | ||
*/ | ||
contacts: Array<{ | ||
/** | ||
* The input phone number of the recipient. | ||
*/ | ||
input: string; | ||
/** | ||
* The WhatsApp ID of the recipient. | ||
*/ | ||
wa_id: string; | ||
}>; | ||
/** | ||
* An array of messages objects. | ||
* Each object contains the message ID and the status of the message. | ||
*/ | ||
messages: Array<{ | ||
/** | ||
* ID of the message. | ||
* | ||
* Messages are identified by a unique ID (WAMID). | ||
* You can track message status in the Webhooks through its WAMID. | ||
* You could also mark an incoming message as read through messages endpoint. | ||
* This WAMID can have a maximum length of up to 128 characters. | ||
*/ | ||
id: string; | ||
/** | ||
* Messages will have one of the following statuses which will be returned in each of the messages objects. | ||
* - "accepted" : means the message was sent to the intended recipient | ||
* - "held_for_quality_assessment": means the message send was delayed until quality can be validated and it will either be sent or dropped at this point | ||
*/ | ||
message_status: 'accepted' | 'held_for_quality_assessment'; | ||
}>; | ||
}; | ||
export type MessageResponseError = { | ||
error: { | ||
message: string; | ||
type: 'GraphMethodException' | string; | ||
code: number; | ||
error_subcode: number; | ||
fbtrace_id: string; | ||
}; | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/graph-api/webhooks/getting-started#verification-requests}. | ||
@@ -281,3 +67,4 @@ */ | ||
private sendMessage; | ||
private callApi; | ||
private callMessageApi; | ||
private callMessageTemplateApi; | ||
/** | ||
@@ -408,2 +195,45 @@ * Send template message. | ||
getMessagePrice: (to: string, type: "marketing" | "utility" | "authentication" | "authentication-international" | "service" | "referral_conversion") => number; | ||
/** | ||
* **Deleting by ID** | ||
* | ||
* To delete a template by ID, include the template's ID along with its name in your request; | ||
* only the template with the matching template ID will be deleted. | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#deleting-templates}. | ||
* | ||
* @param hsm_id The ID of the template. | ||
* @param name The name of the template. | ||
* @returns Object of axios response. | ||
*/ | ||
deleteMessageTemplateById: (hsm_id: string, name: string) => Promise<any>; | ||
/** | ||
* **Deleting by name** | ||
* | ||
* Deleting a template by name deletes all templates that match that name | ||
* (meaning templates with the same name but different languages will also be deleted). | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#deleting-templates}. | ||
* | ||
* @param name The name of the template. | ||
* @returns Object of axios response. | ||
*/ | ||
deleteMessageTemplateByName: (hsm_id: string, name: string) => Promise<any>; | ||
/** | ||
* **Create a message template** | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#creating-templates}. | ||
* | ||
* @param body The body of the request. | ||
* @returns Object of axios response. | ||
*/ | ||
createMessageTemplate: (body: TemplateCreateRequestBody) => Promise<any>; | ||
/** | ||
* **Update a message template** | ||
* | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#edit-a-message-template}. | ||
* | ||
* @param body The body of the request. | ||
* @returns Object of axios response. | ||
*/ | ||
updateMessageTemplate: (template_id: string | number, body: TemplateUpdateRequestBody) => Promise<any>; | ||
} |
@@ -29,5 +29,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TemplateLanguage = void 0; | ||
const axios_1 = __importStar(require("axios")); | ||
const pricing_json_1 = __importDefault(require("./pricing.json")); | ||
const libphonenumber_js_1 = __importDefault(require("libphonenumber-js")); | ||
const messageTemplate_js_1 = require("./messageTemplate.js"); | ||
Object.defineProperty(exports, "TemplateLanguage", { enumerable: true, get: function () { return messageTemplate_js_1.TemplateLanguage; } }); | ||
class WhatsappSdk { | ||
@@ -39,5 +42,5 @@ config; | ||
sendMessage = async (body) => { | ||
return this.callApi(body); | ||
return this.callMessageApi(body); | ||
}; | ||
callApi = async (body) => { | ||
callMessageApi = async (body) => { | ||
const endpoint = this.config.endpoint || 'https://graph.facebook.com'; | ||
@@ -66,2 +69,30 @@ const version = this.config.version || 'v20.0'; | ||
}; | ||
callMessageTemplateApi = async (config) => { | ||
const endpoint = this.config.endpoint || 'https://graph.facebook.com'; | ||
const version = this.config.version || 'v20.0'; | ||
const url = `${endpoint}/${version}/${this.config.phone_number_id}/message_templates`; | ||
try { | ||
const response = await axios_1.default.request({ | ||
method: 'POST', | ||
url, | ||
...(config ?? {}), | ||
headers: { | ||
...(config?.headers ?? {}), | ||
'Content-Type': 'application/json', | ||
Authorization: `Bearer ${this.config.auth_token}`, | ||
} | ||
}); | ||
return response.data; | ||
} | ||
catch (err) { | ||
if (err instanceof axios_1.AxiosError) { | ||
const { error } = err.response?.data; | ||
if (error.message) { | ||
throw new Error(JSON.stringify(error)); | ||
} | ||
throw new Error(err.message); | ||
} | ||
throw err; | ||
} | ||
}; | ||
/** | ||
@@ -266,3 +297,3 @@ * Send template message. | ||
}; | ||
return this.callApi(body); | ||
return this.callMessageApi(body); | ||
}; | ||
@@ -305,3 +336,74 @@ /** | ||
}; | ||
/** | ||
* **Deleting by ID** | ||
* | ||
* To delete a template by ID, include the template's ID along with its name in your request; | ||
* only the template with the matching template ID will be deleted. | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#deleting-templates}. | ||
* | ||
* @param hsm_id The ID of the template. | ||
* @param name The name of the template. | ||
* @returns Object of axios response. | ||
*/ | ||
deleteMessageTemplateById = async (hsm_id, name) => { | ||
return this.callMessageTemplateApi({ | ||
method: 'DELETE', | ||
params: { | ||
hsm_id, | ||
name | ||
} | ||
}); | ||
}; | ||
/** | ||
* **Deleting by name** | ||
* | ||
* Deleting a template by name deletes all templates that match that name | ||
* (meaning templates with the same name but different languages will also be deleted). | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#deleting-templates}. | ||
* | ||
* @param name The name of the template. | ||
* @returns Object of axios response. | ||
*/ | ||
deleteMessageTemplateByName = async (hsm_id, name) => { | ||
return this.callMessageTemplateApi({ | ||
method: 'DELETE', | ||
params: { | ||
name | ||
} | ||
}); | ||
}; | ||
/** | ||
* **Create a message template** | ||
* | ||
* Documentation {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#creating-templates}. | ||
* | ||
* @param body The body of the request. | ||
* @returns Object of axios response. | ||
*/ | ||
createMessageTemplate = async (body) => { | ||
return this.callMessageTemplateApi({ | ||
method: 'POST', | ||
data: body, | ||
}); | ||
}; | ||
/** | ||
* **Update a message template** | ||
* | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/#edit-a-message-template}. | ||
* | ||
* @param body The body of the request. | ||
* @returns Object of axios response. | ||
*/ | ||
updateMessageTemplate = async (template_id, body) => { | ||
const endpoint = this.config.endpoint || 'https://graph.facebook.com'; | ||
const version = this.config.version || 'v20.0'; | ||
return this.callMessageTemplateApi({ | ||
method: 'POST', | ||
url: `${endpoint}/${version}/${template_id}`, | ||
data: body, | ||
}); | ||
}; | ||
} | ||
exports.default = WhatsappSdk; |
@@ -876,1 +876,217 @@ /** | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/on-premises/reference/messages#parameters}. | ||
*/ | ||
export type MessageRequestBody = { | ||
/** | ||
* **Required when type=audio.** | ||
* | ||
* A media object containing audio. | ||
*/ | ||
audio?: MediaObject; | ||
/** | ||
* **Optional.** | ||
* | ||
* An arbitrary string, useful for tracking. | ||
* | ||
* For example, you could pass the message template ID in this field to track your customer's journey starting from the first message you send. | ||
* You could then track the ROI of different message template types to determine the most effective one. | ||
* | ||
* Any app subscribed to the messages webhook field on the WhatsApp Business Account can get this string, | ||
* as it is included in [statuses object](https://developers.facebook.com/docs/whatsapp/cloud-api/webhooks/components#statuses-object) | ||
* within webhook payloads. | ||
* | ||
* Cloud API does not process this field, it just returns it as part of sent/delivered/read message webhooks. | ||
* | ||
* Maximum 512 characters. | ||
* | ||
* Cloud API only. | ||
*/ | ||
biz_opaque_callback_data?: string; | ||
/** | ||
* **Required when type=contacts.** | ||
* | ||
* A contacts object. | ||
*/ | ||
contacts?: Array<ContactObject>; | ||
/** | ||
* **Required if replying to any message in the conversation.** | ||
* | ||
* An object containing the ID of a previous message you are replying to. For example: | ||
*/ | ||
context?: { | ||
/** | ||
* **Required.** | ||
* | ||
* The ID of the message you are replying to. | ||
*/ | ||
message_id: string; | ||
}; | ||
/** | ||
* **Required when type=document.** | ||
* | ||
* A media object containing a document. | ||
*/ | ||
document?: MediaObject; | ||
/** | ||
* **Required when type=image.** | ||
* | ||
* A media object containing a image. | ||
*/ | ||
image?: MediaObject; | ||
/** | ||
* **Required when type=interactive.** | ||
* | ||
* An interactive object. The components of each interactive object generally follow a consistent pattern: header, body, footer, and action. | ||
*/ | ||
interactive?: InteractiveObject; | ||
/** | ||
* **Required when type=location.** | ||
* | ||
* A location object. | ||
*/ | ||
location?: LocationObject; | ||
/** | ||
* **Required.** | ||
* | ||
* Messaging service used for the request. Use "whatsapp". | ||
* | ||
* Cloud API only. | ||
*/ | ||
messaging_product: 'whatsapp'; | ||
/** | ||
* **Required if type=text.** | ||
* | ||
* Allows for URL previews in text messages — See the [Sending URLs in Text Messages](https://developers.facebook.com/docs/whatsapp/api/messages/text#urls). | ||
* This field is optional if not including a URL in your message. Values: false (default), true. | ||
* | ||
* On-Premises API only. Cloud API users can use the same functionality with the preview_url field inside a text object. | ||
*/ | ||
preview_url?: boolean; | ||
/** | ||
* **Optional.** | ||
* | ||
* Currently, you can only send messages to individuals. Set this as individual. | ||
* | ||
* Default: individual | ||
*/ | ||
recipient_type?: 'individual'; | ||
/** | ||
* **Optional.** | ||
* | ||
* A message's status. You can use this field to mark a message as read. See the following guides for information: | ||
* - Cloud API: [Mark Messages as Read](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/mark-message-as-read) | ||
* - On-Premises API: [Mark Messages as Read](https://developers.facebook.com/docs/whatsapp/on-premises/guides/mark-as-read) | ||
*/ | ||
status?: 'read'; | ||
/** | ||
* **Required when type=sticker.** | ||
* | ||
* A media object containing a sticker. | ||
* | ||
* Cloud API: Static and animated third-party outbound stickers are supported in addition to all types of inbound stickers. | ||
* A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. | ||
* An animated sticker must be 512x512 pixels and cannot exceed 500 KB. | ||
* | ||
* On-Premises API: Only static third-party outbound stickers are supported in addition to all types of inbound stickers. | ||
* A static sticker needs to be 512x512 pixels and cannot exceed 100 KB. Animated stickers are not supported. | ||
*/ | ||
sticker?: MediaObject; | ||
/** | ||
* **Required when type=template.** | ||
* | ||
* A template object. | ||
*/ | ||
template?: TemplateObject; | ||
/** | ||
* **Required for text messages.** | ||
* | ||
* A text object. | ||
*/ | ||
text?: TextObject; | ||
/** | ||
* **Required.** | ||
* | ||
* WhatsApp ID or phone number of the customer you want to send a message to. | ||
* See [Phone Number Formats](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/phone-numbers#phone-number-formats). | ||
* | ||
* If needed, On-Premises API users can get this number by calling the [contacts endpoint](https://developers.facebook.com/docs/whatsapp/on-premises/reference/contacts). | ||
* | ||
* With the Cloud API, there is no longer a way to explicitly check if a phone number has a WhatsApp ID. | ||
* To send someone a message using the Cloud API, just send it directly to the customer's phone number —after they have [opted-in](https://developers.facebook.com/docs/whatsapp/overview/getting-opt-in). | ||
* See [Reference, Messages](https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#examples) for examples. | ||
*/ | ||
to: string; | ||
/** | ||
* **Optional.** | ||
* | ||
* The type of message you want to send. If omitted, defaults to text. | ||
*/ | ||
type?: 'text' | 'template' | 'video' | 'document' | 'image' | 'contacts' | 'interactive' | 'location' | 'reaction' | 'sticker' | 'audio'; | ||
/** | ||
* **Required when type=video.** | ||
* | ||
* A media object containing video. | ||
*/ | ||
video?: MediaObject; | ||
/** | ||
* **Required when type=reaction.** | ||
* | ||
* A reaction object. | ||
*/ | ||
reaction?: ReactionObject; | ||
}; | ||
/** | ||
* Documentation: {@link https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages/#successful-response}. | ||
*/ | ||
export type MessageResponseSuccess = { | ||
/** | ||
* A string that represents the messaging service used for the request. | ||
* This will always be "whatsapp". | ||
*/ | ||
messaging_product: 'whatsapp'; | ||
/** | ||
* An array of objects containing the input phone number and the WhatsApp ID of the recipient. | ||
* This is useful for tracking the status of the message. | ||
*/ | ||
contacts: Array<{ | ||
/** | ||
* The input phone number of the recipient. | ||
*/ | ||
input: string; | ||
/** | ||
* The WhatsApp ID of the recipient. | ||
*/ | ||
wa_id: string; | ||
}>; | ||
/** | ||
* An array of messages objects. | ||
* Each object contains the message ID and the status of the message. | ||
*/ | ||
messages: Array<{ | ||
/** | ||
* ID of the message. | ||
* | ||
* Messages are identified by a unique ID (WAMID). | ||
* You can track message status in the Webhooks through its WAMID. | ||
* You could also mark an incoming message as read through messages endpoint. | ||
* This WAMID can have a maximum length of up to 128 characters. | ||
*/ | ||
id: string; | ||
/** | ||
* Messages will have one of the following statuses which will be returned in each of the messages objects. | ||
* - "accepted" : means the message was sent to the intended recipient | ||
* - "held_for_quality_assessment": means the message send was delayed until quality can be validated and it will either be sent or dropped at this point | ||
*/ | ||
message_status: 'accepted' | 'held_for_quality_assessment'; | ||
}>; | ||
}; | ||
export type MessageResponseError = { | ||
error: { | ||
message: string; | ||
type: 'GraphMethodException' | string; | ||
code: number; | ||
error_subcode: number; | ||
fbtrace_id: string; | ||
}; | ||
}; |
@@ -0,1 +1,2 @@ | ||
import { TemplateLanguage } from './messageTemplate'; | ||
/** | ||
@@ -32,5 +33,5 @@ * Documentation: {@link https://developers.facebook.com/docs/graph-api/webhooks/getting-started#event-notifications}. | ||
/** | ||
* Notification type. Value will be messages. | ||
* Notification type. | ||
*/ | ||
field: 'messages'; | ||
field: 'messages' | 'message_template_status_update' | 'message_template_components_update'; | ||
}>; | ||
@@ -98,2 +99,91 @@ }>; | ||
statuses?: Array<WebhookStatusObject>; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The template ID. | ||
*/ | ||
message_template_id?: string | number; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The template name. | ||
*/ | ||
message_template_name?: string; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The template language | ||
*/ | ||
message_template_language?: TemplateLanguage; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The new template header after the change. | ||
* | ||
* Remains empty if the user did not enter a header. | ||
*/ | ||
message_template_title?: string; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The new template body after the change. | ||
* | ||
* Remains empty if the user did not enter new body text. | ||
*/ | ||
message_template_element?: string; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The new template footer after the change. | ||
* | ||
* Remains empty if the user did not enter new footer text. | ||
*/ | ||
message_template_footer?: string; | ||
/** | ||
* Only applicable for message template webhook. | ||
* | ||
* The new list of buttons on the template after the change. | ||
* | ||
* Only URL type and Phone number type buttons are supported for this webhook. | ||
*/ | ||
message_template_buttons?: Array<{ | ||
/** | ||
* **Required.** | ||
* | ||
* Type of button. | ||
*/ | ||
message_template_button_type: string; | ||
/** | ||
* **Required.** | ||
* | ||
* Button label text. | ||
* | ||
* For type URL, if using a variable, must include the example property and a sample value. | ||
* | ||
* 25 characters maximum. | ||
*/ | ||
message_template_button_text: string; | ||
/** | ||
* **Required if message_template_button_type is URL.** | ||
*/ | ||
message_template_button_url?: string; | ||
/** | ||
* **Required if message_template_button_type is PHONE_NUMBER.** | ||
*/ | ||
message_template_button_phone_number?: string; | ||
}>; | ||
/** | ||
* Only applicable for message template webhook (status changed). | ||
* | ||
* Field: message_template_status_update | ||
* | ||
* The template ID. | ||
*/ | ||
event?: 'REJECTED' | 'APPROVED' | 'PENDING_DELETION'; | ||
/** | ||
* Only applicable for message template webhook (status changed). | ||
* | ||
* Field: message_template_status_update | ||
*/ | ||
reason?: 'INCORRECT_CATEGORY' | 'NONE' | string; | ||
}; | ||
@@ -100,0 +190,0 @@ /** |
{ | ||
"name": "@adlanarifzr/whatsapp-sdk", | ||
"description": "Whatsapp Cloud API unofficial SDK", | ||
"version": "0.0.8", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "rm -rf ./dist && tsc", | ||
"build": "tsc" | ||
"build": "tsc", | ||
"publish": "npm publish --access public" | ||
}, | ||
@@ -10,0 +11,0 @@ "repository": { |
134860
12
4109