Zendesk Integration

Build apps on top of your customer support data.

Note: Retool currently only supports connecting to Zendesk's API via our REST API integration.

Authentication

Zendesk supports 3 different authentication methods for using the support API: basic auth, API Tokens, and OAuth. We'll run through all of them here.

Basic Auth with the Zendesk API

Using basic auth is easy, but you'll first need to enable it in your Zendesk API settings:

Once you've enabled basic auth in Zendesk, head over to Retool (create an account if you don’t have one). Click on the “Resources” tab up top, tap on the “Create new” button on the top right, and choose “REST API” as your resource type.

Start by pasting your Zendesk subdomain (ours is retooldocs.zendesk.com) + /api/v2 into the "Base URL" field. Then, from the "Authentication" dropdown below, choose "Basic Auth." Enter your username (email) and password, click "Create resource," and you're ready to go.

API Tokens with the Zendesk API

To authenticate with the Zendesk API via an API Token, head over to your API settings. You'll need to enable Token Access, and then create a token:

To create a token, click "Add API Token" and give it a name. Once you've got it copied to the clipboard or saved elsewhere, head to your Retool homepage (create an account if you don’t have one). Click on the “Resources” tab up top, tap on the “Create new” button on the top right, and choose “REST API” as your resource type.

Start by pasting your Zendesk subdomain (ours is retooldocs.zendesk.com) + /api/v2 into the "Base URL" field. Then, from the "Authentication" dropdown below, choose "None" - we'll do it in the request headers. Scroll up to the "Headers" section and add an Authorization header. It should be of type Basic, and the actual token is going to be a Base64-encoded combination of your username (email) and API token. The format should look like:

<username>/token:<token>

So for us, it looks like [email protected]/token:6wiIBWbGkBMo1mRDMuVwkw1EPsNkeUj95PIz2akv. Finally, we need to Base64 encode this - you can use a free tool on the web like this one. The final header value should look something like:

Basic anzdGluJldG9vbC5jb20vdG9rZW46TnVMVDNScElxWEIzelU5SW1EcFhVVkF5N3QwZjZJOEZSQllOam9TVA==

Click "Create resource" and you should be good to go!

OAuth with the Zendesk API

To authenticate via OAuth (check out Zendesk's docs here), navigate to the "OAuth clients" section of your Zendesk API settings. You'll need to create a new client application for Retool, and copy the resulting Client Secret and ID.

In the "Redirect URLs" section, paste in https://oauth.retool.com/oauth/user/oauthcallback - this is the callback URL Retool uses for authenticating via OAuth schemes. Once you click "Save" you should see your Client Secret - keep that in a safe place, as Zendesk won't display it again.

Once you've finished creating your client application in Zendesk, head over to Retool (create an account if you don’t have one). Click on the “Resources” tab up top, tap on the “Create new” button on the top right, and choose “REST API” as your resource type.

Start by pasting your Zendesk subdomain (ours is retooldocs.zendesk.com) + /api/v2 into the "Base URL" field. Then, from the "Authentication" dropdown below, choose "OAuth 2.0". There are a few fields you'll need to fill out:

  • Authorization URL: this is your Zendesk subdomain + /oauth/authorizations/new. For us, it's https://retooldocs.zendesk.com/oauth/authorizations/new
  • Access Token URL: this is your Zendesk subdomain + /oauth/tokens. For us, it's https://retooldocs.zendesk.com/oauth/tokens
  • Client ID: this is the Unique Identifier you provided when you created your client application in Zendesk. For us, it's retool
  • Client Secret: this is the secret token Zendesk provided when you created your client application
  • Scopes: you can provide a list of scopes for authorization, separated by a space. For our application, we've chosen read write

Finally, you'll need to add a Header to your request that references Retool's magic OAUTH2_TOKEN variable that gets inserted at request time. It should look like Authorization: Bearer OAUTH2_TOKEN. Here's what the final setup should look like:

You can test the OAuth flow by clicking the "Test OAuth integration with your own account" button, or do so in your query when you choose this resource from the dropdown.

Basic query: getting tickets

Start by creating a new query in your query editor (“+ new”) and selecting your Zendesk API resource from the “Resource” dropdown. Our Base URL is pre-populated from when we created the resource, so we just need to append tickets.json to the end. Click preview, and you should see your results!

Server side pagination: getting tickets

You might have too many tickets to display in a Retool table without overloading the frontend. Retool supports server side pagination with table components, so you can re-run your request every time a user switches pages. To get started, we've built a basic GET query that lists our tickets from the tickets.json endpoint. You can pull that data into a table component by referencing the query's data: in our case, {{ getTickets.data.tickets }}.

Zendesk's tickets endpoint supports multiple methods for pagination - in this tutorial, we're going to use limit-offset.

1. Update the table settings

To get started, click on your table component, head over to the right sidebar, and scroll down to the "Pagination" section. Toggle "Server side paginated" on, and select "Limit offset based" from the dropdown. In the "Number of rows in this table" field, reference the count field from the getTickets query with {{ getTickets.data.count }}. You can leave the "Selected page" field at the default.

2. Update the query

Once the table is configured, head over to your getTickets query (or whatever you've named it). You'll need to add two URL Parameters. We've named our table table1, so if you've updated your table name, you'll need to adjust this code accordingly.

  • per_page = {{ table1.pageSize }}
  • page = {{ table1.selectedPageIndex + 1 }}

Save your query, and you should be good to go. Here's what the final setup should look like:


Did this page help you?