With Apify integration for Zapier, you can connect Apify with more than 1,500 apps, including Slack, Trello, Google Sheets, Dropbox, Salesforce, and loads more. Your Zapier workflows can start Apify actors or tasks, fetch items from a dataset, set and get records from key-value stores or find actor or task runs. You can also use the Zapier integration to trigger a workflow whenever an actor or a task finishes.
In this tutorial, we'll show you how you can trigger a Zapier workflow upon a completion of a task of the Web Scraper (apify/web-scraper) actor, in order to upload its results to a Google spreadsheet.
What do you need to get started?
Before we dig into Zapier integration, you'll need to:
Have an Apify account
Have a Zapier account
Create a Google spreadsheet where the scraping results will be stored
Create a task on Apify
A task is a saved configuration for an actor - a cloud program running on the Apify platform. In this tutorial, we'll be using the Web Scraper (apify/web-scraper) actor, which is Apify's flagship tool for web scraping using the headless Chrome browser. To create a new task for this actor, simply go to https://apify.com/apify/web-scraper and click the Use actor button. Your new task will open in Apify Console. Click Run to try how the actor works and then review its results in the Dataset tab.
Let's go to Settings and set the name of the task to "getting-started-zapier", so that you can easily find it later.
Setting up a trigger on Zapier
Once you have your task ready, go to Zapier, log in and click on Make a Zap! button. Since we want to trigger the workflow when the task finishes, let's choose Apify as the trigger app.
Then select the Task Run trigger from the list.
Now you'll need to connect your Apify account with Zapier. For that you'll need your Apify API Token, which is shown in the Integrations tab on your Apify account page.
Simply copy the API token and paste it to Zapier.
After a successful connection of your Apify account, you can choose the task that you created in the previous steps from the dropdown list - just type "getting-started-zapier" in the search box and select the task. Every time this task finishes, the Zap will be triggered.
On the next page, you can see sample runs for the selected task. If you don't see any runs, you'll need to go to Apify tasks, open your task and run it. After the task is finished, you should see the last run on Zapier, where you can pick it as a sample.
Setting up an action on Zapier
Now that you have the Zapier trigger configured, you can set up an action that will be performed when the task finishes. Let's click on Add Step and choose Google Sheets from the Zapier apps.
On the next page, choose the Create Spreadsheet Row(s) action, which is available under the Show less common options link.
After that, you'll need to connect your Google Account and grant write access for Zapier. Then we can configure the creating of sheet rows. First, let's choose Google Drive and the sheet where you want to save the data. Then we select an attribute from task results for each row in a sheet. We can easily do this using a dropdown list filled with the results of the sample run results.
Then click the Continue button and on the next page click Send test to Google Sheets to test the workflow.
The Zap creates a test run of the action and we can see the data uploaded to the spreadsheet.
If the results in sheet look correct, you can simply name your new Zap and switch it on.
Once the Zap is on, it will be started every time the task on Apify finishes. Note that the Zap automatically created a webhook for the task.
Be careful here - if you remove the webhook, your Zap will stop working. Also, note that Zapier can only append a few hundred rows per one Zap run. If you need to upload more rows, you will need to use some more scalabale solution, such as the Google Sheet Export & Import (lukaskrivka/google-sheets) actor, but that's for another tutorial.
That's all, thanks for reading! We hope you found it useful. If you're missing anything, please let us know on email@example.com
Happy integrating with Zapier!