Posts tagged with facebook-graph-api

I develop a page with login for Whatsapp API Cloud following those steps:

https://developers.facebook.com/docs/whatsapp/embedded-signup/pre-filled-data

<script>   window.fbAsyncInit = function () {     FB.init({       appId: "XXXXXXX",       cookie:   true, // enable cookies       autoLogAppEvents: true,       xfbml: true,       version: "v15.0",     });   };   // Load the JavaScript SDK asynchronously   (function (d, s, id) {     var js,       fjs = d.getElementsByTagName(s)[0];     if (d.getElementById(id)) return;     js = d.createElement(s);     js.id = id;     js.src = "https://connect.facebook.net/en_US/sdk.js";     fjs.parentNode.insertBefore(js, fjs);   })(document, "script", "facebook-jssdk");   // Facebook Login with JavaScript SDK   function launchWhatsAppSignup() {     // Launch Facebook login     FB.login(       function (response) {         if (response.authResponse) {           const accessToken = response.authResponse.accessToken;           console.log(accessToken);           //Use this token to call the debug_token API and get the shared WABA's ID           fetch(             `https://graph.facebook.com/v15.0/debug_token?input_token=${accessToken}&access_token=EAARzkHctTewBABQoSZA3gDI36fFBO1ZCW1DV4uW3eUMZClzbZBB8wvmpFNhrShuZA2ej4oZAxxXD0md0vZAkr4NQ6ZBzOzNsK9QMjz0bz3xEzSKQ0BDQU9qD2DoZA3XwGDGyAyAssqgEkGM9iUSmj6CspwPUWwIVuByJdOxtKV4dSNG1Fm44hTWgQ`           )             .then((response) => response.json())             .then((data) => console.log(data));         } else {           console.log("User cancelled login or did not fully authorize.");         }       },       {         scope: "business_management,whatsapp_business_management",         extras: {           feature: "whatsapp_embedded_signup",           setup: {             // ... // Prefilled data can go here           },         },       }     );   } </script> <script async  crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js"></script> <button   onclick="launchWhatsAppSignup()"   style="     background-color: #1877f2;     border: 0;     border-radius: 4px;     color: #fff;     cursor: pointer;     font-family: Helvetica, Arial, sans-serif;     font-size: 16px;     font-weight: bold;     height: 40px;     padding: 0 24px;   " >   Login with Facebook </button> 

But the problem is whatsapp shows in pop-up: You don't have any WhatsApp Business Accounts.

and tell me to create an WhatsApp Business Accounts, that i already have in my bussiness account linked with my whatsapp bussiness number.

I am trying to create a workflow where based on user queries we send some products from the Facebook business catalog to WhatsApp as a single product and list product card as mentioned in the below link: https://developers.facebook.com/docs/whatsapp/guides/commerce-guides/share-products-with-customers

I have created a permanent access token using the system user and I am able to access the catalog and also the products inside the catalog with the access token.

Also using the same token I am able to send normal text and images on whatsapp. Now the issue is when I am trying to send specifically a product as an interactive card, I am getting the below mentioned issue.

{   "error": {     "message": "(#131009) Parameter value is not valid",     "type": "OAuthException",     "code": 131009,     "error_data": {       "messaging_product": "whatsapp",       "details": "Invalid catalog_id."     },     "error_subcode": 2494010,     "fbtrace_id": "AgVHaK1LySusku-_NFpkCNR"   } } 

But the catalog exists and I am also able to access products inside this catalog.

Fetching all the catalogs

Fetching products inside a catalog

Sending Messages as an interactive card for the catalog

I'm trying to send a POST request to edit a template message of WhatsApp:

POST /{whatsapp_template_id}    {   "name": "my_template",   "language": "en_US",   "category": "transactional",   "components": [     {       "type": "BODY",       "text": "whatsapp buddy?"     }   ] } 

Receiving (#3) Application does not have the capability to make this API call.

I am planning to use whatsapp cloud API but I see each country has different rate cards: https://developers.facebook.com/docs/whatsapp/pricing/ If I have application in which registered user can be in USA or UK or India etc and can send messages to users belonging to different countries in that case how to handle pricing implementation on backend?

Is it ok if I calculate the cost based on analytics endpoint: https://developers.facebook.com/docs/whatsapp/business-management-api/analytics this endpoint includes cost as well for each registered phone number. In that case I can easily calculate monthly cost occurring with start and end date in query params. Is there any other solution or can this be improved?