whatsapp-business
Advanced tools
Comparing version 1.7.2 to 1.8.0
{ | ||
"name": "whatsapp-business", | ||
"author": "MarcosNicolau", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.", | ||
@@ -38,3 +38,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"axios": "^1.6.7", | ||
"express": "^4.18.2", | ||
@@ -41,0 +41,0 @@ "form-data": "^4.0.0" |
@@ -10,1 +10,2 @@ export * from "./business"; | ||
export * from "./webhooks"; | ||
export * from "./healthStatus"; |
@@ -26,1 +26,2 @@ "use strict"; | ||
__exportStar(require("./webhooks"), exports); | ||
__exportStar(require("./healthStatus"), exports); |
@@ -40,2 +40,11 @@ import { SupportedLanguagesCodeUnion } from "./languageCodes"; | ||
/** | ||
* 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 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. | ||
* | ||
*/ | ||
biz_opaque_callback_data?: string; | ||
/** | ||
* Use it if you want to use the reply-to feature when answering a message | ||
@@ -199,5 +208,8 @@ */ | ||
}; | ||
/** | ||
* See more here https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#action-object | ||
*/ | ||
export type InteractiveMessageAction = { | ||
/** | ||
* Required for catalog_messages | ||
* Required for catalog_messages and location_request_message | ||
*/ | ||
@@ -214,3 +226,3 @@ name?: string; | ||
/** | ||
* Required for List Messages. | ||
* Required for List Messages and location_request_message. | ||
* Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not. | ||
@@ -259,2 +271,55 @@ * | ||
sections?: InteractiveActionSection[]; | ||
/** | ||
* Optional for Flows Messages. | ||
* | ||
* The current mode of the Flow, either draft or published. | ||
* | ||
* Default: published | ||
*/ | ||
mode?: "draft" | "published"; | ||
/** | ||
* Required for Flows Messages. | ||
*/ | ||
flow_message_version?: LiteralUnion<"3">; | ||
/** | ||
* Required for Flows Messages. | ||
* A token that is generated by the business to serve as an identifier. | ||
*/ | ||
flow_token?: string; | ||
/** | ||
* Required for Flows Messages. | ||
* | ||
* Unique identifier of the Flow provided by WhatsApp. | ||
*/ | ||
flow_id?: string; | ||
/** | ||
* Required for Flows Messages. | ||
* | ||
* Text on the CTA button, eg. "Signup". | ||
* | ||
* Maximum length: 20 characters (no emoji). | ||
*/ | ||
flow_cta?: string; | ||
/** | ||
* Optional for Flows Messages. | ||
* | ||
* navigate or data_exchange. Use navigate to predefine the first screen as part of the message. Use data_exchange for advanced use-cases where the first screen is provided by your endpoint. | ||
* | ||
* Default: navigate | ||
*/ | ||
flow_action?: "navigate" | "data_exchange"; | ||
/** | ||
* Optional for Flows Messages. | ||
* Required only if flow_action is navigate. | ||
*/ | ||
flow_action_payload?: { | ||
/** | ||
* Required. The id of the first screen of the Flow. | ||
*/ | ||
screen: string; | ||
/** | ||
* Optional. The input data for the first screen of the Flow. Must be a non-empty object. | ||
*/ | ||
data?: object; | ||
}; | ||
}; | ||
@@ -325,3 +390,3 @@ export type InteractiveMessageBody = { | ||
header?: InteractiveMessageHeader; | ||
type: "list" | "button" | "product" | "product_list" | "catalog_message"; | ||
type: "list" | "button" | "product" | "product_list" | "catalog_message" | "flow" | "location_request_message"; | ||
}; | ||
@@ -353,2 +418,10 @@ export type ContactMessage = { | ||
* required for type=text | ||
* The message’s text. Character limit varies based on the following included component type. | ||
* | ||
* For the header component type: | ||
* 60 characters | ||
* | ||
* For the body component type: | ||
* 1024 characters if other component types are included | ||
* 32768 characters if body is the only component type included | ||
*/ | ||
@@ -360,2 +433,5 @@ text?: string; | ||
currency?: { | ||
/** | ||
* Default text if localization fails. | ||
*/ | ||
fallback_value: string; | ||
@@ -372,2 +448,5 @@ /** | ||
date_time?: { | ||
/** | ||
* Default text | ||
*/ | ||
fallback_value: string; | ||
@@ -380,3 +459,3 @@ }; | ||
export type TemplateMessageButtonParameter = GenerateMappedNever<TemplateMessageParameter> & { | ||
type: "payload" | "text" | "catalog"; | ||
type: "payload" | "text"; | ||
/** | ||
@@ -397,3 +476,3 @@ * required for quick_reply buttons | ||
*/ | ||
sub_type?: "quick_reply" | "url"; | ||
sub_type?: "quick_reply" | "url" | "catalog"; | ||
/** | ||
@@ -405,2 +484,4 @@ * required when type=button | ||
* required when type=button | ||
* | ||
* Position index of the button. You can have up to 10 buttons using index values of 0 to 9. | ||
*/ | ||
@@ -419,2 +500,5 @@ index?: number; | ||
}; | ||
/** | ||
* See more here https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages#template-object | ||
*/ | ||
export type TemplateMessage = { | ||
@@ -421,0 +505,0 @@ name: string; |
@@ -19,2 +19,6 @@ import { WABAErrorCodes } from "./error"; | ||
title: string; | ||
message: string; | ||
error_data: { | ||
details: string; | ||
}; | ||
}; | ||
@@ -63,7 +67,7 @@ export type WebhookMedia = { | ||
*/ | ||
payload: any; | ||
payload: string; | ||
text: string; | ||
}; | ||
/** | ||
* When the messages type field is set to button, this object is included in the messages object. The context for a message that was forwarded or in an inbound reply from the customer. | ||
* Context object. Only included when a user replies or interacts with one of your messages. Context objects can have the following properties | ||
*/ | ||
@@ -87,2 +91,9 @@ context?: { | ||
id: string; | ||
/** | ||
* Referred product object describing the product the user is requesting information about. You must parse this value if you support Product Enquiry Messages | ||
*/ | ||
referred_product: { | ||
catalog_id: string; | ||
product_retailer_id: string; | ||
}; | ||
}; | ||
@@ -97,2 +108,6 @@ /** | ||
errors?: WebhookError[]; | ||
/** | ||
* The customer's WhatsApp ID. A business can respond to a customer using this ID. | ||
* This ID may not match the customer's phone number, which is returned by the API as input when sending a message to the customer. | ||
*/ | ||
from: string; | ||
@@ -108,3 +123,2 @@ /** | ||
acknowledged: boolean; | ||
customer_identity_changed: boolean; | ||
/** | ||
@@ -152,3 +166,18 @@ * The time when the WhatsApp Business Management API detected the customer may have changed their profile information | ||
/** | ||
* Included in the messages object when a customer has placed an order. Order objects have the following properties: | ||
*/ | ||
order?: { | ||
catalog_id: string; | ||
text: string; | ||
product_items: { | ||
product_retailer_id: string; | ||
quantity: string; | ||
item_price: string; | ||
currency: string; | ||
}[]; | ||
}; | ||
/** | ||
* A customer clicked an ad that redirects them to WhatsApp. | ||
* | ||
* The referral object can be included in the following types of message: text, location, contact, image, video, document, voice, and sticker. | ||
*/ | ||
@@ -186,2 +215,3 @@ referral?: { | ||
thumbnail_url: string; | ||
ctwa_clid: string; | ||
}; | ||
@@ -198,2 +228,6 @@ /** | ||
id: string; | ||
/** | ||
* Set to true if the sticker is animated; false otherwise. | ||
*/ | ||
animated: boolean; | ||
}; | ||
@@ -262,2 +296,6 @@ /** | ||
/** | ||
* Arbitrary string included in sent message. See Message object. | ||
*/ | ||
biz_opaque_callback_data: string; | ||
/** | ||
* An object containing billing information. | ||
@@ -269,16 +307,3 @@ */ | ||
*/ | ||
category: { | ||
/** | ||
* The business sent a message to a customer more than 24 hours after the last customer message | ||
*/ | ||
business_initiated: boolean; | ||
/** | ||
* The conversation originated from a free entry point. These conversations are always customer-initiated. | ||
*/ | ||
referral_conversion: boolean; | ||
/** | ||
* The business replied to a customer message within 24 hours of the last customer message | ||
*/ | ||
customer_initiated: boolean; | ||
}; | ||
category: "authentication" | "marketing" | "utility" | "service" | "referral_conversion"; | ||
/** | ||
@@ -301,21 +326,5 @@ * Type of pricing model used by the business. | ||
*/ | ||
type: { | ||
/** | ||
* Indicates that the conversation started by a business sending the first message to a customer. This applies any time it has been more than 24 hours since the last customer message. | ||
*/ | ||
business_initiated: boolean; | ||
/** | ||
* Indicates that the conversation started by a business replying to a customer message. This applies only when the business reply is within 24 hours of the last customer message. | ||
*/ | ||
customer_initiated: boolean; | ||
/** | ||
* Indicates that the conversation originated from a free entry point. These conversations are always customer-initiated. | ||
*/ | ||
referral_conversation: boolean; | ||
}; | ||
/** | ||
* Date when the conversation expires. This field is only present for messages with a `status` set to `sent` | ||
*/ | ||
expiration_timestamp: string; | ||
type: "authentication" | "marketing" | "utility" | "service" | "business_initiated" | "customer_initiated" | "referral_conversation"; | ||
}; | ||
expiration_timestamp: string; | ||
}; | ||
@@ -322,0 +331,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Message, SendMessageResponse, GetBusinessPhoneNumberResponse, RequestPhoneNumberVerificationCodeArgs, VerifyPhoneNumberArgs, RegisterPhoneArgs, SetUpTwoFactorAuthArgs, DefaultResponse, BusinessProfile, BusinessProfileFieldsQuery, UpdateBusinessProfilePayload, GetMediaResponse, UploadMediaPayload, UploadMediaResponse, BusinessPhoneNumber, UpdateIdentityCheckState } from "./types"; | ||
import { Message, SendMessageResponse, GetBusinessPhoneNumberResponse, RequestPhoneNumberVerificationCodeArgs, VerifyPhoneNumberArgs, RegisterPhoneArgs, SetUpTwoFactorAuthArgs, DefaultResponse, BusinessProfile, BusinessProfileFieldsQuery, UpdateBusinessProfilePayload, GetMediaResponse, UploadMediaPayload, UploadMediaResponse, BusinessPhoneNumber, UpdateIdentityCheckState, HealthStatusResponse } from "./types"; | ||
import { createRestClient } from "./utils/restClient"; | ||
@@ -83,3 +83,8 @@ interface WABAClientArgs { | ||
setupTwoStepAuth({ phoneNumberId, ...payload }: SetUpTwoFactorAuthArgs): Promise<DefaultResponse>; | ||
/** | ||
* | ||
* @param nodeId is optional, defaults to the account_id | ||
*/ | ||
getHealthStatus(nodeId?: string): Promise<HealthStatusResponse>; | ||
} | ||
export {}; |
@@ -81,3 +81,3 @@ "use strict"; | ||
apiToken: apiToken, | ||
baseURL: "https://graph.facebook.com/v17.0", | ||
baseURL: "https://graph.facebook.com/v19.0", | ||
errorHandler: function (error) { var _a; return (0, errorHandler_1.WABAErrorHandler)(((_a = error === null || error === void 0 ? void 0 : error.response) === null || _a === void 0 ? void 0 : _a.data) || error); }, | ||
@@ -281,4 +281,20 @@ }); | ||
}; | ||
/* | ||
* | ||
* HEALTH ENDPOINTS (https://developers.facebook.com/docs/whatsapp/cloud-api/health-status) | ||
* | ||
*/ | ||
/** | ||
* | ||
* @param nodeId is optional, defaults to the account_id | ||
*/ | ||
WABAClient.prototype.getHealthStatus = function (nodeId) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.restClient.get("".concat(this.accountId, "?fields=health_status"))]; | ||
}); | ||
}); | ||
}; | ||
return WABAClient; | ||
}()); | ||
exports.WABAClient = WABAClient; |
{ | ||
"name": "whatsapp-business", | ||
"author": "MarcosNicolau", | ||
"version": "1.7.2", | ||
"version": "1.8.0", | ||
"description": "Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.", | ||
@@ -38,3 +38,3 @@ "license": "MIT", | ||
"dependencies": { | ||
"axios": "^1.4.0", | ||
"axios": "^1.6.7", | ||
"express": "^4.18.2", | ||
@@ -41,0 +41,0 @@ "form-data": "^4.0.0" |
Sorry, the diff of this file is not supported yet
118145
41
2195
Updatedaxios@^1.6.7