Using this API, one can send and respond to WhatsApp messages programmatically.
-
Create Developer account at meta https://developers.facebook.com/async/registration/
-
Integrate with WhatsApp. You will receive a test WhatsApp number to send info to upto 5 contacts.
-
Use temporary(24h) AccessTokens to send whats app messages using Postman or API
-
Sending messages using templates is straight forward but sending direct text messages requires a message from the user.
-
Setting up webhooks, follow the steps here- https://developers.facebook.com/docs/graph-api/webhooks/getting-started#configure-webhooks-product
- Clone the project
git clone https://github.com/NeetishRaj/WhatsAppApiDotnet.git
- Make sure the dotnet CLI and dotnet5.0 packages are installed.
- Create a file in root called
appsettings.Development.json
. Copy the contents fromappsettings.json
and fill in the details forWhatsApp
section from your developer console. - In the root folder run the following
dotnet restore
dotnet build
dotnet run
- Now test the endpoints in Postman, for API reference use Swagger endpoint
https://localhost:5001/swagger
In order to test the Webhook feature, this API needs ot be hosted somewhere so that we can have callback URL to be configured in developer's console. Following these insrtuctions https://developers.facebook.com/docs/graph-api/webhooks/getting-started#configure-webhooks-product
Note: The details are even well documented in their Postman collection page here https://www.postman.com/meta/workspace/whatsapp-business-platform/folder/13382743-08213e00-c6d0-48a2-8be8-62247b8d29bd