---
title: Facebook Webhook
slug: facebook-webhook
description: Add Facebook Webhook functionality for your user facing integrations
docTags: 
createdAt: 2023-01-10T06:14:01.000Z
---

Through Pathfix Automation, you can enable user webhook listening for all your user that have connected their Facebook accounts via Pathfix OAuth.&#x20;

This will allow you to listen for any changes in your customers Facebook account and notify you with the data for the user. This includes user data, pages data for any business page they may have connected, applications, Facebook ads and much more

The following documentation will guide you on how you can setup your Facebook account and setup the Webhook listening for all your connected users.



### Setup in Pathfix OAuth

Before proceeding, make sure you have setup your Facebook integration in [Pathfix OAuth](https://app.pathfix.com/) and have added the Connect button for your users to be able to connect their Facebook accounts.

- Configure your Facebook integration in Pathfix OAuth
- Add the script tag in your application to allow your users to authenticate their Facebook accounts (Detailed documentation for Pathfix OAuth setup can be [found here](https://docs.pathfix.com/))





::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/aSnbRUW_OXVrEXr5AIbxE_image.png" size="96" width="1747" height="405" position="center" showCaption="false"}



### Setup in Pathfix Automation

- Create a blank automation by clicking on **Design&#x20;**&#x61;nd selecting **New Design**
- Give your first task a name to save the automation (autosave)



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/Gn2rgytjyC8Xa4znkpiKG_image.png" size="92" width="1890" height="1124" position="center" showCaption="false"}



- Click on the **Test and Publish&#x20;**&#x74;ab and click on **Test&#x20;**&#x74;o run a test on the automation



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/-t1Iil4V8IYNkmVBroQfh_image.png" size="92" width="1890" height="695" position="center" showCaption="false"}



- On successful completion, click on **Publish to Live**



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/h7AVAVr244PZ_iLtqbeWo_image.png" size="92" width="1888" height="784" position="center" showCaption="false"}



- Click on **Endpoints&#x20;**&#x61;nd copy the endpoint url for use in the Webhook setup
- Live Endpoint is for Live environments and Dev endpoint is for testing/development



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/TaEYtPz74LYpEDphlRqf1_image.png" size="48" width="725" height="922" position="center" showCaption="false"}



- Click on **Webhooks&#x20;**&#x66;rom the top navigation and click on **Create New**
- Select Facebook from the list of provider webhooks&#x20;
- Paste the endpoint URL copied from the automation into the **Callback URL** section
- Add values in the **Verify Token** field (this can be random numbers, but copy this for verifying it in the Facebok developer app
- Add the fields you would like to subscribe to in the **Subscribed Fields** (note: this needs to match with the fields data you want to listen for)



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/uXR857fWYwTQtazDX5sfP_image.png" size="76" width="1400" height="1098" position="center" showCaption="false"}





- Click on the **Pathfix OAuth tab** and enter your Pathfix OAuth [Public Key and Private Key](https://docs.pathfix.com/pathfix-keys)**
- Click on the field of **Webhook URI** to generate a webhook url. Copy the value for use in your Facebook developer app
- Click **Save&#x20;**&#x74;o save the setting



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/XNfn-ytChdLkVQ7ULD0s2_image.png" size="74" width="1406" height="1094" position="center" showCaption="false"}



- On the Webhooks page, click on **Activate&#x20;**&#x61;gainst Facebook to activate your webhook



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/5T2NdxhVbTVfD_VR5COOY_image.png" size="72" width="1400" height="1083" position="center" showCaption="false"}



- The webhook activation will take a few seconds and will happen in the background (click on **Refresh&#x20;**&#x6F;n the top navigation to refresh the page)
- Once activated, the webhook status will turn **Green**

****

::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/OE4Fp8YTlcGPwZdKPBpgz_image.png" size="76" width="1402" height="1093" position="center" showCaption="false"}



Your webhook has been setup in Pathfix Automation

### Setup in Facebook Developer

- Log in to your Facebook developer console and select the app
- From the left navigation, under **Products**, click on **Add product**
- From the list, search for **Webhook&#x20;**&#x61;nd click on **Setup&#x20;**&#x74;o activate the product
- From the dropdown, select the Object you want to activate the webhook for



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/zK8jCpRtoW7MJXjyK3cj1_image.png" size="94" width="1565" height="605" position="center" showCaption="false"}

- Click on **Subscribe to this object** button
- On the popup window, paste the Webhook URI in the callback URL section and the token entered during the webhook setup



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/WbTI4Xd3o5zhm9zI8LJdm_image.png" size="92" width="1402" height="513" position="center" showCaption="false"}



- Once the verification is run successfully, you will see a list of webhooks you can subscribe to
- Click **Subscribe&#x20;**&#x61;gainst the items you want to listen to



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/8EmjiuM8h1WSCuWB90vcJ_image.png" size="82" width="1519" height="1130" position="center" showCaption="false"}





### Testing Your Webhook Setup

We recommend running a test on your webhook setup to make sure the setup is right. To do this:

- Go to your Pathfix OAuth account and click on Test Connection under the Facebook integration setup
- Click on Connect/Re-Connect and connect a Facebook account



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/S6qwy7MsDPnudNbqHifJh_image.png" size="52" width="896" height="844" position="center" showCaption="false"}



- On successful connection, the Automation will start listening for changes in the connected Facebook account for the connected user
- You will see the webhook user count increase (if it doesn't increase at first, click on **Refresh&#x20;**&#x6F;n the top navigation)
- This indicates that the webhook listening is now live



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/eQvgfDvLHocp3kLfwTDy6_image.png" size="78" width="1414" height="1106" position="center" showCaption="false"}



- Go to your Facebook account that was connected and create a test entry (depending on what event you selected to listen for)
- Go to your Pathfix Automation account, click on **Monitor&#x20;**&#x61;nd select the Automation from the list
- You should see the test event created would have triggered a webhook response&#x20;



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/UJeL-nQ9g3bWZzchYPlrC_image.png" size="88" width="1811" height="1244" position="center" showCaption="false"}

Your Test is successful.



### Configure Your Automation

Now that your webhook has been setup successfully, you will need to copy the payload sent by Facebook and captured by Pathfix Automation to create your Automation.

Here are the few initial steps to get you going:

- Copy the **Request&#x20;**&#x72;eceived from our test event&#x20;



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/z8eluSpWmVo5lcQ6jPkEo_image.png" size="84" width="1811" height="1244" position="center" showCaption="false"}



- Go to the Automation created and paste the **Request&#x20;**&#x69;nto the **Call data (JSON)&#x20;**&#x73;ection of the FIRST task



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/HSNvPN0KSpG677QUo20kP_image.png" size="92" width="2243" height="1286" position="center" showCaption="false"}



- From here, you can call an API, run a condition or process the data as you please through the Automation



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/hq9HCHBZI0WX5HIhuYBMQ_image.png" size="88" width="1652" height="1110" position="center" showCaption="false"}



- You can also pick specific data fields received from the webhook data received and push it to your anywhere for processing



::Image[]{src="https://api.archbee.com/api/optimize/4iTydmxMeM2cxR5sP_SIi/QUt9_QuqdulAUu2QtvyxH_image.png" size="86" width="1533" height="1166" position="center" showCaption="false"}



- Once you are done with your automation build, click on **Test and Publish**
- On successfully testing your automation, click on **Publish to live** in order to make sure your automation is live





**Important**

- Any changes made to the automation will need to be done in the **Dev&#x20;**&#x65;nvironment
- Once changes are made, you will first have to Test the Automation and on successful completion then **Publish to Live&#x20;**
- Please note, without publishing to Live, the changes will not go into effect



Few points to note on the JSON:

1. The pathfix\_user\_id received is the same user\_id that is sent via the Pathfix OAuth system. This generally is the Current Users Unique Id&#x20;
2. the `data` section of the JSON is the **exact&#x20;**&#x64;ata that is sent by the provider





Need help? Reach out to our support via support\@pathfix.com or live chat through your Pathfix dashboard

