This repository is a demo of how to integrate the WhatsApp Business Cloud API through Facebook's Graph API. using Spring Boot.
- Uses restfb as the Facebook's Graph API client.
- Implements Embedded Signup for authentication.
- Lists associated WhatsApp Business Accounts.
- Lists associated WhatsApp Business Phone Numbers.
- Lists associated WhatsApp Message Templates.
- Spring Boot 3.4
- Java 21
- Gradle
- lombok
- A Meta Business Account.
- A Business App, associated with your Meta Business Account.
- Add the Facebook Login for Business Product to your app.
- Create a Facebook Login for Business configuration with the whatsapp_business_management, whatsapp_business_messaging permission.
- The server where you will be hosting Embedded Signup must have a valid SSL certificate (https).
Check the official documentation for more details:
- Embedded Signup Implementation
- WhatsApp Business Management API
- WhatsApp Business Platform Cloud API
- Set
up OAuth redirect URLs
to include the /callbackendpoint.
- Note your App ID, Config ID, and App Secret, check Basic Settings.
Update the configuration file src/main/resources/application.yml with your Facebook API credentials:
facebook:
  appId: your_app_id
  configId: your_config_id
  appSecret: your_app_secret
  callbackUrl: https://your-app.com/callback
  webhookToken: wp-notificationMake sure to replace the placeholder values with your actual Facebook application credentials.
- Build the Application
./gradlew build- Run the Application
./gradlew bootRunUse .\gradlew.bat instead if you are on Windows.
- Navigate to /loginto initiate the Facebook authentication flow.
- After successful authentication, you will be redirected back to the application /.
- The access token will be stored in the session.
| Method | Endpoint | Description | 
|---|---|---|
| GET | /login | Redirects the user to Facebook authentication. | 
| GET | /callback | Processes the authentication response. | 
| Method | Endpoint | Description | 
|---|---|---|
| GET | / | Lists associated WhatsApp Business accounts, phone numbers, and message templates. |