Trello Power-Ups are like plugins for Trello that can extend its existing functionality and integrate external services. Today we're going to build a simple Power-Up, deploy it to Netlify, and add it to a board. Basic knowledge of JavaScript is required to really follow along. I'll be using VSCode as my code editor, but any editor will work.

Building the Power-Up

Power-Ups are hosted in an IFrame within Trello, so we need to basically create a website with some JavaScript that Trello will use to add the functionality itself. In your editor, create a new HTML file with the following in it, save it to an empty folder as index.html.

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
</head>

<body>
  <script src="https://p.trellocdn.com/power-up.min.js"></script>
  <script>
    TrelloPowerUp.initialize({
      // Start adding handlers for your capabilities here!
      'card-buttons': function (t, options) {
        return [
          {
            icon: "https://i.ibb.co/6sbknH0/logo-stroke-32pt-style-2-no-stroke.png",
            text: 'Hello World!',
            callback: function (t) {
              return t.card().then((card) => alert("hello world!"))
            }
          }
        ];
      },
    });
  </script>
</body>
</html>

Here is what this little Power-Up will do to start.

  • Add a button to every card.
  • When the button is clicked, it will display a browser alert of "hello world!"

Deploying to Netlify

Deploying a Power-Up to Netlify is just the same as deploying any other site to Netlify. If you don't have an account, you can create one for free at https://app.netlify.com/signup/email. Once logged in, head over to sites, scroll to the bottom, and you'll see a place where you can drop a folder. Go ahead and drag the folder that contains the index.html file we created into this area. You'll then be presented with a new view that lists a URL for your site. This is what we will use to register the Power-Up with.

https://cdn.brianmorrison.me/media/2020/3eb314a0-260f-4d2f-b77d-301e7908c702

https://cdn.brianmorrison.me/media/2020/e0b83c5e-304a-450f-b671-37dc9fbe6c7a

Creating a Power-Up App

To get the Power-Up working in Trello, you'll need to register it. Head to https://trello.com/power-ups/admin and click on Create New Power-Up. Give your Power-Up a name, select a team to use the Power-Up, then paste in the URL from Netlify.

https://cdn.brianmorrison.me/media/2020/37de1dd9-e1c3-45d8-9eaa-54cf5c3dc8b9

https://cdn.brianmorrison.me/media/2020/1ff2cc71-2372-4dcd-985b-641dc3cdc691

Once you click Create, you'll be taken to the Power-Up Management Screen. Once there, head over to Capabilities on the left. This will show you all the functionality that can be built with Power-Ups. For our little test, we need to enable Card Buttons, so find that in the list and enable it.

https://cdn.brianmorrison.me/media/2020/ce01836e-4d97-4079-abd0-92c3c1c9a3dc

Testing our Power-Up

Now that our App is setup, lets add it to the board. You'll need to select a board that is part of the team that the power up was added to. Once your board is open, open the Menu, click on Power-Ups, select Custom, click Add under the name of your Power-Up, and then Add one more time.

https://cdn.brianmorrison.me/media/2020/f8164898-8da3-4bef-a177-f05c02ad0854

https://cdn.brianmorrison.me/media/2020/3e8de941-4025-4ab9-bba6-e5aa23c018e4

https://cdn.brianmorrison.me/media/2020/97d1897d-a333-40ab-83e1-852fd8668b36

Now open a card and you'll see a new Hello World button on the right side. Click it and you should get an alert pop up, which is exactly what we built and deployed to Netlify.

https://cdn.brianmorrison.me/media/2020/2d5e0fe1-4743-402e-9812-94d6a4f70395

https://cdn.brianmorrison.me/media/2020/cd092af2-0092-4f42-80f8-55ac889e5010

Getting Card Details

Now that we have a Power-Up built and working, lets expand it just a bit. We're going to grab the name & id of the card, then add that to our alert box. This is simply to demonstrate how you can get data from the card to use in your code however you need to.

Lets go back to our Index.html and update it like so. Note the changes on the line starting with return t.card(...

<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
</head>

<body>
  <script src="https://p.trellocdn.com/power-up.min.js"></script>
  <script>
    TrelloPowerUp.initialize({
      // Start adding handlers for your capabilities here!
      'card-buttons': function (t, options) {
        return [
          {
            icon: "https://i.ibb.co/6sbknH0/logo-stroke-32pt-style-2-no-stroke.png",
            text: 'Hello World!',
            callback: function (t) {
              return t.card('id', 'name').then((card) => alert(`Alert on card ${card.name} (id: ${card.id})`))
            }
          }
        ];
      },
    });
  </script>
</body>
</html>

Now you can redeploy your site to Netlify by going into your site, opening Deploys from the top bar, and dragging your folder in again.

https://cdn.brianmorrison.me/media/2020/12d6498c-b321-4547-ab49-4f79aea453b8

Once its redeployed, refresh your Trello page and lets test the button again. You should now get an updated alert box.

https://cdn.brianmorrison.me/media/2020/3f2652fd-97d8-4591-a852-3ea8cbbccb7b

Adding a Board Button

For one more experiment, lets add a button to the board now. In this updated code, I added another object into TrelloPowerUp.initialize for the board button.

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
</head>
<body>
  <script src="https://p.trellocdn.com/power-up.min.js"></script>
  <script>
    TrelloPowerUp.initialize({
      // Start adding handlers for your capabilities here!
      'card-buttons': function (t, options) {
        return [
          {
            icon: "https://i.ibb.co/6sbknH0/logo-stroke-32pt-style-2-no-stroke.png",
            text: 'Hello World!',
            callback: function (t) {
              return t.card('id', 'name').then((card) => alert(`Alert on card ${card.name} (id: ${card.id})`))
            }
          }
        ];
      },
      'board-buttons': function (t, options) {
        return [
          {
            icon: "https://i.ibb.co/6sbknH0/logo-stroke-32pt-style-2-no-stroke.png",
            text: 'Hello Board!',
            callback: function (t) {
              return t.board().then((board) => alert("Hello from the Board!"))
            }
          }
        ];
      }
    });
  </script>
</body>
</html>

Before you deploy to Netlify, head back to https://trello.com/power-ups/admin, open your app and enable Board Buttons under Capabilities.

https://cdn.brianmorrison.me/media/2020/e9e22b28-ccea-4a33-b444-04853042e66e

Redeploy to Netlify and refresh your Trello window. You should have a new button on the board. Click it and you should receive an alert from the Board!

https://cdn.brianmorrison.me/media/2020/5af29df8-1989-4de6-9b12-fa9dfc484e5d

https://cdn.brianmorrison.me/media/2020/3abbd711-ad6c-4124-a6ec-a1c17d1670d5

Those are only two of the many ways Power-Ups can be used. If you've built something cool, feel free to let me know on Twitter at @brianmmdev!