gallery-image

we are here

3938 Somerset Circle Rochester Hills MI 48309

What is Facebook Business API:

WhatsApp for Business is part of the Facebook Business API ecosystem. To integrate WhatsApp with MuleSoft, you’ll first need to create a WhatsApp Business Account and set up the necessary configurations on the Facebook Business Manager platform.

Create a Facebook Business Account:

Create a Facebook Business Account If you don’t have one already, create a Facebook Business Account on developers.facebook.com. This will be used to access the WhatsApp Business API.

Step 1: Open your web browser and navigate to developers.facebook.com Click on login

Step 2: Log in to Facebook.

Step 3: click on the ‘My Apps’ option in the top navigation menu.

Step 4: On the ‘My Apps’ page, you will find a button or option to create a new app. Click on it.

create a new app page

Step 5: In the process of creating a new app, you will be asked to select an ‘App Type.’ Choose Business’ as the app type and Click on ‘Next’

Choose Business

Step 6: Select an app type and Click on ‘Next’

Step 7: Follow the prompts to provide the necessary information about your business and the app you are creating. This information may include your business name, website, email address, and other relevant details. Click on ‘Create app’

Create app type

Step 8: Add products to your app select Whatsapp and Click on ‘setup’

Add products

Step 9: Click on Continue

Step10: After clicking Continue, Scroll down the page click on WhatsApp and Click on API Setup

API Setup

Step 11: Next, Scroll down the page and Click  Add a phone number

Step 12: Now Create a WhatsApp Business profile (This profile will show information about your business to people on WhatsApp) fill in the details and Click on Next

Create a WhatsApp Business profile

Step 13: Next page Add a phone number for WhatsApp, Enter your number Click On Next

Add a phone number

Step 14: Now your phone Number has been added to your Whatsapp business account and get the temporary access token This token will expire in 23 hours you can use it to send and receive messages through the WhatsApp Business API.

Access token,

Create Keystore :

Follow these steps to generate a keystore and export a self-signed certificate

Step 1: open a command prompt windows +r, Enter the CMD, and click OK

Open command prompt

Step 2: Open a command prompt in the same directory as Java keytool; alternatively, you may specify the full path of keytool in your command. Pay close attention to the alias you specify in this command as it will be needed later on (Ex: keytool -genkey -alias dwinsoft -keyalg RSA -keystore KeyStore.jks -keysize 2048)

CMD Keystore

Step 3: Enter a password for the keystore with at least 6 characters

Enter a password

Step 4: Respond to prompts to enter other values. Enter your desired values. The following output shows example responses

Enter your desired values

Step 5: Confirm or reject the details by typing “Yes” or “No” and press Enter

Step 6: Press Enter to use the same password as the keystore, alternatively specify a separate password and press enter

Now KeyStore.jks created successfully.

Create a New Mule Project

Open Anypoint Studio. Click on “File” > “New” > “Mule Project.” Enter a project name and click “Finish.”

Configuring the TLS Certificate

Step 1: Open the global element to Click Create.

Step 2: Next, search the TLS Context, Select  TLS Click Ok

TLS Context

Step 3: Next! scroll down page Key Store Configuration

Step 4: Select the type JKS, Enter the Path name.jks, and enter the password and Click ok .

Global TLS config

Step 5: The KeyStore.jks is placed in the src/main/resources.

KeyStore

Your endpoint must be able to process two types of HTTPS requests Configure webhooks to receive messages and Send Messages.

Configure webhooks to receive messages( GET Method)

GET method receives messages from WhatsApp and responds correctly with the challenge value when needed for webhook verification.

HTTP Listener:

Drag and drop an “HTTP Listener”, Double-click on the “HTTP Listener” component to configure its properties. Set the “Path” field to the endpoint path ( “/webhook”).  HTTP Listener Config, the port is specified as 8082, and the protocol is selected as HTTPS

Listener Config

Next step Select the TLS Change the Global reference and config the TLS_context NextClick OK

Select the TLS

Next, in the ‘Advanced’ section of the HTTP Listener Configuration, select ‘GET’ as the allowed method.

select GET

Transform Message

Drag and drop the “Transform Message” component. Double-click on the “Transform Message” component to open and set up the transformation script to process the incoming request. The script is written in DataWeave 2.0 and performs the following tasks Copy to past the Transform Message

( %dw 2.0

output text/plain

var mode = attributes.queryParams.” hub.mode”

var token = attributes.queryParams.” hub.verify_token”

var challenge = attributes.queryParams.” hub.challenge”

var verify_token = “Dwinsoft”

if ((!(mode==”) and !(token==”)) and

  ((mode == “subscribe”) and (token == verify_token)) )

   challenge as String

   else 404)

Transform Message – Dataweave

Send Message (POST Method):

POST flow to handle event notifications, which will contain user messages or other relevant data from WhatsApp. If you need assistance with those steps or have more questions, please let me know.

HTTP Listener:

Drag and drop an “HTTP Listener”, Double-click on the “HTTP Listener” component to configure its properties. Set the “Path” field to the endpoint path ( “/webhook”).  HTTP Listener Config, the port is specified as 8082, and the protocol is selected as HTTPS

Listener Config

Next step Select the TLS Change the Global reference and config the TLS_context Next Click ok.

Select the TLS

Next, in the ‘Advanced’ section of the HTTP Listener Configuration, select ‘POST’ as the allowed method.

Transform Message

Drag and drop the “Transform Message” component. Double-click on the “Transform Message” component to open and set up the transformation script to process. The script is written in DataWeave 2.0 and performs the following tasks

Transform Message

Next Open the Developer Account – Dashboard  App  developers.facebook.com copy the command in the window and Temporary access token

Temporary access token

HTTP Request Configuration:

Step 1: Drag and drop the “HTTP Request” component. Double-click on the “HTTP Request” component to open Click to Edit, Open The Configuration element scroll down the connection. Now enter the host and protocol paste Command and Temporary access token

HTTP Request Configuration

Step 2: Open Settings, in the default headers, select Edit inline from the drop-down option

No alt text provided for this image
default headers

Step 3: Next configure the temporary token and Click on Finish .

No alt text provided for this image
configure the temporary token

Step 4: Next give the POST method and Enter the Path

No alt text provided for this image
HTTP Request Configuration

Completed the configuration successfuly

No alt text provided for this image
Send Flow

Run Your Project

  1. In Anypoint Studio, right-click on the project (the main area of your Mule Flow) where you’ve designed your integration.
  2. From the context menu, select “Run Project” to deploy and run your Mule application.

Deploy an Application to Runtime Manager:

Step 1: Sign in to Anypoint Platform.

Step 2: Select Runtime Manager.

Step 3: On the Applications page, click Deploy application. You see the Deploy Application page. the Choose file menu, and the Deploy Application button on the Deploy Application page.

Step 4: Enter the application name, select the application jar file, select CloudHub, and Click on Deploy Application

Runtime Manager SANDBOX

Step 5: After successfully deploying the Application you get the App URL Copy that URL

Affter successfully deploy Runtime Manager

Configure webhooks to receive messages

Open the Developer Account – Dashboard  App  developers.facebook.com

Step 1: Click Step 3 Configure webhooks to receive messages. Configure webhooks.

Configure webhooks to receive messages

Step 2: After opening the Configure webhooks to receive messages open the webhook config page. Edit the Callback URL and Verify token

Webhook config

Step 3: In the Edit page paste the URL obtained from Runtime Manager and give the Verify token as specified in the transform message. Click verify and save.

Callback URL verify token

Step 5: click on Webhook fields manage. Subscribe to all Fields and click on Done

Webhook fields Manage

Whatsapp Send messages and receive messages

Now Open the Whatsapp message Click on Chatbox Send the message from registered mobile number

Whatsapp Send message and receive messages

Runtime Manager log page:

You can see the Whatsapp incoming messages in the Runtime Manager log

Runtime Manager log

Write a comment

Your email address will not be published. Required fields are marked *

Enter Name*
Enter Email*
Enter Website*
Enter Your Comment*

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare