codigoencasa / bot-whatsapp

🤖 Crear Chatbot WhatsApp en minutos. Únete a este proyecto OpenSource (Typescript Version Pronto)
https://bot-whatsapp.netlify.app
MIT License
2.18k stars 766 forks source link

[Issue] With Mexican and Arg Numbers +52 #1004

Open aldoximple opened 4 months ago

aldoximple commented 4 months ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @bot-whatsapp/provider@0.1.38 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.

rodrimarchese commented 2 months ago

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

github-actions[bot] commented 3 days ago

¿Alguna novedad sobre esta ISSUE?