Generate Permanent Access Token For WhatsApp

on

|

views

and

comments

It’s time to get back to the part that we left out in the previous blog. In the previous blog, we have completed “Basic Setup for Salesforce + WhatsApp Integration”, now it’s time to move on the next important thing that is “Generating Permanent Access Token for Facebook”.

Setting Up Base For Generating Permanent Access Token (PAT)

If you have already logged in to your Facebook Account, you will be redirected to the below shown page else do following the previous blog for checking out signup options. Next click on “My Apps”

Here, you will find the App that you have created by following the previous blog. It will appear as shown below :-

Click on your demo App (“Salesforce+WP” in my case) that you have created. Once done, you will be redirected to the App detail page. From the sidebar, click on the “WhatsApp” Section. Within this “WhatsApp” section, click on “Getting Started” option. Here, you will be able to find all the details that you have setup from the previous blog. In the “Getting Started” section, you will find the “Temporary Access Token”. The major drawback of this “Temporary Access Token” is that it will get expired within 23 hours. To avoid this tedious task, it’s better to Generate Permanent Access Token”.

Initializing “Permanent Access Token” Generation

To begin the process of “Permanent Access Token” generation, Click on “Configuration” option under WhatsApp section. In the “Configuration” section, you will see an option called Permanent Token. Click on “Learn how to create permanent token” link which will redirect you to documentation page of Facebook Developer.

Scroll down to the “Required Assets” section on the documentation page of Facebook Developer.

Please make sure that you have completed the steps mentioned in the “Required Assets” section. If you have followed all the steps of our blogs, you should have completed some of the above-mentioned steps like creating a meta–Developer Account, creating Business App and adding it to your Business Manager Account. Now, the next step we need to perform is to generate an access token. For this, click on the first link under the “An access token” section as highlighted in the image below: –

This link will land you on to new page which will show all the points that are needed to “Generate Permanent Access Token”.  Scroll down to “Steps to add new system user” section. Click on the first step i.e “Go to Business Settings”

Creating System User

Clicking on the above link will take you to the setting page of the Business Account that you have already created. From Sidebar, select “System users” under “Users” section. Click on “Add” button. A pop up will appear stating “Non-discrimination policy”. Leave all the options as it is and click on “I accept” button. After that another pop up will appear asking you to “Create System User”.

Here, you need to enter “System Username” and select “Admin” as System User Role. Once this step is completed, again pop up will appear stating “Non-discrimination policy”. Leave all the options as it is and click on “I accept” button. Now, you need to add this “Admin” user to the WhatsApp Account.

Adding newly created “System User” to the WhastApp Account

For this, scroll down to “Accounts” section from the sidebar. Here, you will find an option named “WhatsApp Account”. Click on “WhatsApp Account” option to add newly created “System User”.

Click on “Add People” button. Now, it will show all the users that you have created. From the list, you need to select recently created “System User”. After that, assign “Partial Access” and “Full Control” to the selected user and click on “Assign”. This marks the completion of adding “System User” Process.

Adding newly created “System User” to the Demo App

Also, we need to add “System User” to the demo app that we have created (Salesforce+WP in my case). To achieve this milestone, scroll down to “Accounts” section from the sidebar. Here, you will find an option named “Apps”. Click on “Apps” option to add newly created “System User”. Click on “Add People” button. Now, it will show all the users that you have created. From the list, you need to select recently created “System User”. After that, assign “Partial Access” to develop the app and “Full Control” to the selected user and click on “Assign”. This marks the completion of adding “System User” Process.

Generating “Permanent Access Token”

From the Sidebar, scroll up to “Users” section. Click on “System Users” option under “Users” section, select recently created “System User” and then click on “Generate New Token”.

Once you click on “Generate New Token”, a pop up will appear asking you to select your Demo app. Select your demo app (“Salesforce+WP” in my case) and assign two important permissions for this Demo App.

  1. Whatsapp_business_messaging
  2. Whatsapp_business_management

After this, click on “Generate Token” button which will appear at the bottom of this popup.

After this, Permanent Access Token will get generated. For safer side, it will be better to copy and paste the Token on your Notepad as it won’t be stored at Facebook.

Using “Postman” to send messages to WhatsApp

First thing first. Now get back to your application that you have created by following the steps from previous blog. If you are still confused follow these steps quickly.

Go to https://developers.facebook.com/ à Click on “My Appsà Select the demo app that you have created (“Salesforce+WP” in my case).

Now, scroll down to “WhatsApp” section from sidebar. Select “Getting Started” option under WhatsApp section. In the “Send and Receive Messages” section, select your WhatsApp number in the “To” section. After this, come down to “Step 2: Send messages with the API” section, copy the newly generated command and paste it on your notepad (for safety & backup purpose).

Since, we are going to send messages to WhatsApp through Postman, it’s highly advised to download & install Postman through this link. Once you have installed Postman, go ahead and open the “Postman” App and click on “Import” button (at the top left). Here you will find multiple tabs under the Import button. Select the “raw text” tab and paste the command URL that you have copied from the previous step. Once done, click on “Continue” button and then on “Import” button. So, this will generate a request for you.

I’ll breakdown this URL, to make understanding clearer.

Now, the basic need of using “Postman” is to send message. So below this URL, you will find an option named “Body”. Go to that option, then click on “Beautify”. This will show you that message that will be sent. Next, click on “Headers” option. Under “Headers”, you will find two keys

  1. Authorization: – This contains the Temporary Access Token (which will expire within 23 hours). Here you need to replace it with Permanent Access Token. For that, remove everything from the “Authorization” and then type “Bearer”, give a space and paste the Permanent Access Token that you have saved in your Notepad.
  2. Content – Type

 

Now, go ahead and click on “Send” Button next to the URL. This will send message to the mentioned WhatsApp number, and you can also see the confirmation message in the body section of the Postman as shown below: –

Finally, we have completed the “Permanent Access Token Step” and it’s time to move ahead to the next step!! But we know that “Too many cooks spoil the broth”, so its time to take a pause and wait for the next step in the upcoming blog 😊.  For more updates, do not forget to Subscribe our Youtube Channel. Till next time, take care and be well 😊.

Aman Tiwari
Aman Tiwarihttps://pantherschools.com/
Lifetime Learner, philanthropist & hardworker, who believes in converting dreams into reality😇 3X Salesforce Certified Developer & Admin|| 1.5X Trailhead Ranger|| Blogger, Speaker, and Instructor.
Share this

Leave a review

Excellent

SUBSCRIBE-US

Book a 1:1 Call

Must-read

How to Utilize Salesforce CLI sf (v2)

The Salesforce CLI is not just a tool; it’s the cornerstone of development on the Salesforce Platform. It’s your go-to for building, testing, deploying, and more. As one of the most important development tools in our ecosystem

Save the day of a Developer with Apex Log Analyzer

Table of Contents What is Apex Log Analyzer? Apex Log Analyzer, a tool designed with Salesforce developers in mind, is here to simplify and accelerate your...

Salesforce PodCast

Introduction Hey Everyone, Welcome to my podcast, the first-ever podcast in India for Salesforce professionals. Achievement We are happy to announce that we have been selected as Top...

Recent articles

More like this

LEAVE A REPLY

Please enter your comment!
Please enter your name here

It’s time to get back to the part that we left out in the previous blog. In the previous blog, we have completed “Basic Setup for Salesforce + WhatsApp Integration”, now it’s time to move on the next important thing that is “Generating Permanent...Generate Permanent Access Token For WhatsApp
5/5

Stuck in coding limbo?

Our courses unlock your tech potential