MarcosNicolau / whatsapp-business-sdk

Node.js connector for the WhatsApp Business APIs with TypeScript support, integration tests and more.
MIT License
81 stars 21 forks source link

Types error for buttons #7

Closed GautierT closed 1 year ago

GautierT commented 1 year ago

Hi! πŸ‘‹

Firstly, thanks for your work on this project! πŸ™‚

Today I used patch-package to patch whatsapp-business@1.5.0 for the project I'm working on.

The typescript for the buttons contain a small mistake.

As you can see here : https://developers.facebook.com/docs/whatsapp/cloud-api/reference/messages Buttons should be like this :

"action": {
      "buttons": [
        {
          "type": "reply",
          "reply": {
            "id": "UNIQUE_BUTTON_ID_1",
            "title": "BUTTON_TITLE_1"
          }
        },
        {
          "type": "reply",
          "reply": {
            "id": "UNIQUE_BUTTON_ID_2",
            "title": "BUTTON_TITLE_2"
          }
        }
      ]
    }

Here is the diff that solved my problem:

diff --git a/node_modules/whatsapp-business/dist/src/types/messages.d.ts b/node_modules/whatsapp-business/dist/src/types/messages.d.ts
index 204e722..71fb984 100644
--- a/node_modules/whatsapp-business/dist/src/types/messages.d.ts
+++ b/node_modules/whatsapp-business/dist/src/types/messages.d.ts
@@ -169,16 +169,19 @@ export declare type InteractiveMessageAction = {
     /**
      * Button content. It cannot be an empty string and must be unique within the message. Emojis are supported, markdown is not.
      */
-    button: string;
+    button?: string;
     /**
      * Required for Reply Buttons.
      */
-    buttons: {
+    
+    buttons?: {
         type: "reply";
-        title: string;
-        id: string;
+        reply: {
+            title: string;
+            id: string;
+        }
     }[];
-    sections: InteractiveActionSection[];
+    sections?: InteractiveActionSection[];
 };
 export declare type InteractiveMessageBody = {
     text: string;

This issue body was partially generated by patch-package.

MarcosNicolau commented 1 year ago

Hi @GautierT :wave:!

First of all, thank you for opening this issue and contributing to the project, I am really glad you found it useful :grinning:.

I've just read the documentation and what you commented and you are 100% right :+1:.

I'll commit and push the changes ASAP :bug: or, if you want, you can create a pull request and I'll accept it.

github-actions[bot] commented 1 year ago

:tada: This issue has been resolved in version 1.5.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: