Set up the Ads hub apps
For the person who runs this Watification server. Get Meta, TikTok and Snapchat to approve the Ads hub, set the redirect URLs, the lead callbacks and the environment variables, and turn on the Meta cutover.
This page is for the owner or operator of a Watification server. It is not needed by workspace members. A workspace connects its ad accounts from Ads in the dashboard once the apps below are set up for the server.
The Ads hub only reads from the ad platforms. It never creates, edits, pauses or deletes an ad. It reads results (spend, views, clicks), follows the leads that come from ads, and, when a member switches it on, tells the platform what happened to a lead ("this person became a customer").
The code works before any approval. Until a platform approves your app, the matching feature shows "Not approved yet" and nothing else breaks.
Meta and TikTok review the apps. Meta's review needs a short screen recording for each permission, and Meta's access tier for ads needs real traffic first. Plan for the wait before you promise leads or events to customers.
This page covers Meta, TikTok and Snapchat. Meta and TikTok are the first release; Snapchat is the second. LinkedIn Ads and Google Ads come later and need their own apps.
Before you start
- Meta: the Meta app you already use for WhatsApp, Messenger and Meta Ads, and the Facebook Login for Business configuration that Meta Ads (Settings > Integrations > Meta Ads) already uses. Its id is
META_LOGIN_CONFIG_ID. The Ads hub reuses it. There is no second Meta login. Your business must pass Business Verification (needed for Advanced Access). - TikTok: a TikTok for Business developer app for ads. It is separate from the Business Messaging app of the TikTok channel. Never reuse that app's secret here.
- Snapchat: an OAuth app in Snap Business Manager. You must be an Organization Admin to create it. It is separate from any other Snap app.
- A public
httpsaddress for the dashboard and one for the webhook service. - A decision on who gets Ads. By default Free workspaces get no ads features. See "Which plans get Ads" below.
Meta
Ask Meta to approve the permissions
In the Meta App Dashboard, open App Review and request Advanced Access for each of these, with a use case and a screen recording each:
| Permission | What Watification does with it |
|---|---|
ads_read | Reads ad accounts and results. |
business_management | Reads the business's own ad accounts and Pages. |
leads_retrieval | Reads lead forms and the leads people send. |
pages_manage_ads | Needed together with leads_retrieval to read lead data. |
pages_show_list | Lists the Pages a person can use. |
pages_read_engagement | Meta lists it as required with the lead webhook. |
pages_manage_metadata | Subscribes a Page to new leads, and removes the subscription. |
ads_management | Meta lists it for lead retrieval and the lead webhook. Watification asks for it so leads and events work. It does not create or change any ad. |
Meta will ask the data handling questions, and you must pass the yearly Data Use Checkup. Meta Ads under Integrations already uses ads_read and business_management, so check what your app already holds before you apply.
Watification never asks for a campaign write permission.
Raise the Marketing API access level
Meta's Limited access is for development only. To upgrade the app to Full access, it must have made at least 500 Marketing API calls in the last 15 days with an error rate under 15%. Plan for this before real customers connect.
Add the permissions to the login configuration
After App Review passes, open the Facebook Login for Business configuration that META_LOGIN_CONFIG_ID points to and add the new permissions to it. Keep it a system-user token configuration. A user-token configuration fails the code exchange.
Existing Meta Ads customers have to connect once more so their login holds the new permissions. Until they do, their account keeps showing results but leads, events and audiences stay off for them. The dashboard does not yet say so in words: the "Sign in again" message for a moved Meta connection is not built.
Add the leadgen field to the Page webhook
In the App Dashboard, open Webhooks, choose the Page object and subscribe to the field leadgen. Meta only delivers a field that is subscribed on both the app and the Page. Watification subscribes each customer's Page itself. You do the app side once.
The webhook URL is the Meta URL you already use. Lead notices come in through it. You do not add a new URL for Meta.
Set the environment variables
See the table under "Environment variables" below. For Meta you need ADS_ENABLED and the existing META_LOGIN_CONFIG_ID. ADS_META_CUTOVER is the step in the next section.
Who can connect a Page for leads
The person who connects a Page must hold the Advertise task on it, and one of Manage, Create content or Moderate. Watification only offers Pages that pass this check. A Page with fewer tasks does not appear in the picker.
The Meta cutover
Before this step, Meta Ads (Settings > Integrations) keeps working exactly as it does today. The cutover moves each workspace's Meta connection into the hub in one step, so results are never counted twice. It is your switch: ADS_META_CUTOVER.
Check before you flip (it is safe to wait):
- Meta App Review has passed and the login configuration lists the new permissions.
- The release that includes the cutover migration is deployed. That release changes the database, so run it in a maintenance window.
ADS_ENABLED=true. The credential keys exist on the api and the worker.META_LOGIN_CONFIG_IDis set. The api and the worker refuse to start withADS_META_CUTOVER=trueand noMETA_LOGIN_CONFIG_ID.- For every workspace that has a Meta Ads connection, turn on its entitlements
ads.enabledandads.meta.enabled(through its package or an override), and setads.max_ad_accountsto at least the number of accounts it ticked. Workspaces without these are not moved. They stay on the old Meta Ads page until they have them.
Flip: set ADS_META_CUTOVER=true for the api and the worker, then restart both completely. A watch restart does not reload new variables. The scheduler is not touched.
Check a few minutes later:
- The worker log shows
ads.meta-cutover-import.completedwithimportedequal to the number of entitled workspaces andfailedat 0. The metricads_meta_cutover_imports_total{result}agrees.skippedcounts workspaces without entitlements, or with a token Meta refused. - In the database,
select count(*) from integrations.meta_ad_connections where status = 'active' and handed_over_at is nullequals the skipped workspaces, andselect count(*) from ads.connections where platform = 'meta'equals the imported ones. ads_sync_runs_total{platform="meta",result="synced"}rises as the moved accounts do their first 90 day read. The scheduler log shows nointegrations.meta-ads-syncpull for a moved workspace.- In the dashboard of a moved workspace, Reports > Ads shows the same campaign names and a spend close to the day before the flip. Leads, events and audiences stay off for that workspace until the member signs in again.
Roll back:
- To stop new moves and read the old way again, set
ADS_META_CUTOVER=falsefor the api and the worker and restart both. Reports read the old tables again, and new Meta connects use the old path. The migration stays. - The hub keeps the connections it already moved and keeps reading them.
- There is no automatic way to move one workspace back, because the old token was revoked once the new one was confirmed. To return one workspace: the member connects again under Settings > Integrations > Meta Ads, and an operator turns
ads.meta.enabledoff for that workspace. That avoids reading it twice.
TikTok
Create the developer app
In the TikTok for Business developer portal, create an app for ads (not the Business Messaging app). Write down the App ID and the Secret.
Choose the permissions
On the app, use Update app permissions and add these, with a reason that matches them:
| Permission | Id | What it is for |
|---|---|---|
| Read Ad Account Information | 100 | Lists the advertiser accounts, with currency and time zone |
| Read Campaigns, Read Ad Groups, Read Ads | 200, 210, 220 | Names and status of what the results belong to |
| Reporting | 4 | Spend, views, clicks |
| Lead Management, or Leads Retrieval together with Test Leads | 12000000, or 12010100 and 12020100 | Reads instant-form leads, and the download that catches missed ones |
| Report Conversion Event (under Measurement) | 7224195155857866754 (parent 5) | Lets Watification tell TikTok what happened to a lead |
Do not request any permission that creates or changes ads. TikTok's own permission list is what keeps the hub read-only on that side. The authorization URL does not take a list of permissions, so ADS_TIKTOK_SCOPES is not used. The app's permissions are the list.
The connecting person must be an ad account admin. Only an admin can run the lead download, which is the safety net for missed leads. Without it the live webhook still works.
Set the redirect URL
Copy the advertiser authorization URL from the app's page in the developer portal. Add this as the redirect URL, replacing <dashboard> with your dashboard's address:
https://<dashboard>/app/ads/tiktok/callbackSet the same address as ADS_TIKTOK_REDIRECT_URI. If you need to change the authorization host, set ADS_TIKTOK_OAUTH_BASE_URL. By default Watification uses https://business-api.tiktok.com/portal/auth. Check it against the URL in your app on the first live connect.
Set the leads callback
TikTok sends new leads to a URL on the webhook-ingress service. Give Watification the public address of that route:
https://<webhook-host>/webhooks/ads/tiktok-leadsSet it as ADS_TIKTOK_LEADS_CALLBACK_URL on the api. Watification gives it to TikTok itself when a member turns a lead form on. You do not type it into the TikTok portal. Without it, turning on a TikTok lead source answers "not approved".
The ingress checks every request's X-Open-Signature with the app's secret. Set the same ADS_TIKTOK_CLIENT_SECRET on the webhook-ingress service. The route only exists when that secret is set. Use the ads app's secret, never TIKTOK_APP_SECRET, which belongs to the Business Messaging app.
Ask for a higher rate limit if you need it
The basic level is 10 calls a second, 600 a minute and 864,000 a day for the whole app, shared by every workspace. If that is too small, apply for a higher level in the portal. TikTok does not state how long approval takes.
Snapchat
Create the OAuth app
In Snap Business Manager (business.snapchat.com), open Business Details, then OAuth Apps, and create an app. You need the Organization Admin role. Write down the Client ID and the Client Secret. The secret is shown once.
Set the redirect URL
Add this as the redirect URL of the app, replacing <dashboard> with your dashboard's address:
https://<dashboard>/app/ads/snapchat/callbackYou do not have to set ADS_SNAPCHAT_REDIRECT_URI. When it is unset, Watification builds this same address from DASHBOARD_ORIGIN. Set it only if the address Snapchat has must differ. The address in the app and the one Watification sends must match exactly.
Scopes
Watification asks for two scopes, and you do not choose them anywhere:
| Scope | What it is for |
|---|---|
snapchat-marketing-api | Lists the ad accounts, reads campaigns, ad squads, ads and results, reads lead forms and sets up the lead webhook |
snapchat-offline-conversions-api | Lets Watification tell Snapchat what happened to a lead (Conversions API) |
Snapchat has one scope for the whole Marketing API, and it can change ads. Watification's code only reads results and manages its own lead webhooks; it never creates, edits or pauses an ad. That is enforced in the code, not by the scope.
The connecting person must be a member of the ad account. To turn a lead form on, the person must also be an Organization Admin, because Snapchat only lets an Organization Admin create the lead webhook. Without it the member sees "not allowed" for that form and nothing else is affected.
Lead webhooks
Nothing to type into Snapchat. When a member turns a lead form on, Watification creates the webhook for that form itself, at an address built from WEBHOOK_BASE_URL:
https://<webhook-host>/webhooks/ads/snapchat-leads/<token>The <token> is a random value made for that one form and kept only as a hash. Snapchat signs every lead with a secret that belongs to the ad account, and Watification checks that signature before it reads the lead. The webhook-ingress service needs only ADS_SNAPCHAT_CLIENT_ID to open the route: it holds no Snapchat secret.
Snapchat keeps the answers of a lead for 30 days. A second job reads Snapchat's own lead report every 12 hours and recovers a lead the webhook missed, but it can never reach back further than 30 days. If a connection needs a new sign-in, do it within a few days so no lead is lost.
Conversions
To send "this person became a customer" back to Snapchat, a member picks one of the ad account's Snap Pixels as the place that receives it. Create the pixel in Ads Manager first. Watification lists the pixels; it does not create one. Lead is sent as SIGN_UP, Qualified as CUSTOM_EVENT_1, and Won as PURCHASE when the deal has an amount, otherwise CUSTOM_EVENT_2. In Ads Manager, build the conversions you want to optimise on from those names.
Environment variables
Set these on the server. ADS_ENABLED and the app variables are read by the api and the worker. The full list, with defaults, is in the server's .env.example file under the "ADR-156 Ads hub" heading.
| Variable | Set on | What it is |
|---|---|---|
ADS_ENABLED | api, worker | true turns the hub on. Off by default. |
META_LOGIN_CONFIG_ID | api, worker | The one Meta login configuration (ADR-162). The hub reuses it. There are no Meta app variables of the hub's own. |
ADS_META_CUTOVER | api, worker | true runs the Meta cutover above. Needs META_LOGIN_CONFIG_ID. |
ADS_TIKTOK_CLIENT_ID | api, worker | The TikTok ads app's App ID. |
ADS_TIKTOK_CLIENT_SECRET | api, worker, webhook-ingress | The TikTok ads app's Secret. Never shown in logs. The ingress uses it to check lead notices. |
ADS_TIKTOK_REDIRECT_URI | api | The redirect URL from the redirect step. |
ADS_TIKTOK_LEADS_CALLBACK_URL | api | The public address of /webhooks/ads/tiktok-leads. |
RABBITMQ_ADS_TIKTOK_ROUTING_KEY | webhook-ingress | Optional. Defaults to tiktok-ads. The worker listens on tiktok-ads, so change it only if you also change the worker. |
ADS_SNAPCHAT_CLIENT_ID | api, worker, webhook-ingress | The Snapchat OAuth app's Client ID. The ingress only uses it to open the lead route. |
ADS_SNAPCHAT_CLIENT_SECRET | api, worker | The Snapchat OAuth app's Client Secret. Never shown in logs. |
ADS_SNAPCHAT_REDIRECT_URI | api | Optional. Defaults to DASHBOARD_ORIGIN plus /app/ads/snapchat/callback. |
RABBITMQ_ADS_SNAPCHAT_ROUTING_KEY | webhook-ingress | Optional. Defaults to snapchat-ads. The worker listens on snapchat-ads, so change it only if you also change the worker. |
ADS_LEAD_BODY_MAX_BYTES | webhook-ingress | Optional. Largest lead webhook body the ingress accepts. Default 65536. |
ADS_OPT_OUT_REGION_CODES | api, worker | Optional. Calling codes where a marketing opt-out also stops lead events. Default is the EEA and the UK. none turns it off. |
ADS_COUNSEL_SIGNOFF | api, worker | Optional. false by default. Set it to true only after counsel has signed off audience upload and Google sends. |
Set the three TikTok app variables as a group. The api refuses to start when only some of them are set, and the worker needs the App ID and Secret together. The same goes for Snapchat: the Client ID and Secret together on the worker, and on the api the Client ID, the Secret and a redirect address (which is derived for you from DASHBOARD_ORIGIN). Optional settings also exist for how often jobs run, batch sizes and per-workspace call budgets (ADS_INSIGHTS_SYNC_INTERVAL_MS, ADS_SYNC_BATCH, ADS_EVENT_DELIVERY_INTERVAL_MS, ADS_EVENT_BATCH_<PLATFORM>, ADS_<PLATFORM>_BUCKET_CAPACITY). Leave them alone unless you have a reason.
Which plans get Ads
These are the defaults, pending owner confirmation. They are set through package entitlements, so you can change them without a release.
| Plan | What it gets |
|---|---|
| Free | No Ads features. |
| Pro | The hub (results), leads, and events sent back to the platform. |
| Top plan, or an add-on | Audiences and AI tips (they are not built yet). |
The entitlements are ads.enabled, one per platform (ads.meta.enabled, ads.tiktok.enabled, ads.snapchat.enabled) and ads.max_ad_accounts. An operator grants them by package or by an override for one workspace.
Counsel and privacy
Before you turn the Ads hub on for real workspaces, get counsel to confirm:
- The privacy policy, the data processing agreement and the list of subprocessors name advertising data and the ad platforms.
- Whether phone numbers that came from WhatsApp may be sent to platforms other than Meta under the WhatsApp Business Messaging Policy. This is not settled in the offline docs.
- That customers in the EEA and the UK are handled the way you want. By default, a contact who opted out of marketing is not sent as a lead event when their phone starts with an EEA or UK code, or when they have no phone. Change
ADS_OPT_OUT_REGION_CODESonly on counsel's advice.
ADS_COUNSEL_SIGNOFF stays false until counsel has signed off audience upload and Google sends. Neither is part of this first release.
Restart and check
Restart the api, the worker and the webhook-ingress service. In the dashboard, open Ads. Connect a test Meta ad account, a test TikTok advertiser and a test Snapchat ad account. When the accounts appear, switch one on and see its results after the first read. Then turn a lead page on and send a test lead.
Things nobody has seen running yet
The Ads hub was built and tested against stand-in Meta and TikTok servers. These need a live check on your real apps:
- Meta: that the Page token taken from the system-user login is accepted for the
leadgensubscription and for reading leads. If Meta refuses it, a second login by a person who holds the Advertise task is needed. That login is not designed yet and needs your decision. - Meta: that turning on a lead page does not remove Messenger's own subscription fields on the same Page.
- TikTok: a real lead notice with a real app secret, including a lead whose answers use non-English letters, and a notice that holds more than one lead.
- TikTok: the permission that the lead subscription call needs, and the exact authorization address.
- Both: the event upload fields, and that Meta keeps the deal amount on an event.
- Snapchat: the first sign-in (the scopes Snapchat really grants, and that a refresh token comes back and whether it changes on use), and that the 3600 second token is renewed without a new sign-in.
- Snapchat: a real lead webhook: the exact format of the
theader, that the signature matches, and whether Snapchat sends the lead again when the answer is not a success. - Snapchat: the lead report (how its days line up with the ad account's days, and that it lists the creatives of the form), and that a person who is not an Organization Admin gets the "not allowed" answer for a form.
- Snapchat: that Snapchat accepts the sign-in token on the Conversions API address, and which of its two age limits for old events it enforces.
If something is wrong
- "Not approved yet" on a platform: the app does not hold the permission yet, or the member's login was made before it was added. Check App Review, then ask the member to sign in again from Ads.
- The api does not start: some of the three TikTok app variables are set and others are missing, or
ADS_META_CUTOVER=trueis set withoutMETA_LOGIN_CONFIG_ID. Fix the variables. - TikTok leads do not arrive: check that
ADS_TIKTOK_LEADS_CALLBACK_URLis a publichttpsaddress, that the webhook-ingress service has the sameADS_TIKTOK_CLIENT_SECRET, and that the worker is running. The download runs every six hours and catches missed leads for pages with recent leads. - Meta leads do not arrive: check that the
leadgenfield is subscribed on the Page object of the app, and that the member who connected the Page holds the Advertise task. - Snapchat leads do not arrive: check that
WEBHOOK_BASE_URLis a publichttpsaddress, that the webhook-ingress service hasADS_SNAPCHAT_CLIENT_ID, that the worker is running and that the person who turned the form on was an Organization Admin. A lead that failed the signature check is dropped and counted (ads_lead_ingest_stopped_total, resultsignature_invalid); the 12-hourly report recovers it for days with no webhook lead at all. - A TikTok connection says to sign in again: the token was refused. The member signs in again from Ads.
Reply to Facebook and Instagram comments
See comments on your Facebook Page and Instagram posts in the inbox, reply in public or send a private message, hide or delete a comment, and set up a workflow that answers new comments.
Campaigns
Send a WhatsApp message template to a selected audience and follow delivery and replies.