Postman bot with zendesk + slack APIs

Tae Hoshino
4 min readNov 1, 2020

Postman collection to post zendesk ticket counts in slack channel

If you are working for a SaaS company, there are many updates (e.g. new features) everyday. And one of these things support agents check first in the morning is the daily open ticket counts.

We have our daily routine of sharing this information with team by posting the list of ticket counts in a slack channel. Being inspired by this blog post, I automated the workflow using postman collection + monitor + APIs!

Specifically, this automated workflow does the following:

  • Get list of views from zendesk
  • Get ticket counts for each of the views
  • Post formatted message in slack channel

1. Getting started

  1. If you do not have zendesk support admin account, you can sign up for free trial from here. Once you verified the email address, you will be redirected to the support portal as below.
We will need subdomain to call zendesk API endpoints later

2. Then navigate to the gear icon -> Channel -> API. Allow token access and create API token which we will need to authenticate the bot. See here for more information on how to get started. (You can alternatively use password instead, but API token is recommended as it’s more secure).

3. Let’s now create slack app. Open https://api.slack.com/web and login to your slack account.

4. Go to “Your Apps” page and create new app and then select Bots.

5. On left bar, select Oauth & Permissions -> Under Scopes, add the following scopes.

6. Finally, on the top of the OAuth & Permissions page, install app to your workspace, which then generates access token (which we will need later).

2. Creating Postman collection

Here are the steps:

  1. Get list of views that the current login account has access to. From the response body, obtain id and title attributes, store them as key-value pairs of an object viewTitles and save it as an environmental variable.
    Also, ids (view ids) are concatenated to be used as an input to the request parameter in the next Get view counts request (by saving it as an environmental variable viewIdStr).
Test scripts in Get views request

New to Postman tests?
Postman test scripts can be used to post-process the response of a request so it’s extremely useful to connect multiple requests by passing the output of one request to another as an environmental variable.

2. Get ticket counts of the views by passing viewIdStr to a request parameter. From the response body, obtain view_id and value (ticket counts for a given view) and store them in an object ticketCounts. Then create a new object titleCountObj in the form of {title : ticket count} by matching id of viewTitles and view_id of ticketCounts.
Finally, a text to be posted in slack channel postText is formatted by looping over key-value pairs of titleCountObj.

Test scripts in Get view counts request

3. Post the formatted text in slack channel. Setting mrkdwn parameter of request to be true, you can use all sorts of text formatting including emoji.

Request body

3. Run the collection in runner

Finally, let’s test it by running the collection in runner!

TA-DA!

Text posted in slack

In actual use, the collection can be scheduled to run using Postman monitor. This will save a few minutes everyday.

Many a little makes a mickle.

The collection is available from:

https://documenter.getpostman.com/view/12689164/TVYKbHKE

--

--