Awhile back I was a guest on the Postman web stream along with Marcel Ribas from Dropbox. Our task was to build something live using the Dropbox and HelloSign APIs. So obviously, me being me, we set out to create a bot.

Dropbox acquired HelloSign but their products, and their APIs, are not integrated with each other yet, so the sky was the limit on what functionality we wanted to create.

I like to think about a high-level user perspective, so in my head:

“A hiring manager wants to remind new hires to sign important documents stored in Dropbox. All they need to do is add the new hires to the shared Dropbox folder and add the documents they want to be signed. The bot will send a HelloSign signature request email every day at 8am. They can sign the documents and the hiring manager can download the signed documents from HelloSign.”

As easy as this seems there are a few things to consider in this workflow collection:

  1. We will be looping recursively over each file in the folder and also looping over each folder member for each file.
  2. We need access to any folder on an account, so the token will be linked to a user and use Dropbox’s full account access
  3. HelloSign can use a Dropbox shared link with the downloadable flag set to true

Understanding this makes the collection a lot easier to understand.

I am going to gloss over the Dropbox and HelloSign app creations. The former is the hardest but by reading the Dropbox documentation or by the Response errors you will know what you permissions you need to add. You do need to make sure to give access to the Full Dropbox Access and create a non-expire access token to pass into the Authorization header for Dropbox requests. For HelloSign, it is very easy to generate a user token but you will need to add it in Postman as Basic Auth and give the access token as the user and leave password blank.

Be sure to use Auth tab and have username set to the token and password is blank

Be sure to use Auth tab and have username set to the token and password is blank

HelloSign needs to have the token as the username and password blank in the Auth tab

First, we are going to grab the folder’s contents’ file paths and the parent folder’s shared ID. We are going to save the file paths array which we will be looping over and the shared ID as environment variables.

We are going to save the file paths array which we will be looping over and the shared ID as environment variables

We are going to save the file paths array which we will be looping over and the shared ID as environment variables

Grab file paths that we will be looping over and the shared folder ID as environment variables

This next tidbit is starting to get into the meat of Postman Workflows, we are going to conditionally choose which Postman request in the collection to run after the results of the current request!

Second, we are going to go and get the Dropbox shared links. These links are generated every time you want to share files amongst users. Dropbox share links can be generated in the UI so they might exist. We will check if the file already has a public share link we can use.

Postman collections always run in order but by using **_postman.setNextRequest _**we can actually change which request to run after the execution of the current one. In this case, if we do have a link then let’s skip over **_Create Shared Link _**and use **_List Folder Members _**instead. OMG! BRANCHING REQUESTS!

#postman-collections #postman #dropbox #api #integration

HelloSign Dropbox Bot
1.10 GEEK