gabrieldwight / Whatsapp-Business-Cloud-Api-Net

This is C# wrapper of whatsapp business cloud api for .NET
MIT License
284 stars 104 forks source link

how to send text messages #3

Closed AlejandroT02 closed 2 years ago

AlejandroT02 commented 2 years ago

Hello, im trying to send a text message and it throws me this exception: WhatsappBusiness.CloudApi.Exceptions.WhatsappBusinessCloudAPIException: 'Unsupported post request. Object with ID 'messages' does not exist, cannot be loaded due to missing permissions, or does not support this operation. i saw that builder.Configuration.GetSection("WhatsAppBusinessCloudApiConfiguration") is not working. i would appreciate if you can provide an example connecting whatsapp business configurations such as phonenumberid with the project

gabrieldwight commented 2 years ago

@AlejandroT02

You need to perform the following steps:

  1. You need to create your app from Meta for developers
  2. You need to add WhatsApp business product to the app you created in the portal
  3. You will get the test WhatsApp phone Number Id and WhatsApp Business Account Id assigned to your app from meta.

If you are using asp.net core 6.

You will need to add the following key and value the appsetting.json file. This will solve this issue builder.Configuration.GetSection("WhatsAppBusinessCloudApiConfiguration") it is reading the configuration from appsetting.json file

{
  "WhatsAppBusinessCloudApiConfiguration": {
    "WhatsAppBusinessPhoneNumberId": "<YOUR PHONE NUMBER ID FROM META>",
    "WhatsAppBusinessAccountId": "<YOUR BUSINESS ACCOUNT ID FROM META>",
    "WhatsAppBusinessId": "",
    "AccessToken": "<YOUR TEMPORARY OR PERMANENT ACCESS TOKEN FROM META>"
  }
}

Let me know if that solved your issue

AlejandroT02 commented 2 years ago

Thank you, but it is giving me another problem, I am entering the data correctly and it does not send me the whatsapp or give me any exception

gabrieldwight commented 2 years ago

@AlejandroT02 If you have received a test hello world message from meta when sending it to test your phone number. You are required to reply with any text since it's a template message. After you reply to the Facebook hello world template message with any text to it. You can now send any type of message to your test phone number since it is like a form verification on their end. That will solve your issue of not receiving WhatsApp messages from cloud api.

AlejandroT02 commented 2 years ago

Thanks!!!! didn't know i had to reply, you helped me a lot.