Posts under category Facebook WhatsApp Business API

I am trying to create a template from postman by sending this object:

{     "name": "listado_productos",     "language": "es",     "category": "TRANSACTIONAL",     "components": [         {             "type" : "HEADER",             "format": "document",             "example": {                 "header_handle": [                     "https://drive.google.com/file/d/1CcTpDZL3p0ltMFhIKU9Vhz1LWG0bQFpN/view?usp=share_link"                 ]}         },         {             "type": "BODY",             "text": "Buenas tardes, acá le enviamos el nuevo listado de precios. Muchas gracias"         },         {             "type": "FOOTER",             "text": "ABS."         }     ] } 

If I try an example from the official business-management-api guide, it also rejects it for non-compliance with terms and conditions.

"name": "promotional_message",   "language": "en_US",   "category": "TRANSACTIONAL",   "components": [{            "type":"BODY",            "text":"Hi {{1}}, get an extra 10% off every order above $300.",            "example":{"body_text":[["Sonia"]]}          },          {            "type":"HEADER",            "format":"TEXT",            "text": "Bonus Tuesday starts now!"          },          {            "type":"FOOTER",            "text":"Not interested? Tap Stop promotions"          },          {            "type":"BUTTONS",            "buttons":[{"type":"QUICK_REPLY", "text": "Shop now"},             {"type":"QUICK_REPLY", "text": "Stop promotions"}]          }]   

The response is that it is rejected for being duplicate or not complying with WhatsApp Busiess Api terms and services but it is not true, I read the terms and conditions and the file / message format complies. Does anyone identify the problem?

I have a problem with my nodejs code and the connection to the official whatsapp business api.

The bot connects the webhook correctly, the messages arrive to the server correctly but the code I have implemented to make it respond is not being effective, I checked the code from top to bottom but I can't find the fault.

I leave you the codes so you have more context:

whatsappController.js:

const fs = require("fs"); const myConsole = new console.Console(fs.createWriteStream("./logs.txt")); const whatsappService = require("../services/whatsappService") const VerifyToken = (req, res) => {     try {         var accessToken = "456E7GR****************************";         var token = req.query["hub.verify_token"];         var challenge = req.query["hub.challenge"];         if(challenge != null && token != null && token == accessToken){             res.send(challenge);         }         else{             res.status(400).send();         }     } catch(e) {         res.status(400).send();     } } const ReceivedMessage = (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 text = GetTextUser(messages);             var number = messages["from"];             myConsole.log("Message: " + text + " from: " + number);             whatsappService.SendMessageWhatsApp("The user say: " + text, number);                          myConsole.log(messages);             myConsole.log(messageObject);         }         res.send("EVENT_RECEIVED");     }catch(e) {         myConsole.log(e);         res.send("EVENT_RECEIVED");     } } function GetTextUser(messages){     var text = "";     var typeMessage = messages["type"];     if(typeMessage == "text"){         text = (messages["text"])["body"];     }     else if(typeMessage == "interactive"){         var interactiveObject = messages["interactive"];         var typeInteractive = interactiveObject["type"];         if(typeInteractive == "button_reply"){             text = (interactiveObject["button_reply"])["title"];         }         else if(typeInteractive == "list_reply"){             text = (interactiveObject["list_reply"])["title"];         }else{             myConsole.log("sin mensaje");         }     }else{         myConsole.log("sin mensaje");     }     return text; } module.exports = {     VerifyToken,     ReceivedMessage } 

The second file is whatsappService which I make the connection with the api using the token and I also send the format of the message I want to send when I receive a hello for example...

const https = require("https"); function SendMessageWhatsApp(textResponse, number){     const data = JSON.stringify({         "messaging_product": "whatsapp",             "recipient_type": "individual",         "to": number,         "type": "text",         "text": {             "preview_url": false,             "body": textResponse         }     });     const options = {         host:"graph.facebook.com",         path:"/v15.0/1119744*************/messages",         method:"POST",         body:data,         headers: {             "Content-Type":"application/json",             Authorization:"Bearer EAAWNbICfuWEBAK5ObPbD******************************************************"         }     };     const req = https.request(options, res => {         res.on("data", d=> {             process.stdout.write(d);         });     });     req.on("error", error => {         console.error(error);     });     req.write(data);     req.end(); } module.exports = {     SendMessageWhatsApp }; 

Then I declare the routes for the get (to check token) and post (to receive and reply to messages) methods:

const expres = require("express"); const router = expres.Router(); const whatsappController = require("../controllers/whatsappControllers"); router .get("/", whatsappController.VerifyToken) .post("/", whatsappController.ReceivedMessage) module.exports = router; 

Last but not least the index file for the code to run correctly:

const express = require("express"); const apiRoute = require("./routes/routes"); const app = express(); const PORT = process.env.PORT || 3000 app.use(express.json()); app.use("/whatsapp", apiRoute); app.listen(PORT, () => (console.log("El puerto es: " + PORT))); 

I should clarify that I did the tests with Postman and they were all successful, it responds and receives messages correctly, finally I did the tests by uploading the bot to the Azure service and it works without problem until it has to answer/replicate the user's message.

The bot is not responding to the user when he talks to it but everything arrives correctly to the server and it processes it with a 200 response. I attach the evidence that there is no problem in the reception.

Finally I must say that in the meta platform I have everything configured as specified by the same platform, I have already configured the api to answer the messages through the webhooks and everything is correct, I just can't get the bot to answer correctly.

The bot is hosted in the Azure service.

I would like to send a WhatsApp message from my project. So I use twilio WhatsApp API and I use my own phone number as the sender and link whatsApp Business Account with my Twilio Account. To use my own whatsapp number as business number, I delete my account from whatsapp messenger and use it as business number since error is shown as the image.Please see this link to see image Error image. Everything including sending message from project is ok, but one thing is I can't login to my own number using whatsapp messenger or whatsapp business app. When I try to login to whatsapp messenger or business app, the error show "WhatsApp is temporarily unavailable. Please try again in 1 hour".

My question is

  • I think I need to login to whatsapp business app only since my phone no is registered as business account. is my assumption true?
  • which step do I need to follow to login to whatsapp?

Please help me. Thanks all in advance.

For reference, I follow along the instructions just like the below link. text

If I can't login, how can I manually reply to my customers?

We are building a chatbot for WhatsApp using the OpenAI API, which is intended to be able to answer any question asked to it. However, we are experiencing some issues when trying to integrate the OpenAI API with the WhatsApp Business API. Here is the code we are using for this integration:

import os import requests from flask import Flask, request import openai from Testbotgpt import generate_response app = Flask(__name__) def send_message(to, text):     data = {         "recipient_type": "individual",     "to": "whatsapp:{}".format(to),     "type": "text",     "text": {       "body": text     }     }     headers = {         'Content-Type': 'application/json',         'Authorization': 'Bearer <Access Token>'     }     api_url = 'https://api.whatsapp.com/v1/messages'     response = requests.post(api_url, json=data, headers=headers)     if response.status_code != 200:                raise ValueError('Error sending message: {}'.format(response.text)) @app.route('/bot', methods=['POST']) def bot():     incoming_msg = request.values.get('Body', '').lower()     from_number = request.values.get('From', '')     responded = False      # Check if the message contains a greeting     if 'hi' in incoming_msg:         send_message(from_number, "Hello! How can I help you today?")         responded = True     elif 'bye' in incoming_msg:         send_message(from_number, "Goodbye! Have a great day.")         responded = True        # Use the GPT model to generate a response based on the user's input     else:         response = generate_response(incoming_msg)         send_message(from_number, response)         responded = True           return 'OK' if __name__ == '__main__':   app.run() 

Could you please help us understand what we are doing wrong and suggest a solution to fix the issue?

Is it possible to use the WhatsApp business API to communicate with users and also allow them to forward content from WhatsApp directly to our application. For example enabling Web-hooks for different WhatsApp channels to receive the messages from those channels. If yes, can someone guide me how can we implement this feature? and how can we authorize those channels with our WA business account

Finding sources/documentation for developing needed feature