Zapier is a service that allows you to build advanced automations around webhooks without development experience. In this guide you’ll learn how to use Zapier by creating a basic automation that sends you an email notification any time a user creates an account in your app. Don’t worry if this particular automation is not useful to you - this guide is designed to be used as a starting point for your own custom automations.
Your first Zap
We’ll accomplish our goal by creating what Zapier calls a Zap - an automation that executes an “action” when a “trigger” is fired. In our case the trigger will be a new user webhook from Treefort and the action will be a notification email sent to yourself.
1. Create a Zap
First things first: Zapier setup.
Create a Zapier account: If you don’t already have a Zapier account then sign up here. Their free tier is adequate for this guide. As you increase your usage of Zapier you may have to upgrade to a higher tier. Read Zapier’s pricing page for details.
Create a Zap: From your Zapier account, click the orange “Create” button and choose “Zaps”.
Setup a trigger: Your new Zap will include a trigger and an action. Click the trigger and then choose “Webhooks”.
Under “Trigger event” choose ”Catch Hook” and then click “Continue”.
Under “Pick off a Child Key” enter “data.user”. We‘ll explain why later. Click “Continue”.
Copy the URL under “Your webhook URL” for use in the next step. This is the URL that Treefort will send webhook notifications to.
2. Create a webhook
Next we‘ll create a webhook in Treefort that will notify Zapier any time a user is created in your app.
Open your Treefort dashboard in a new tab (without closing Zapier) and navigate to the webhooks page under “Integrations”.
Click the blue “Add endpoint” button and paste in the URL you copied from Zapier in the previous step.
Under “Description” enter “Email me any time a user creates an account.”
Under “Subscribe to events” scroll down and select “user.created”.
Click “Create”.
3. Test your webhook
In this step we’ll test that our webhook and Zapier trigger are working correctly.
Open up your web app and create a new account using any email address (it doesn’t even have to be real). You don’t need to subscribe, just create an account.
Navigate back to the webhook you created in your Treefort dashboard and click the refresh icon next to “Message Attempts”. You should see a new “user.created” message.
Switch back to Zapier and click “Test trigger” for your Zap. You should see your webhook message pop up under a card called ”request A”.
Once you’ve confirmed that everything is working, click “Continue with selected record” in Zapier.
4. Finish your Zap
At this point we’ve setup Treefort to automatically notify Zapier via webhook any time a user creates an account in your app. The last step is to tell Zapier what to do when that happens: send you an email notification.
Search for “email” in the Zap‘s action popup and choose the first result.
Under “Action event” choose “Send Outbound Email” and click “Continue”.
In the “To” field enter your own email.
Under “Subject” enter “New user!” and under “Body” enter “A new user signed up with email: ”.
With the “Body” field still focused, press the slash key. Choose “Email” under “Catch Hook”. Entering a slash in Zapier pulls up a menu that allows you to select a dynamic value from your trigger. In this case we configured our action to include the new user‘s email address in the email notification.
Click “Test” and you should receive an email about the new user.
Clicking “Publish” will take this Zap live, meaning that you‘ll continue to receive these email notifications for every new user that signs up for your app. That’s it!
Getting fancy
Now that you’ve setup a working Zap you’re well on your way to building your own custom automations. Read on for additional tips.
Multiple webhooks
Feel free to create as many webhooks as you like in Treefort. When working with Zapier you will usually create one webhook per Zap.
The webhook event catalog
You‘ll notice that there were a lot of options to choose from when we selected the user.created
event in Treefort for our first Zap. You can browse the full list of available events by clicking the “Event Catalog” tab under the webhooks page. Each of your webhooks can be configured to send one or more of these events.
Selecting webhook event data
Remember when we entered “data.user” under “Pick off a Child Key” in our first Zap‘s trigger? That’s called “dot notation” and it’s a way to reference a particular field in the data that Treefort sends to Zapier.
If you open up the “Event Catalog” tab under the webhooks page and expand the “user.created” event you‘ll notice that it contains a “user” object nested inside a “data” object. That’s where “data.user” came from. If you only cared about the user’s email in Zapier you could have entered “data.user.email” to select the email field nested inside the user object.
If you poke around the event catalog you’ll notice that other webhook events contain other fields that can all be accessed in this way. For example you can extract the subscription data from a subscription event in Zapier using “data.subscription”.
Zapier actions
Zapier includes a huge selection of pre-made actions for third party software. Search around to see if the software you’d like to integrate with Treefort is available for use in your Zaps. It probably is, but if not don’t hesitate to reach out to us and we’ll see if we can help.
Zapier documentation
Zapier has comprehensive documentation for their service available here: https://help.zapier.com/hc/en-us