Integrate Trello Cards with Google Sheets
Tags: wayscript, tutorial
Published: 2020-08-06 10:55:01

Introduction
------------

In this post we will be exploring a proof of concept to write card names between Trello and Google Sheets. By using WayScript the solution is clean, easy, and seamless between the two platforms.

Prerequisites
-------------

You will need a Trello account and board and a Google account and Google Sheet to work with. To learn more about this please us the following resources

*   [Working with Trello](https://docs.wayscript.com/library/modules/trello)
*   [Working with Google Sheets](https://docs.wayscript.com/library/modules/google-sheets)

Since we will be using two triggers we should create a second function by clicking the ‘+’ in the top left of WayScript interface

![](https://wayscript.com/blog_img/125/add_function.PNG)  
![](https://wayscript.com/blog_img/125/functions.PNG)

Let’s also go ahead and import the Google Sheets and Trello packages by using the libraries tab

![](https://wayscript.com/blog_img/125/libraries.PNG)

For this post we will also Create Variables and use the Python module, If, and Print to Log modules

*   [Working with Create Variable](https://docs.wayscript.com/library/logic/create-variable)
*   [Working with Conditionals](https://docs.wayscript.com/getting_started/conditionals)
*   [Working with Python](https://docs.wayscript.com/library/modules/python)
*   [Working with Print to Log](https://docs.wayscript.com/library/logic/print-to-log)

Getting Started
---------------

Let’s get started by adding a Google Sheets trigger to trigger on new rows in our sheet to our left function  
  

![](https://wayscript.com/blog_img/125/google_sheet_trigger.PNG)

  
  

Create Boolean
--------------

We’re going to create a toggle variable to easily toggle if the card name doesn’t exist in Trello  
  

![](https://wayscript.com/blog_img/125/toggle.PNG)

  
  

Search Trello Cards
-------------------

We need to get existing Trello cards to avoid duplicates  
  

![](https://wayscript.com/blog_img/125/trello_settings.PNG)

Python Check for Difference
---------------------------

Nice Python one-liner which creates a list of differences from two lists without iteration and changes toggle to true if differences exist (easy way to check if card doesn’t exist in Trello) 
<pre>
variables[ 'card' ] = list( set( variables[ 'Row_Data' ) - set( variabled[ 'Card_Names' ] ) ) 
if variables[ 'card' ][0]:
 variables[ 'toggle' ] = True
</pre>

Check Toggle
------------

We add an If condition to check our toggle state  
  

![](https://wayscript.com/blog_img/125/condition.PNG)

  
  

Create Card (True)
------------------

If toggle is true then create Trello card  
  

![](https://wayscript.com/blog_img/125/treallo_create.PNG)

  
  

Print to Log (False)
--------------------

Card already exists in Trello  
  

![](https://wayscript.com/blog_img/125/print_log.PNG)

  
  

Trello Trigger
--------------

Now that we have the Google Sheet trigger function we need to create the Trello trigger to insert rows into Google Sheet from Trello  
  

![](https://wayscript.com/blog_img/125/trello_trigger.PNG)

  
  
Since, we will be needing an output we will need to modify Trello advanced settings  
  

![](https://wayscript.com/blog_img/125/trello_trigger_advanced.PNG)

  
  

Create Variable
---------------

We are going to create a List variable as a placeholder for our Google Sheet row  
  

![](https://wayscript.com/blog_img/125/trello_row.PNG)

  
  

Get Card Name
-------------

Again we will be using some easy Python code to parse our JSON data and append to our Google Sheet row data 
<pre>
import json data = json.loads( variables[ 'JSON_Data' ] variables = [ 'trello_row' ].append( data['action']['data']['card']['name'] )
</pre>

Write Google Sheet
------------------

Let’s write our card name from Trello as a new row in Google Sheets  
  

![](https://wayscript.com/blog_img/125/google_sheets_write.PNG)

  
  

Result
------

You should now be able to create rows and cards to/from Trello and Google Sheets  
  

![](https://wayscript.com/blog_img/125/google_sheet.PNG)

  
  

![](https://wayscript.com/blog_img/125/trello_list.PNG)

  
  
As always, if you have any questions, comments, feedback, or suggestions, please let us know on WayScript or through our [discord](https://discord.gg/VWbXSbj). If you would like to view this WayScript simply follow the link [Trello Cards and Google Sheets](https://wayscript.com/user/wizgeeky/ACZLq726).