Posts tagged with whatsapp

currently I have a node js server which Listens for incoming messages and sending a response to the client based on his msg content .

  • I have a Verified Business account, Whatsapp business account + phone number set and a webhook set for my node js server

I am now trying to expand it and to Listen for 2 whatsapp numbers . meta allows to set only one webhook per "app" which I think there is my problem . after creating a new app , and associated it to the same business account which has 2 whatsapp phone numbers , I still Can't listen to the 2nd number .

This is the current code which runs :

const RecievedMessage = (req,res)=> {     try {         var entry = (req.body["entry"])[0];         var changes = (entry["changes"])[0];         var value = changes["value"];         var messageObject = value["messages"];         if (typeof messageObject != "undefined"){             var messages = messageObject[0];             var number = messages["from"];             var msgid = messages["id"];             var text = getTextUser(messages); // getting the usr message             if(text != ""){               processMessage.Process(text,number,msgid);              }         }         myConsole.log(text);         res.send("EVENT_RECEIVED")     }catch(error) {         myConsole.log(error);         res.send("EVENT_RECEIVED")     } }     

for the webhooks I set 2 different endpoints one on each app: /whatsapp /whatsapp2

the verify function :

 const VerifyToken = (req,res) => {     try {         const keyValuePairs = req._parsedOriginalUrl.query.split('&');         const parsedValues = {};                  keyValuePairs.forEach(pair => {             const [key, value] = pair.split('=');             parsedValues[key] = value;         });                       var accessToken = 'token';              var token = parsedValues['hub.verify_token'];//req._parsedOriginalUrl.query["hub.verify_token"];              var challenge = parsedValues['hub.challenge'];//req._parsedOriginalUrl.query["hub.challenge"]                       if(challenge !=null && token != null && token == accessToken) {                 res.send(challenge);              } else {                  res.status(400).send();              }                     } catch(error) {             res.status(400).send();            } }    

express routes

app.get('/whatsapp',async(req,res)=> {    try { const keyValuePairs = req._parsedOriginalUrl.query.split('&'); const parsedValues = {}; keyValuePairs.forEach(pair => {     const [key, value] = pair.split('=');     parsedValues[key] = value; }); const hubMode = parsedValues['hub.mode']; const hubChallenge = parsedValues['hub.challenge']; const hubVerifyToken = parsedValues['hub.verify_token'];      var accessToken = 'token';      var token = parsedValues['hub.verify_token'];      var challenge = parsedValues['hub.challenge'];      if(challenge !=null && token != null && token == accessToken) {         res.send(challenge);      } else {          res.status(400).send();      }    } catch(error) {     res.status(400).send();    } })     
 app.get('/whatsapp2',async(req,res)=> {    try { const keyValuePairs = req._parsedOriginalUrl.query.split('&'); const parsedValues = {}; keyValuePairs.forEach(pair => {     const [key, value] = pair.split('=');     parsedValues[key] = value; }); const hubMode = parsedValues['hub.mode']; const hubChallenge = parsedValues['hub.challenge']; const hubVerifyToken = parsedValues['hub.verify_token'];      var accessToken = 'token';      var token = parsedValues['hub.verify_token'];      var challenge = parsedValues['hub.challenge'];//req._parsedOriginalUrl.query["hub.challenge"]      if(challenge !=null && token != null && token == accessToken) {         res.send(challenge);      } else {          res.status(400).send();      }    } catch(error) {     res.status(400).send();    } })   

I am sure I'm not the first one which need a multi-phone number setup for a Whatsapp chatbot Thanks everyone , cheers

'm currently working with the WhatsApp Business API and facing an issue specifically with the "messages" webhook. For some reason, this webhook isn't being triggered, even when I test it manually from the WhatsApp Business dashboard.

Here are the details:

All other webhooks (e.g., status, message_template, etc.) are working perfectly fine. I've tried reconfiguring the webhook URL multiple times. I switched the app back to development mode to see if that would fix it, but no luck. Has anyone encountered a similar issue or have any ideas on how to resolve this?

Additional Information:

I've verified that the server is publicly accessible and can receive POST requests. There are no errors or logs indicating any incoming request for the "messages" webhook on my server. Any help or suggestions would be greatly appreciated!

I've developed a cloud service (Google cloud Run job) with a webapp that responds to messages as if the replies were from me. When triggered, it reads all my emails and writes a draft as an answer. However, I want to integrate it also with WhatsApp.

I read that I can create an endpoint with the business cloud api so that the software can receive my whatsapp messages, but I realised that I can't save messages as draft with the current API. Indeed, I want to save a response generated by my service as a draft in WhatsApp, so when I open WhatsApp, the message is already there under the intended contact.

I've discovered that the "click to chat" functionality (e.g., https://wa.me/myfriendnumber?=hi) partially achieves this.

However, when I open such a link, it launches my browser first, which then prompts me to open the WhatsApp app. I'd like to bypass this manual step, avoiding the "Open in WhatsApp" confirmation popup, so that I can open multiple links programmatically and have the messages saved as drafts in WhatsApp directly.

Is there a way to automate this, or another method to achieve the same result?

I'm in process of registering phone number to be used with Whatsapp API, when I try to generate access token for my phone number, I'm greeted with this alert.

There was a problem registering (my phone number). Unsupported post request. Object with ID '(phone_number_id)' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

There also this message that tells me the phone number needs to be registered.

When I attempt to follow the link, it brings me to this page, it has instruction to follow and "certificate".

The these instruction link lead to documentation on how to register the phone number, however the top of documentation clearly state that this instruction no longer valid as of now because it is using on premise API. So I tried to find the one valid for cloud API, I found this documentation → https://developers.facebook.com/docs/whatsapp/cloud-api/reference/registration/

The documentation offers a way to register the phone number through API, below is the snippets I copied from the documentation.

curl 'https://graph.facebook.com/v21.0/106540352242922/register ' \ -H 'Content-Type: application/json' \ -H 'Authorization: Bearer EAAJB...' \ -d ' {   "messaging_product": "whatsapp",   "pin": "212834" } 

The question is how do I get phone number ID if my phone number is not "registered" to begin with ? I tried to retrieve the phone number ID by following the link here → https://developers.facebook.com/docs/whatsapp/business-management-api/manage-phone-numbers#get-all-phone-numbers, but it only list the test phone number, my phone number does not appear.

{   "data": [     {       "verified_name": "Test Number",       "code_verification_status": "NOT_VERIFIED",       "display_phone_number": "+1 555-131-8955",       "quality_rating": "GREEN",       "platform_type": "CLOUD_API",       "throughput": {         "level": "STANDARD"       },       "id": "375420581369195"     }   ],   "paging": {     "cursors": {       "before": "xxxx",       "after": "xxxx"     }   } } 

Goal: I want to provide WhatsApp messaging feature within my android app for my customers to send messages to their customers, and without my customers intervention in terms of any accounts setup/embedded signups for them. Because my customers won't use this feature if they need to invlove in the setup process that Meta docs are suggesting as a solution or tech provider. So I want to use my own setup and WABA account so that my customers can use this feature right way.

My Setup:

  1. Meta developer account is created.

  2. Meta business manager is created.

  3. Meta app is created and linked to business portfolio.

  4. My business verification is successfully completed.

  5. WABA Account is created and my new business phone number is added and Webhooks setup also done.

  6. Access Verification is not done as I am not going to deal or create my customers WABA accounts.

  7. App Review submission is failed as I didn't provide FB Login button and now I think I understood why FB login is needed and now I don't want my customers fb login intervention as it is going to come to the concept of dealing customers WABA accounts in the end.

  8. Added Phone number is in unavailable status, its registration is failing because of on premises api expiration and struggling to do it with Cloud API endpoints like /wabaId/phone_numbers, /request_code, /verify_code etc and now I completely got stuck and confused on how to register business phone number with certificate code and without issues.

Test implementation in the app:

  1. Multiple messaging templates are created and available to use.
  2. We are able to send whatsapp messages using templates created to the mobile numbers added in the test list in development mode.

Problems/Concerns/Queries To achive my goal mentioned above:

  1. Is my goal achievable?
  2. How to register added business phone number using certificate code as per latest docs/changes?
  3. Does it require access verification to register business phone number?

Please help me with my goal and what else I need to do or am I missing anything?

Currently added business phone number is in unavailable status and need to get it to active status.

I am assuming that I don't need to go through access verification and app review process as I'm not going to deal customers individual setup/waba accounts.

I am expecting to use my business phone number id with permanent access token to make graph API /messages calls and send messages to customers of my customers. This will be triggered by my customers through my android app.