In my last post I’d described my initial set up of Zapier to “synchronise” my Trello and BitBucket systems.
I defined 4 Zaps that seemed to provide the functionality I needed to test Zapier at this point:
- When I Open an Issue in BitBucket then Zapier will Create a Card under my Backlog list in my Trello Board.
- When I Create a Card in the Backlog list in my Trello board, Zapier will Open an Issue in BitBucket.
- When I Create a new Repository in BitBucket the Zapier will Create a New Board in Trello.
- When I Push to BitBucket then my Changesets are logged as cards into a BitBucket Log list in my Trello Board.
(Note: All list names in Trello are the ones I use – yours are likely to be different!).
All tested as expected. HOWEVER, the eagle eyed amongst may have spotted the problem – I did leave it as it was initially set up to see if Zapier was intelligent enough to work around the problem (It wasn’t but can be told how to!).
The problem: Zaps 1 and 2 form an infinite loop. This is exactly what happened: I created new Backlog card in Trello, a few minutes later Zapier Opened the Issue in BitBucket, a few minutes later Zapier Created a new Card from the new Issue and a few minutes later Opened a new Issue in BitBucket….. I let it run for 7 iterations then switched the Zap off.
I contacted Zapier about this and they answered within their stated time scale (a couple of hours, more on their support below). However, by that time I’d worked out the method to avoid the loop! Zapier comes with a rich set of Filters for each service it connects and using these avoids infinite loops or Zap duplication. This is where having a separate Zapier BitBucket account is very useful (though not essential).
The “BitBucket Open Issue to Trello Create Card” filter:
In Section (4) of the Zap edit (Filter BitBucket Triggers) I used the Custom Filters to create a single filter that would avoid any issues opened by my “Zapier” BitBucket account.
The left hand drop down provides a list of BitBucket fields that can be used – I selected reported_by_first_name, then set the middle filter action to (Text) Does not contain and entered the value Zapier in the data field (right most).
Filter used for BitBucket to Trello Zap
This passed the test and now works only when a BitBucket Issue is opened by someone other than “Zapier”!
The “Trello Create Card to BitBucket Open Issue” filter:
This needs a slightly different approach to the previous filter because there is no Zapier Trello user to identify the source of the Card. However, it is easy to add an identifier to the data that is passed via Zapier. This must be done in the “Open BitBucket Issue to Trello Card” Zap – the same one as used to set the filter above.
So I select that Zap for Edit and move down to section 5: Match up BitBucket Issue to Trello Card. Below the Board and List selection boxes are the Name and Description fields.
In the Description field I have used the Issue Content (a selectable BitBucket data field) and have also added a literal (Via Zapier) text indicator. This serves to:
- show that the card came from BitBucket via Zapier.
- act as a filter item to prevent the card getting Zapped back to BitBucket.
This tested ok and teh Zap switched on. This completes the changes needed to the BitBucket Issue to Trello Card Zap.
The next stage is to add the filter to the Trello Card to Bitbucket Open Issue Zap. Edit the Zap and move to section 4: Filter Trello Triggers.
The left hand drop down provides a list of Trello fields that can be used – I selected desc, then set the middle filter action to (Text) Does not contain and entered the value Zapier in the data field (right most).
And that’s it! Test again and switch on the Zap. And it works like a dream! No more infinite loop.
And, as these things tend to happen, after I’d set it up and got it all working I got a detailed reply from Zapier support with the following:
If you want those zaps to work the way you intended but without the duplicates, we put together a guide that lets you use filters and a slight adjustment to how you create those cards/issues to avoid that loop: https://zapier.com/help/avoiding-zap-loops/
The Push to Bitbucket creates new Trello card Zap.
I think this is really good. I push changes to my BitBucket repo and some minutes later a new card appears in my Trello Board BitBucket Log list with the Revision number and Date and Time. There are more details within the card – but this allows a really good overview of the project progress within Trello (a single point of reference).
I suspect I am only just at the very beginning of finding all the features and uses of Zapier. But, so far, it is proving its value.