emingure / whatsapp-business-api-ts

A Wrapper for Whatsapp Business Cloud API hosted by Meta.
https://www.npmjs.com/package/whatsapp-business-api
15 stars 7 forks source link

ok message but don't send anything #2

Open juanele121976 opened 3 days ago

juanele121976 commented 3 days ago

Hello, thank you for your contribution to send WhatsApp messages, I have a problem, sending the message everything comes out ok, but WhatsApp does not receive anything

"response": { "messaging_product": "whatsapp", "contacts": [ { "input": "+56996958468", "wa_id": "56996958468" } ], "messages": [ { "id": "wamid.HBgLNTY5OTY5NTg0NjgVAgARGBI5QzVBODg1OERGMTUwRDRFAATQ" } ] }

thanks a lot

juanele121976 commented 3 days ago

/////////////////code //////////////

export const sendWhatsAppUpdateState = asyncHandler(async (req: any, res: any, next: any) => {

const phone_number_to_send = req.body.phone
const mensaje = req.body.message

console.log(mensaje,phone_number_to_send)

const wp = new WhatsappAPI({
  accountPhoneNumberId: PHONE_NUMBER_KEY || "", // required
  accessToken: WHATSAPP_TOKEN_KEY  || "", // required
})

const returned = await wp.sendTextMessage(phone_number_to_send, {message:mensaje,preview_url:false});

 res.status(200).json({
      success: true,
      response:returned,
    //  total,
  });

});

juanele121976 commented 3 days ago

image