Backend service for Custom GPTs to search Facebook's Marketing API for ad targeting interests. Includes token management and cloud function deployment utilities.
This service does two things:
- Searches Facebook's Marketing API for targetable interests
- Manages Facebook API access tokens
The API search checks names, descriptions, and paths - finding more interests than Facebook's in-platform tool which only does exact matches.
Returns:
- Interest name
- Audience size range
- Category path
- Description
- Topic
Takes comma-separated search terms, returns JSON.
- Converts short-lived tokens to long-lived tokens
- Deploys tokens to cloud functions
- Handles SSL certificates
- Has manual deployment option
- Go to Facebook Access Token Tool
- Find your app
- Copy the User Token (short-lived token)
- Run:
python3 src/exchange_token.py
- Paste your token when prompted
- Type 'y' to deploy to both functions
The script will:
- Get your long-lived token
- Deploy it to both functions
- Show you the new token
To deploy without updating tokens:
./deployment/gcloud_deploy.sh
https://us-central1-facebook-marketing-gpt-api.cloudfunctions.net/facebook_marketing_search
{
"terms": "comma,separated,search,terms"
}
[
{
"name": "Interest Name",
"audience_size_lower_bound": 1000000,
"audience_size_upper_bound": 1500000,
"path": "Interests > Category > Subcategory",
"description": "Interest description",
"topic": "Topic category"
}
]
- Audience Analysis
- Looks at core interests
- Checks behaviors and values
- Finds related brands/activities
- Search Terms
- Uses short, specific terms
- Includes variations
- Skips unnecessary words
- Uses unique identifiers
- Results
- Checks relevance
- Looks at audience size
- Reviews categories
Made by Ryan Mioduski. Open issues or PRs for changes.