Recurring Events and Deferred task for Trello

How to implement  deferred and recurring tasks for Trello

This blog provides step by step instructions to getting recurring cards and deferred cards working in Trello. I was using different technologies to create  a workflow that adds the extra functionality by adding tags to the description in Trello cards.

Technological “pieces” involved:

  • Trello API with Web Hooks
  • Amazon AWS Lambda functions with a Dynamo DB table and the AWS API gateway
  • Node.js as the language (for the AWS Lambda functions).

The blog is written for anyone interested in having the same functionality.

See the video below:

What is trello ?

Trello is a collaboration tool that allows you to arrange your projects into boards, list of related activities and cards (tasks).

Legalities

I am not affiliated, associated, authorized, endorsed by or in any way officially connected to Trello, Inc. (www.trello.com).

Why recurring tasks are important?

Many project related activities have recurring events, especially when considering projects relating to all aspects of life.

Examples:

  • Do your timesheets at a certain interval
  • prepare for a recurring meeting
  • run a certain report on a weekly / monthly basis
  • prepare a progress report email to a client on a weekly basis
  • etc …

In Trello, you can mimic recurring events using one of two ways:

  • Clone the task before completing it, and manually enter the new end date in the cloned task.
  • Not completing the task, and simply reassign a new due date.

The Trello way is simply not good enough for me, I am lazy and I do not want to manually change the date all the time, or manually clone the task.

What’s the big deal with deferred tasks?

Many tasks are things that you know that you need to do at a certain time, but there is no need or ability to do them before a certain date.

Example: if you need to prepare a month end report, you have it in your todo list, with a due date for the end of the month, but you cannot really start working on it before month end.

Since Trello do not have defer capability, you keep seeing the task in your list and you have to keep ignoring it until the right time. This takes mental energy that can be spent on better things.

Ideally, when you have the ability to choose a start date, that task would stay hidden from view until the start date arrive, at that point, it would appear for you as an available item to work on.

Example:

A month end report will have a due date of the 30th of the month, and a start date of the 28th of the month, so on the 28th it appears as an available task to consider.

The end goal of this blog

Recurring cards – By the end of implementing the workflow in this blog, you will be able to drag tasks into a “Done” list in Trello that would trigger the creation of a new task with a new due date based on a rule you specify in the task description.

Deferred cards – By the end of implementing the workflow in this blog, you will be able to defer a task, make it disappear and reappear at the appropriate time.

Server-less environment – I wanted to build a system that does not require running physical servers. The last thing we want to do is add complexity to our lives. Servers need to be maintained, they go down, they need regular security updates etc.

The big plan

Note: if some of the following lines sounds like Martians – don’t panic !, I will provide detailed instructions.

Note 2: this is a workflow I implemented over a couple of weekends without deep previous knowledge of any of the technologies used. It works for me, but I cannot guarantee it will work for you, or that it will not completely destroy your Trello environment, or make you miss an important task. I assume NO responsibilities for any loss of any kind, data, financial, mental, spiritual , or any other kind of loss.

Assumptions: I assume you are using a Mac, this should not affect you as long as everything works as expected (they always do , don’t they?), but I am sure that with little tweaking, the testing and troubleshooting parts can work on windows as well.

I also assume that you are semi technologically savvy. I am doing my best here to provide detailed instructions, but this is not a process for the complete beginner.

We will utilize the awesomeness that is AWS (Amazon web services). We will use the following services:

  • Amazon lambda functions
  • Amazon API gateway
  • Amazon Dynamodb
  • Trello API

Programming languages we will use:

Node.js with the following modules:

  • sugar —> Provides fancy date strings like “3 weeks from now”
  • node—trello —> The trello api client
  • AWS-sdk (for local testing) —> A client for the Amazon web services, we will use dynamodb and ses (simple email service)
  • local lambda —> Mimics the AWS lambda environment for local testing purposes
  • ini —> Provides initialization files support for configuration options.
  • fs —> Allows us to read the configuration file

Costs – please take a look at the following pages:

https://aws.amazon.com/lambda/pricing/

https://aws.amazon.com/dynamodb/pricing/

As far as my calculations go (for my own usage), I calculated a few cents per month. Having said that, if someone finds my end points to the API , they can potentially run millions of requests per day and completely bankrupt me, so use with caution.

How is it going to work?

Recurring cards -> For recurring tasks you will be able to use specialized text in the description field of cards to let the system know when the next occurrence suppose to occur.

Example: <! 10 days from now !>

Will mean that whenever you drag the card to a “done” list, Trello will create a duplicated card with a due date that matches the rule.

Deferred cards —> For deferred tasks, you will be able to use specialized text in the description field of cards to let the system know when the card should be enabled again.

Example: <+ last day of the month +>

This will make the card archived until the time comes, at that point (it keeps track of the time by using the Dynamodb table), the script will remove it from archive when the time arrives.

Step by step:

Login to the AWS management console

Make sure you have an AWS account (Amazon web services)

NOTE: There are charges involved in this. Take a look at the pricing on the AWS website before you proceed.

Goto: http://aws.amazon.com , and login to your AWS Management console.

1__aws_account

If you do not have an account, press the “Create and AWS Account” button, and follow the instructions, and than go to your AWS Management console.

Create an amazon DynamoDb table (record the region)

2__aws_dynamodb

3__aws_dynamodb_create

4__aws_dynamo_creating_png

  • Make sure to record the region the tables is created in (you will need it later to configure your code)
  • Make sure to add “cardId as the primary key.
  • Take note of the table name you choose (you will need it later to configure the code)

Create an Amazon role

5__aws_iam

When creating the AWS Lambda functions, we will need to provide them with a role to allow them to connect to AWS resources.

I was using only one role for all of the lambda functions. This is probably not the recommended way by Amazon, but it was more convenient for me.

You can use the following code to create your role, that provides access to running a lambda function, provides it crud (create, read, update delete) on the DynamoDb Table, and gives it access to SES – the Amazon simple email service. You will need to replace the table name and the region (on line 34)

This website provides you with the names of the regions as the script below is looking for.

http://www.stelligent.com/cloud/list-all-the-availability-zones/

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "lambda:InvokeFunction"
            ],
            "Resource": [
                "*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "dynamodb:UpdateItem",
                "dynamodb:PutItem",
                "dynamodb:Scan",
                "dynamodb:DeleteItem"
            ],
            "Resource": "arn:aws:dynamodb:<region name>:*:table/<your table name goes here>"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ses:SendEmail"
            ],
            "Resource": "*"
        }
    ]
}

Download an install the code from github

Follow my instructions here to install the environment, and setup the config files.

https://github.com/asabi/recurring-and-deferred-cards-for-trello

Test the different pieces with the testing instructions.

At the end of the setup run “./shipToAmazon.sh”, that will create a zip file to use when uploading the code to the AWS Lambda function.

Create the lambda functions

For the basic functionality of having recurring cards and deferred cards, we will need three Lambda functions. If you want to be able to add a task by calling a url (for example to add a task using Alfred on the mac), you will need the 4th function, but that’s options.

The 4 Lambda functions are (you can call them any way you want by the way, the name is not relevant, as long as you know what it is):

createTrelloRecurring – This Lambda function is used to replicate a task, but with a new due date that is based on a string in the description of the task.

trelloDeferCards – This Lambda function is used to archive a card in Trello, and keep the card ID and title in a DynamoDb table (for tracking purposes)

enbaleTrelloDeferredCards – This Lambda function is used to unarchive cards when the time arrives. It uses the DynamoDb table to figure out the cards to unarchive. This function gets called every X minutes (I made it 5 minutes, but if you want to pay less, you can run it every hour , once a day, whatever works for you.

createCardInInbox (optional) – This Lambda function can be used to create a simple card that only has a title, it is created in a list on a board that you choose to use as your “inbox” (GTD term).

To create the Lambda functions, first get the code and install the required node modules (described in the repository), setup your config.ini based on your needs, and run the ./shupToAmazon.sh file. That will create a new .zip file that you will use to upload to every Lambda function (you re-upload the exact file for each).

To create a Lambda function, follow these instructions:

6_aws_LambdaFunctionsPage

7_aws_SelectBlueprint

8_aws_ConfigureLambda

Feel in the name, and the description, keep the runtime on “node.js”, for the code select “Upload a .ZIP file”.

When choosing the Handler, make sure to use the appropriate location. These are the locations (pretty self explanatory based on the function names above):

  • enableDeferredItem.handler
  • createRecurringItem.handler
  • archiveDeferredItem.handler
  • createCardInInbox.handler

For the role, I was just using the same role that we created above, if you want to be more secure, create a role per function with only the permissions that the Lamda function needs (for example, createCard and createRecurring do not need access to DynamoDb).

For the timeout, I gave it 10 seconds, just in case, but in most cases it finishes way sooner.

Hit “Next” and “Create Function”

For the “enableTrelloDeferredCards”, select the “Event Sources” tab, and add a new “Scheduled Event”, with the rate you would like it to run on.

9_aws_Add_Source

Create the API gateway

Now when we have all of our Lambda functions setup, all we need to do is create a simple API gateway with 3 end points for:

  • Copying a card with a new due date when a recurring one is completed.
  • Archiving a card when (defer it)
  • Creating a new card (a simple end point

To start navigate to the api gateway console, and click on the “Create API” button.

10_aws_api_gateway

for each of the end point click on “create resource”, and create the end point as shown in the pictures. Make sure you click on the “/“ at the top before making each one, otherwise every new end point will be made as a child of the previous one.

11_aws_endpoints

Once you are done, create a POST method for each of the end points. Choose the appropriate Lambda function for each:

12_aws_create_endpoint

We now have to add 2 “HEAD” end points, one for the defertrellocard, and one for createrecurrinttask end point. The reason for those two, is that Trello will send a “HEAD” request when creating as web hook, if you do not create those methods, you will not be able to create the web hook to trigger those actions. You can choose “Mock integration” for the “integration type” (Trello just needs the end point to return a 200 header).

Once it is all done, click on the “Deploy API” button. Choose new stage, and give it a name (I called it production, but you can call it watever you like), and hit the deploy button.

This will take you to the stages view, where it will show you the base URL to access your end points. You will use those links to create the web hooks for trello.

See the image below. The invoke URL is the base, note on the left the two resources that have a “HEAD” method.

To call each end point, simply use the base URL with a “/“ and the resource name.

13_aws_api_gateway_deployed

Set up the Trello environment

Add a list named “Done” to any of the boards you would like to make recurring tasks working.

Create the web hooks

To create the web hooks, use the code provided on github.

execute:

node webhooks.js list

To see the list of existing hooks, this will also confirm that you have configured it properly. You most likely not have anything, unless you already played with it before.

Create an web hook for each Trello list you would like to create recurring events in (when a card will be dropped to it, a new ones will be created as long as there is the appropriate text description:

node webhooks.js create ‘<url to the api gateway web hook for createrecurringtask>’ ‘<description>’ ‘<board name>’ '<list name>'

Create a web hook for the boards you want to be able to defer cards in:

node webhooks.js create ‘<url to the api gateway web hook for defertrellocard>’ ‘<description>’ ‘<board name>’

Test that it all works

  1. Create a new card, and add some future date to the description using your recurring keyword, drop it into your “done” list, you should see a new card added in place of the card you just completed.
  2. Create a new card, and add some future date (a minute or so into the future) to the description using your deferred keyword. As soon as you hit “save” for the description, the card will get archived, and the next time the enbaleTrelloDeferredCards runs, it should show.

If things do not work, take a look at the debugging instructions on the github project (https://github.com/asabi/recurring-and-deferred-cards-for-trello).

Resources:

Resources I used when creating this workflow:

https://trello.com/app-key

https://github.com/adunkman/node-trello

https://developers.trello.com/advanced-reference/

http://sugarjs.com/dates

https://jsonformatter.curiousconcept.com

http://requestb.in

http://www.themarketingtechnologist.co/building-a-url-validator-with-amazon-api-gateway/

http://ashiina.github.io/2015/01/lambda-local/