Skip to content

Instantly share code, notes, and snippets.

@leilaylp
Last active August 8, 2023 13:21
Show Gist options
  • Save leilaylp/8df3bd83c2de16b3060b640618102174 to your computer and use it in GitHub Desktop.
Save leilaylp/8df3bd83c2de16b3060b640618102174 to your computer and use it in GitHub Desktop.
Subscribe Facebook Webhooks with Leads Ads Form

How to subscribe Facebook Webhooks with Leads Ads Form

I made this tutorial because I think facebook docs is a bit confusing. I didn't find good stuff about connecting Leads ads forms with a webhook. But don't worry, this is what you need:

First:

  • Create a new Facebook App
  • Have any Facebook Page and leads ads forms created.
  • Create a webhook. If you can't understand the Facebook docs, here's what you need:
    • Any Verify Token, like 'string123'.
    • A https callback url which will return the token verification. When you press 'Verify and Save', fb will check if the url is correct and the verification is ok. If ok, your App will be subscribed to one webhook.

Since you want to connect that webhook with the leads ads form, you have to subcribe it with your page. This will be done with the following steps:

Step 1: Go to the Graph API Explorer

Step 2: Select the application created before in the 'Application' select box.

Step 3: Generate a Page Access Token selecting the page where you have the leads ads forms. Check you are generating this with the App and no the Graph API Explorer.

Step 4: Run this: POST /{page-id}/subscribed_apps

And that's all :)

@zorn
Copy link

zorn commented Mar 12, 2021

Step 4 seems incomplete. The docs for that endpoint suggest a payload like subscribed_fields=leadgen.

https://developers.facebook.com/docs/graph-api/reference/v7.0/page/subscribed_apps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment