builderbot icon indicating copy to clipboard operation
builderbot copied to clipboard

[Issue] With Mexican and Arg Numbers +52

Open aldoximple opened this issue 1 year ago • 2 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @bot-whatsapp/[email protected] for the project I'm working on.

When I was using Mexican phone number with meta provider a '1' character to the body.to property. So this cause an invalid number.

Here is the diff that solved my problem:

diff --git a/node_modules/@bot-whatsapp/provider/lib/meta/index.cjs b/node_modules/@bot-whatsapp/provider/lib/meta/index.cjs
index 5bbdeb3..e8d8b86 100644
--- a/node_modules/@bot-whatsapp/provider/lib/meta/index.cjs
+++ b/node_modules/@bot-whatsapp/provider/lib/meta/index.cjs
@@ -579,6 +579,13 @@ class MetaProvider extends ProviderClass {
      * @return {Object} The response data from the API.
      */
     async sendMessageToApi(body) {
+        if (body.to.slice(0, 2) == '52') {
+            if (body.to.length > 12) {
+                let lada = body.to.slice(0, 2)
+                let number = body.to.slice(3, 14)
+                body.to = lada+number
+            }
+        }
         try {
             const response = await axios.post(`${URL$1}/${this.version}/${this.numberId}/messages`, body, {
                 headers: {

This issue body was partially generated by patch-package.

aldoximple avatar Feb 26 '24 22:02 aldoximple

Pueden usar versión 1.1.4-alpha.0 soluciona el problema para números méxicanos y argentinos Fixed en https://github.com/codigoencasa/bot-whatsapp/pull/1044

rodrimarchese avatar Apr 19 '24 15:04 rodrimarchese

¿Alguna novedad sobre esta ISSUE?

github-actions[bot] avatar Jun 29 '24 23:06 github-actions[bot]