Posts under category Facebook WhatsApp Business API

I am trying to run a google app script with Whatsapp business API to send messages to my customers directly from google sheets. The below app runs fine but every time I run it, it sends the message again and again to all customers irrespective of the same msg being sent to the same customer earlier.

Is there a way, I can add a column and update it automatically to record if the message has been sent to this customer in which case skip to the next (just like in mail merge scripts).

I have the below code and a screenshot of the image here

`
const WHATSAPP_ACCESS_TOKEN = "**My whatsapp token**"; const WHATSAPP_TEMPLATE_NAME = "**My template name**"; const LANGUAGE_CODE = "en"; const sendMessage_ = ({   recipient_number,   customer_name,   item_name,   delivery_date, }) => {   const apiUrl = "**My api url**";       const request = UrlFetchApp.fetch(apiUrl, {     muteHttpExceptions: true,     method: "POST",     headers: {       Authorization: `Bearer ${WHATSAPP_ACCESS_TOKEN}`,       "Content-Type": "application/json",     },     payload: JSON.stringify({       messaging_product: "whatsapp",       type: "template",       to: recipient_number,       template: {         name: WHATSAPP_TEMPLATE_NAME,         language: { code: LANGUAGE_CODE },         components: [           {             type: "body",             parameters: [               {                 type: "text",                 text: customer_name,               },               {                 type: "text",                 text: item_name,               },               {                 type: "text",                 text: delivery_date,               },             ],           },         ],       },     }),   });   const { error } = JSON.parse(request);   const status = error ? `Error: ${JSON.stringify(error)}` : `Message sent to ${recipient_number}`;   Logger.log(status); }; const getSheetData_ = () => {   const [header, ...rows] = SpreadsheetApp.getActiveSheet().getDataRange().getDisplayValues();   const data = [];    rows.forEach((row) => {     const recipient = { };     header.forEach((title, column) => {       recipient[title] = row[column];     });     data.push(recipient);   });    return data; }; const main = () => {   const data = getSheetData_();   data.forEach((recipient) => {       const status = sendMessage_({         recipient_number: recipient["Phone Number"].replace(/[^\d]/g, ""),         customer_name: recipient["Customer Name"],         item_name: recipient["Item Name"],         delivery_date: recipient["Delivery Date"],       });   }); };

I am building an application using the WhatsApp Business Cloud API. Essentially I want to know if it's possible to build an application that collects all the messages from the day and downloads it. Specifically the media attached to it using the API. As far as I know you can use webhooks to get incoming messages. But in order to do this the application has to be run forever, and my cousin has a problem with this as it could cause problems to run an application forever vs just run it once a day. I'm able to send messages using the API and a python wrapper but that's much more simple than what I'm trying to do. Aditionally, there is an option of using selenium but that's not really an automated solution to what we're trying to do because everytime selenium executes the browser we'd need to log in using the QR code. If anyone has any idea if this is possible (or not possible) I'd be very appreciative!

from heyoo import WhatsApp import logging import requests from dotenv import load_dotenv from flask import Flask, request, make_response app = Flask(__name__) token = 'EAAVk5rqOCsABAAcPPrZC6GnlZAJuykdFIQd4DhkuRVNeGntfFOU5jaK4jG2yCZBS6i7kFQGk3kRvDP0fExBXRsFyqWUqfVVJsSxeQdcA9XHWpRuUsnnuwqLcZAQpwTiuoZCXv4ixCcHYlPEe6NGHupCalHvWw9NQRoZAVnegU5ZCBvX6eO9E8vyum1lQ2SSt7OuUpdpIkmkyBK8tiEL8rpGwM8RrqZA3A10ZD' messenger = WhatsApp(token,  phone_number_id='100398242927044') messenger.send_message('Hey its JJ ', '1xxxxxxxx') logging.basicConfig(     level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) print("hello") @app.route("/", methods=["GET", "POST"]) def hook(): 

//some code that isn't working yet

I'm new to all of this stuff so I don't really know how to set up a webhook either but my cousin who's business I'm building this app for doesn't ideally want to use a webhook.

We are using an integration with whatsapp business API and it is working great, but we need to check if we have a new message or if the user have replied, we try it to use the whatsapp business app, but we can't access to the app and it seems like that whatsapp doesn't allow to use the App and API with the same number, then is there any way to check the messages like an app or dashboard?

I have been investigating in internet but I cannot find any solutions for that

When doing an api call, I'm getting the response 400 with reason

"Unsupported post request. Object with ID '###############' does not exist, cannot be loaded due to missing permissions, or does not support this operation".

Though the permissions for whatsapp_business_messaging and whatsapp_business_management was given and token was generated for an admin user.

Is it that permanent tokens does not work on apps with apps in development mode? Because the temporary token was working with the same code and messages were being sent correctly.

I'm trying this for Odoo 16 in python 3.8 `

recipient_phone_number = rec.owner_id.partner_id.mobile url = f"https://graph.facebook.com/v15.0/{phone_number_id}/messages" headers = {     "Authorization": f"Bearer {access_token}",     'Content-Type': 'application/json' } # Code for sending text message in whatsapp. text_data = {     'messaging_product': 'whatsapp',     "recipient_type": "individual",     'to': recipient_phone_number,     'type': 'text',     "text": {         "preview_url": False,         "body": "Dear %s, this message is to remind that document %s will expire on %s."                 % (rec.owner_id.name, rec.name, rec.expiry_date)     } } text_response = requests.post(     url,     headers=headers,     data=json.dumps(text_data) ) 

`