I build small Apify actors. Last week I tried to make one of them run straight after a Google Maps scraper, so the second actor receives the first one's results without anyone copying a dataset ID. The first version failed with a 403. This is what was wrong and how it works now.
What I wanted
Actor A scrapes places. Actor B takes each place's website and finds contact emails. In the Console, B has an Integrations tab. You add A, and when A finishes, B starts with A's dataset ID filled in.
What failed
My first version read the ID from the webhook payload inside B:
const datasetId = input.datasetId ?? payload.resource.defaultDatasetId;
const ds = await Actor.openDataset(datasetId, { forceCloud: true });
On a run started by the integration it returned 403. The dataset belonged to another run and B had limited permissions, so it was not allowed to read it.
The fix
Limited-permissions actors can read a dataset when it arrives through an input field that is declared as a dataset resource. In input_schema.json:
"inputDatasetId": {
"title": "Dataset from another actor",
"type": "string",
"editor": "textfield",
"resourceType": "dataset",
"resourcePermissions": ["READ"]
}
Apify grants the run read access to whatever dataset ID the user puts in that field. Nothing else in the code changes: the same Actor.openDataset(id, { forceCloud: true }) call works.
Filling it in automatically
On actor A, open Integrations, add actor B, and in the body use the default dataset of the run that just finished:
{ "inputDatasetId": "{{resource.defaultDatasetId}}" }
I ran this against the Google Maps scraper compass/crawler-google-places and B received the dataset and read it. If you leave the field out of the schema, the same body gets the 403 above.
Two small things I hit
- A cost cap of
0.1USD on a run of that scraper was refused. The minimum I could set was0.5. - Read the field names from the other actor's output before you map them. I let B accept a field name (default
website) and fall back towebUrlanddomain, so one input works with several scrapers.
Where I use it
Three of my actors accept a dataset this way: website-contact-extractor, bulk-email-verifier and google-maps-verified-email-scraper. Disclosure: I build and sell them (pay per event).
Docs worth reading: Apify integrations and actor input schema.
If you have a case where the Integrations tab behaves differently, tell me in the comments. I have tested one pairing, not every one.
Top comments (0)