Jump to content
MoritzLost

TrelloWire - Turn your pages into Trello cards

Recommended Posts

TrelloWire

This is a module that allows you to automatically create Trello cards for ProcessWire pages and update them when the pages are updated. This allows you to setup connected workflows. Card properties and change handling behaviour can be customized through the extensive module configuration. Every action the module performs is hookable, so you can modify when and how cards are created as much as you need to. The module also contains an API-component that makes it easy to make requests to the Trello API and build your own connected ProcessWire-Trello workflows.

Features

  • All the things the module can do for you without any custom code:
    • Create a new card on Trello whenever a page is added or published (you can select applicable templates).
    • Configure the target board, target list, name and description for new cards.
    • Add default labels and checklists to the card.
    • Update the card whenever the page is updated (optional).
    • When the status of the card changes (published / unpublished, hidden / unhidden, trashed / restored or deleted), move the card to a different list or archive or delete it (configurable).
  • You can extend this through hooks in many ways:
    • Modifiy when and how cards are created.
    • Modify the card properties (Target board & list, title, description, et c.) before they are sent to Trello.
    • Create your own workflows by utilizing an API helper class with many convenient utility methods to access the Trello API directly.

Feedback & Future Plans

Let me know what you think! In particular:

  • If you find any bugs report them here or on Github, I'll try to fix them.
  • This module was born out of a use-case for a client project where we manage new form submissions through Trello. I'm not sure how many use-cases there are for this module. If you do use it, tell me about it!
  • The Trello API is pretty extensive, I'll try to add some more helper methods to the TrelloWireApi class (let me know if you need anything in particular).
  • I'll think about how the module can support different workflows that include Twig – talk to me if you have a use-case!
  • Next steps could be a dashboard to manage pages that are connected to a Trello card, or a new section in the settings tab to manage the Trello connection. But it depends on whether there is any interest in this 🙂

Links

Module configuration

TrelloWireFullPage.thumb.png.000845648085ad2934da6f34074974e7.png

  • Like 13
  • Thanks 1

Share this post


Link to post
Share on other sites

This sounds great, even though I don't use trello 🙂 A short screencast would be great to get a quick impression 🙂 

  • Like 3

Share this post


Link to post
Share on other sites
28 minutes ago, bernhard said:

This sounds great, even though I don't use trello 🙂 A short screencast would be great to get a quick impression 🙂 

And some background on why you built this would be really interesting too! Looks great!

  • Like 3

Share this post


Link to post
Share on other sites
1 hour ago, bernhard said:

This sounds great, even though I don't use trello 🙂 A short screencast would be great to get a quick impression 🙂 

Thanks! I was hoping the screenshot would do that 😆 Maybe I can give the screencast a go this weekend ... though I'm just now realizing I don't even have a headset any more 😅

1 hour ago, elabx said:

And some background on why you built this would be really interesting too! Looks great!

Lockdown because of Covid-19 mostly 😅

No but really, the README on Github has two examples, and the first one is basically the client project that started this off. This project is a lead generation platform with multiple contact / data collection forms. Our client's team manages all requests on a Trello board. This works really well once everybody is used to it, they use many custom labels and lists to organize all requests / leads. Currently all the new leads are entered manually, but after the relaunch every request will create both a ProcessWire page and a Trello card for the lead. After additional data is entered through one of the forms, the cards are updates with more information and appropriate labels. This is what the status change handling options are for; if the ProcessWire page is trashed, the Trello card can be archived and so on ...

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Oh wow! I discovered Trello just last week (yes, more free time during lockdown...). We were planning to use it as a project management tool for my (non-tech) team to enriched the content of the website (yes, again, lockdown...). Basically, I created some lists : "to do", "done", "added to website". The module will allow me to create the page (unpublished) with an automated checklist (text, image, translations), so people will choose one card, assign to self and work on the subject. When everything will be checked, they will move to "done", until I added the new content to the website (I'm the only one having backend access and I want it stay like this).

So for now, it's working. And I like the fact I could add some automatic text without having to copy manually. Could I ask something? I'm not sure I understand what is wirePopulateStringTags
Do I can use this to pull out the creation date or the child pages?
Can it could be possible to add a trigger on "publishing" a page in status change handling?
And last question. I guess via a hook, I should be able to create a button to automating card creation for existing pages?

Thanks a lot!

Mel

  • Like 1

Share this post


Link to post
Share on other sites

Hi @mel47, I'm happy to hear that!

13 hours ago, mel47 said:

So for now, it's working. And I like the fact I could add some automatic text without having to copy manually. Could I ask something? I'm not sure I understand what is wirePopulateStringTags
Do I can use this to pull out the creation date or the child pages?

Yes, you can! You can use this to output fields from the page to the Trello card. For example, by default the card body contains a link to the page: {httpUrl}, this will be the page's url after parsing. You can use both custom fields as well as system fields. For example:

**Page title: {title}**

Page content:

{body}

Page was created at {created}

This approach is somewhat limited. For example, the {created} placeholder will output the raw timestamp, and as far as I'm aware there's no way to change that to a proper date format. But that's why all methods are hookable. For example, if you want to append the (properly formatted) creation date to the body of all cards (when they are created or updated), you can hook TrelloWireCard::setBody:

<?php
// site/ready.php
namespace ProcessWire;

wire()->addHookBefore('TrelloWireCard::setBody', function (HookEvent $e) {
    $body = $e->arguments(0);
    $card = $e->object;
    if ($card->page) {
        $body .= sprintf("\n\nCreated at: %s", date('Y-m-d', $card->page->created));
        $e->arguments(0, $body);
    }
});

You can hook different methods of TrelloWire or TrelloWireCard depending on when you want to modify the cards, there's a complete list of hookable methods in the README.

 

13 hours ago, mel47 said:

Can it could be possible to add a trigger on "publishing" a page in status change handling?

Currently the only things you can do through the module configuration when a page is published is (1) create a new card for this page or (b) restore the card associated with this page if it was previously archived. It's also possible to update the card whenever the page is saved, though that doesn't differentiate between status changes.

If you want to perform a specific action after a page is published (like, for example, tick one of the checklist items), you can do that through hooks and use the TrelloWireApi class to perform the action through the Trello API. If you need some help with that let me know what you want to do!

Quote

And last question. I guess via a hook, I should be able to create a button to automating card creation for existing pages?

Yes, you can create cards manually in your template files. In that case, I would first deactivate the automatic card creation through the configuration. Then you can create cards manually:

// replace with a check for your button
if ($buttonWasClicked) {
    $TrelloWire = $modules->get('TrelloWire');
    $page = wire('page');
    $card = $TrelloWire->buildCardData($page);
    // dont create cards for pages that are already associated with a card
    if (!$card->id) {
        $TrelloWire->createCardForPage($card, $page);
    }
}

Let me know if it's working for you! Something on my To-Do list for this module is to add some "recipes" for stuff like that 🙂

6 hours ago, bernhard said:

That's the old version of https://processwire.com/api/ref/wire-text-tools/populate-placeholders/ and it does what it says: Populate placeholders in a string with corresponding variables (thx for reminding me about that! 😄 ).

I think both methods are equivalent, wirePopulateStringTags just passes through to the populatePlaceholders method. Some of those methods are really well hidden in the documentation, those are super handy and should definitely be more visible!

  • Like 1

Share this post


Link to post
Share on other sites

Hi

Thanks for the answer. For now, I was able to create the button for existing pages. However I'm stuck with triggering after publishing a page. I want to move to a different list.

I'm there now, but I'm missing the part concerning retrieval of the lists. I tried different things but no success, I'm still learning hooks and API, I don't understand everything... 

$this->pages->addHookAfter('publishReady', function(HookEvent $event) {
    $processor = $event->object; 
    $page = $event->arguments('page');
    
    if($page->template != 'content') return;
    
    $TrelloWire = $processor->wire('modules')->get('TrelloWire');
    $card = $TrelloWire->buildCardData($page);
    
    $TrelloWire->moveCard($card->id, ?????);  
});

Thanks for any help

Mel

Share this post


Link to post
Share on other sites
17 hours ago, mel47 said:

I'm there now, but I'm missing the part concerning retrieval of the lists. I tried different things but no success, I'm still learning hooks and API, I don't understand everything... 

You need to know the ID of the list you want to move the card to. To get all lists of a board, you need to know the ID of that board first. In general, you can check the Trello API docs and perform the query you need using the TrelloWireApi class included in the module.

Take note that all the API methods are defined on the TrelloWireApi class, not TrelloWire itself. So you need to use $TrelloWire->api()->moveCard()!

For this particular case, the TrelloWireApi class has a helper method to retrieve both boards and lists associated with your account:

// get the module and the api helper class
$TrelloWire = wire('modules')->get('TrelloWire');
$TrelloWireApi = $TrelloWire->api();

// this will return an array of boards (with name and id)
$boards = $TrelloWireApi->boards();

// alternatively, you can use the target board defined through the module configuration
$boardId = $TrelloWire->TargetBoard;

// this returns an array of lists on the board
$lists = $TrelloWireApi->lists($boardId);

Once of you have the array of lists, take note of it's ID, this is what you need to move a card to it. You can do this dynamically by searching through the array and search for the correct name or whatever, but I'd just dump the array of lists, grab the ID you need and put it in a constant somewhere 🙂 This also saves an API call each time, and those actually have a noticable impact on performance because of network overhead.

$targetId = 'some-id'; // get this ID from the lists() method above!
$TrelloWireApi->moveCard($card->id, $targetId);

Let me know if something isn't working for you!

  • Thanks 1

Share this post


Link to post
Share on other sites

Thanks! Got it! Put it here if someone needed.

const ADDED_BOARD = '';  //put here the id as previously described by MoritzLost

$this->pages->addHookAfter('publishReady', function(HookEvent $event) {

    $processor = $event->object; 
    $page = $event->arguments('page');

    if($page->template != 'content') return;
    
    $TrelloWire = wire('modules')->get('TrelloWire');
	$TrelloWireApi = $TrelloWire->api();
    
    $card = $TrelloWire->buildCardData($page);
    	
	if ($card->id) {
   			 $TrelloWireApi->moveCard($card->id, ADDED_BOARD);
   			 $page->message($this->_('Moved Trello card to "Added" Board'));
	}
});

Mel

  • Like 1

Share this post


Link to post
Share on other sites

@mel47 Great 🤙 Though I think you have mixed up boards and lists; The method TrelloWireApi::moveCard only moves a card to a different list (within the same or a different board). So your constant ADDED_BOARD should probably be named ADDED_LIST instead to avoid confusion!

Share this post


Link to post
Share on other sites

Oups, too newbie with Trello... but it do what I wanted!

  • Like 1

Share this post


Link to post
Share on other sites

Hello @MoritzLost

Found a bug. If you let empty "body" in config, I get this error. Put any text and problem solved.
Except that, everything working fine so far!
Thanks.

image.thumb.png.3c771e518d12cd5275c35a1398764f42.png

Share this post


Link to post
Share on other sites

@mel47 Thanks for the report! I have just pushed a fix for the issue in release 1.0.1. The title and body arguments to TrelloWireApi::createCard() are now nullable, and the body defaults to an empty string if not set. This also means that the Hook for TrelloWireCard::setBody now gets called even if the body is empty, which it wouldn't previously. I have also added a Changelog.

Let me know if you find any more bugs!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
    • By daniels
      This is a lightweight alternative to other newsletter & newsletter-subscription modules.
      You can find the Module in the Modules directory and on Github
      It can subscribe, update, unsubscribe & delete a user in a list in Mailchimp with MailChimp API 3.0. It does not provide any forms or validation, so you can feel free to use your own. To protect your users, it does not save any user data in logs or sends them to an admin.
      This module fits your needs if you...
      ...use Mailchimp as your newsletter / email-automation tool ...want to let users subscribe to your newsletter on your website ...want to use your own form, validation and messages (with or without the wire forms) ...don't want any personal user data saved in any way in your ProcessWire environment (cf. EU data regulation terms) ...like to subscribe, update, unsubscribe or delete users to/from different lists ...like the Mailchimp UI for creating / sending / reviewing email campaigns *I have only tested it with PHP 7.x so far, so use on owners risk
      EDIT:
      Since 0.0.4, instructions and changelog can be found in the README only. You can find it here  🙂
      If you have questions or like to contribute, just post a reply or create an issue or pr on github, thanks!
    • By MoritzLost
      Sorry for the convoluted title. I have a problem with Process modules that define a custom page using the page key through getModuleInfo (as demonstrated in this excellent tutorial by @bernhard). Those pages are created automatically when the module is installed. The problem is that the title of the page only gets set in the current language. That's not a problem if the current language (language of the superuser who is installing the module) is the default language; if it isn't, the Process page is missing a title in the default language. This has the very awkward effect that a user using the backend in the default language (or any other language) will see an empty entry in the setup menu:

      This screenshot comes from my Cache Control module which includes a Process page. Now I realize the description sounds obscure, but for us it's a common setup: We a multiple bilingual sites where the default language is German and the second language is English. While the clients use the CMS in German, as a developer I prefer the English interface, so whenever I install a Process module I get this problem.
      As a module author, is there a way to handle this situation? I guess it would be possible to use post-installation hooks or create the pages manually, but I very much prefer the declarative approach. The page title is already translatable (through the __ function), but of course at the time of installation there is no translation, and as far as I'm aware it's not possible to ship translations with a module so they are used automatically. Could this situation be handled better in the core? I would prefer if the module installation process would always set the title of the Process page in the default language, instead of the language of the current user.
×
×
  • Create New...