Build and Publish a New Integration with Zapier

December 12, 2023
JP Soto
Build and Publish a New Integration with Zapier

For our PeopleSmart customers, we want to create a Zapier integration that facilitates Contact Report data to be used in automated flows. With Zapier integrations, we can make sure that, as soon as a User runs a Contact report, the metadata we chose to expose to Zapier will be used in Zapier flows to trigger further actions with other available integrations, such as Slack and Gmail. 

Zapier integration tips

Zapier recommends using as few triggers/actions as possible in the beginning to be able to publish your integration quickly. Once your integration is published and it gains traction with users, you can start adding more and more triggers/actions to it.

Zapier integration main steps

  1. Open Zapier’s visual builder at zapier.com/app/developer.
  2. Fill in the details about your app.
  3. Add your API’s authentication, triggers, and actions.
  4. Once the above steps are complete, your app will be tagged as Public Beta.
  5. Then you need to meet another round of requirements in order to be fully and publicly published. 

Zapier requirements to fully publish your integration

First of all, you will need to fill out a document provided by Zapier. Zapier will use the info provided to build internal and external documentation about your integration.

Then, as a second step, you need to create and Publish at least 10 Zap templates, and,

finally, your integration needs to attract 50 active users. This means that there must be at least 50 users using your integration in a Zap and the Zap must be turned on for the users to be valid.

Workaround to meet the 50 active user requirement

If you choose to embed your Zapier integration in-product behind a login screen, Zapier can waive your 50 active user requirement for you. This looks as follows:

Of course, this workaround does not apply for all customers. 

Zapier verification schedule 

Zapier has a system that checks daily for apps that have met the launch requirements. You will be automatically launched once these requirements are met, and the beta tag will be removed soon after. You’ll see an email in your inbox announcing the launch and your official admittance to the Partner Program at the end of your launch month.

Zapier recommends using OAuth v2 because it matches the login process they expect from most modern apps. 

Also, the user part of authentication typically takes place in full on the app’s own site, which is very convenient because it reduces the complexity of maintaining the screen login.

Authorization libraries

It depends on what programming language you are using. For example, if you are using Ruby on Rails, the Doorkeeper gem for the OAuth support is a great choice.

Usually, the Doorkeeper gem is mentioned along with the Devise gem, which is an Authentication solution. This is because both gems work very well together to provide authentication and authorization logic out of the box.

If you need to override a Doorkeeper view in your application, you can add a file, for example, new.html.erb, with the same name and location that the Doorkeeper gem uses, like this.

For example:

/app/views/doorkeeper/authentications/new.html.erb

Refresh token configuration

The Zapier site mentions that configuring the Refresh token endpoint is optional. However, you do need to configure it. Otherwise, your integration will throw up errors because the access token will expire and you will not be able to renew the token by itself.

The Refresh token is used to request a new pair of Access-Refresh tokens, so the integration can still keep performing requests using the new Access token.

Zapier OAuth Redirect URL

By default Zapier provides a redirect URL: (https://zapier.com/dashboard/auth/oauth/return/App16602CLIAPI) to allow you to start working on your integration. When the integration is partially completed and tagged as beta, the redirect URL changes and includes the name of the integration/app in the URL.

The new URL will look like: https://zapier.com/dashboard/auth/oauth/return/AppMyNewZapierIntegration. This is important because you will need to change that URL in the configuration of your integration.

Authorization flow diagram

Zapier triggers 

Once the authorization part is ready, Zapier needs to have at least one trigger configured. The trigger is the way Zapier knows that something has changed and there should be an endpoint configured for this purpose.

Zapier will check the endpoint every X minutes to see if something changed. If new data is fetched, Zapier will use that data with any integration configured within the flow.

Trigger flow diagram

Zapier Polling — Webhooks

The time range Zapier uses to hit the Trigger endpoint depends on the user’s paid account. There are two ways in which Zapier can perform this. One is by Polling and the other one is using Webhooks. 

Code Snippets

Doorkeeper Code Snippet

# Gemfile
gem 'doorkeeper', "~> 5.5.4"

# initializers/doorkeeper.rb
Doorkeeper.configure do

orm :active_record

# Enable refresh token
use_refresh_token

# This block will be called to check whether the resource owner is authenticated or not.

  resource_owner_authenticator do
  current_user || User.find_by_user_code(session[:user_code])
end
end

URL Configuration Code Snippet

# application.rb
module App
class Application < Rails::Application

  config.authorize_url = 'https://www.domain.com/oauth/authorize'
  config.authorize_css = 'https://www.domain.com/assets/application'
  config.assets_url = 'https://www.domain.com/assets/'

  config.to_prepare do
    # Only Authorization endpoint
    Doorkeeper::AuthorizationsController.layout "authorize"
  end
end
end

end

Zapier is a very good tool to automate tasks based on triggers that can be customized through regular integrations or integrations built from scratch. 

Additional references

1. Webhooks and polling

2. Zapier Visual Builder

3. Zapier Build Integration Steps