Connectors / Service / Facebook

The largest social network in the world. (updated: 1620808632190)

Facebook

Connect to Facebook and utilize marketing tools they provide.

Overview

The Facebook connector allows you to view adverts, list generated leads from ads as well as create and update custom audiences.

Authentication

PLEASE NOTE: The Authentication process mentioned below can be used for Facebook connectorand Facebook Trigger Version 2.0. For the authentication process of Facebook Trigger version 1.0 ,refer to the Trigger Authentication section below.

Within the workflow builder, highlight the Facebook connector.

In the Facebook connector properties panel to the right of the builder, click on the Authenticate tab and the 'New authentication' button.

facebook-add-new-auth

This will result in a Tray.io authentication pop-up modal. The first page will ask you to name your authentication and select the type of authentication you wish to create ('Personal' or 'Organisational').

The next page asks you for your 'Client ID' and 'Client secret' credentials.

facebook-popup

To get these credentials, you need to be registered as a Facebook developer and add Tray as an application in the Facebook developer portal.

To start the registration process while logged into your Facebook account, go to the Facebook for Developers website and click Get Started.

facebook-dev-acc-registration

Click 'Next' to agree to Facebook's Platform Terms and Developer Policies.

Enter your phone number and verify your account using text message or phone call.

facebook-enter-phn-no

Select an occupation that most closely describes what you do for a living.

facebook-select-occupation

Now that you are registered, you can use the App Dashboard to create your first app.

To create the app, go to the Apps panel and click 'Create App'.

facebook-create-app

From the pop-up choose an app type that suits your application.

facebook-select-app-type

Enter the name of your app and an email address where you wish to receive important developer notifications. The email address can be different from the email address associated with your Facebook account. Once done click 'Create App'.

facebook-app-name-1

Re-enter your Facebook password to continue.

facebook-reenter-facebook-pw

The next step is to add your app. Click the 'Set Up' button from the product with the name 'Facebook Login'.

facebook-add-app

You will be redirected to the 'Quickstart' page. From the left panel, click on the 'Facebook Login' link to expand the sub-menu. Click 'Settings' from the sub-menu.

The next step is to enter Tray.io's OAuth 2 settings URI. You can find this URI on Tray.io's platform by navigating to Services > Add service > OAuth 2 settings.

facebook-oauth2-ui-1

Add this URI https://auth.tray.io/oauth2/token in the 'Valid OAuth redirect URIs' field and click 'Save changes'.

facebook-add-tray-url-1

Now you have successfully added Tray.io as an application. To get the Client Id and Secret for this newly created app, click Settings > Basic from the left panel.

On this page, you can get your credentials.

facebook-appid-secret

Copy and paste these credentials to your Tray.io authentication pop-up window.

You can optionally select the service permissions of your choice and then click the 'Create authentication' button.

facebook-service-permissions

You will then be redirected to a Facebook login page. Login with your Facebook account credentials and continue.

facebook-auth-login

Facebook will then ask you to grant permissions for the scopes selected in the previous screen. Press the 'Continue as Connector' button to grant the permissions.

facebook-continue-as-connector

The authentication has been successfully created and the Facebook connector can now be used.

Select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Refreshing authentication

It's important to note that due to Facebook's authentication system, tray.io has to ask users who have created an authentication on the platform to re-authenticate regularly. tray.io will send an email to the owner of the authentication warning that the authentication will expire soon. To re-authenticate, a link will be provided that will take you to the authentication page.

facebook-email

Click on the URL and it will take you to this page:

back-to-facebook

From here, follow the same steps that were discussed in the Authenticating with Facebook section.

It is important to note that if re-authentication does not occur, the connector will fail after the authentication expires and workflows will be affected by this.

Facebook Trigger

Version 1.0

Within the workflow builder, highlight the Facebook trigger.

In the trigger properties panel to the right of the builder, click on the Authenticate tab and the 'New authentication' button. This will result in a Tray.io authentication pop-up modal.

facebook-trigger-auth-add-new

Name the authentication. When choosing between the type of authentication you wish to create ('Personal' or 'Organisational'), consider who and how many people will need access to it.

As you can see, the next page asks you to select which scopes you would like to enable for your created authentication.

facebook-trigger-auth-popup

Once you have selected the desired scopes in the Tray.io authentication popup window, click on the 'Create authentication' button. Upon clicking 'Create authentication', you will be prompted to sign in to your Facebook account.

facebook-trigger-auth-facebook-login

After you have logged in with your Facebook account, go back to your settings authentication field (within the workflow builder properties panel), and select the recently added authentication from the dropdown options now available.

Your connector authentication setup should now be complete.

Version 2.0

The Authentication process for Facebook Trigger version 2.0 is the same as the Facebook connector Facebook Connector Authentication.

Facebook leads ad trigger

The Facebook leads ad trigger allows a user to receive a notification whenever a lead has been generated on a page. The trigger uses it's own authentication and has a different process than that of the connector. To create authentication for Facebook trigger, refer to the Trigger Authentication section above.

Below is a guide on how to use this trigger:

  1. Select the Facebook leads ad trigger from the selection when creating a workflow.

select-facebook
  1. Authenticate the trigger and select the operation as 'Subscribe to Lead Gen Ads'.

operation
  1. Select a Facebook page of your choice from the available drop-down options, for which you wish to fire this trigger.

select-page
  1. Once the page has been selected, 'Enable' the trigger

enable-workflow

Notifications sent by Facebook contain only the ID of the lead that was created. To get all associated data about the new Lead, you can use a core connector in the nest step with operation set to Get Lead. This operation retrieves all information about a Lead from a given ID.

Notes on using Facebook

Facebook permissions

It is important to note that some operations within the connector are dependant on certain permissions that the signed-in Facebook user has. For example, to use the List leads from ad operation, you will need to be page admin to access the lead data of an ad (https://www.facebook.com/business/help/766393076839635). If operations are not returning data you're expecting, check using the Facebook documentation that permissions are set up correctly.

Available Operations

The examples below show one or two of the available connector operations in use.

Please see the Full Operations Reference at the end of this page for details on all available operations for this connector.

Example usage

List leads from ad

This example will walk through how to list leads from a given ad. The first step is to add the Facebook connector to the workflow.

To list leads from an ad, the id of the ad we want to query needs to be provided. To find this ID, the operation list ads in ad account can be used. This will return data about all ads that belong to an ad account.

To use this operation, select the List ads in ad account operation in the input panel.

select-list-ads

An ad account then needs to be selected, this dictates what ads are listed.

select-ad-account

The ID of the advertisement can the be collected from the result set manually, or JSONPaths can be used to get the data straight from the operation. Below the connector snake is used to retrieve the JSONPath:

snake-case

The input for the List leads from ad operation now looks like the following:

list-leads-input

The workflow is ready to be ran. Below you can see that the workflow ran successfully and leads have been listed from a given ad.

example-output

Creating a custom audience

This example will walk through how to create a custom audience. The first step is to add the Facebook connector to the workflow.

The Create custom audience operation then needs to be selected.

add-facebook

The first steps that will be taken will be to provide some information about the custom audience. This includes the ad account that this audience will belong to, a name for the audience, a useful description about the audience and the customer file source.

meta-data

The next step is to provide a population for this custom audience. This is done by adding audience member objects to the array of audience members.

Below you can see an example of an audience member object.

add-attributes

It is important to understand that if you did not want to include the same fields in every audience member object, you have to provide an empty string in the field you wish to leave out. An example below shows how in the next audience member, the Birth year attribute wants to be left out. Using the tooltip, an empty string can be set. This will prevent any errors from occurring when the workflow is run.

select-empty
empty-string

Now the custom audience has been defined, and the workflow is ready to be run. As can be seen in the image below, the workflow ran successfully and a custom audience has been created in Facebook.

successful-custom

All Operations

Latest version:

9.1

Create custom audience

Create a custom audience in your business account.

Create post

Create a new post.

Delete audience members

Remove members from a given audience.

Delete custom audience

Delete a custom audience.

Get ad

Retrieve an ad using its ID.

Get ad account

Retrieve an ad account using its ID.

Get ad account insights

Retrieve insights from a specific ad account.

Get ad insights

Retrieve insights for a specific ad.

Get adset

Retrieve an adset using its ID.

Get adset insights

Retrieve insights for a specific adset.

Get audience

Retrieve a custom audience.

Get business user

Retrieve a business user detail using ID.

Get campaign

Retrieve a campaign using its ID.

Get campaign insights

Retrieve insights for a specific campaign.

Get lead

Get data about a specific lead using their ID.

Get page insights

Get insights for a specific page.

Get post insights

Get insights for a specifc post.

Get user

Get data about the user signed in.

List ad accounts

List ad accounts associated with current user.

List ad accounts DDL

List ads in ad account

List ads in a given ad account.

List adsets in ad account

List adsets in a given ad account.

List business client ad accounts

List all client-owned ad accounts.

List business users

List all business users associated with this business.

List campaigns in ad account

List ad campaigns found in an ad account.

List custom audience ad accounts DDL

List custom audiences

List custom audience found in an ad account.

List forms in page

List leadgen forms owned by a page.

List leads from ad

List leads from a given ad.

List leads from form

List leads from a given form.

List pages managed

List the pages managed by the current user.

List pending users

List all users invited to access this business, who have not yet accepted their invitation.

List posts on page

Retrieve a list of posts associated with a specific page.

List saved audiences

List all saved audiences.

Raw HTTP request (advanced)

Perform a raw HTTP request with some pre-configuration and processing by the connector, such as authentication.

Targeting search

Retrieve target audiences for your ads that match your search query.

Update custom audience

Update a custom audience with a new population.

Update post

Update a post.