Use case: we have this situation where we trigger the creation of a trello card but it's linked to an entity in our system. So
e1 <-> card1
We also allow for cards to be created directly in trello and then implicitly create an entity in our system
card2 <-> e2
The problem is we need to inspect the webhook event for the second case, and it also comes back in the first case. So we need to distinguish the two cases.
So ideally, I want to store hidden meta data in the card. But afaik trello does not support this. So I noticed the X-Forwaded-For header is sent and it always has one the trello webhook-source IP addresses . So can I rely on this?
Thanks for any help!
@ali from what I understand you want to create a card in Trello programatically linked to an entity in your system, and allow users to create cards in Trello that will link to an entity in your system, but need to exclude events created when your system programatically creates the cards.
The way I resolve this is by using a "bot user". I created a G-Suite framework called Trellinator:
I use a method like this:
You can see the implementation here:
Basically I just have a shortcut way of excluding things that have been done by the "bot". If you're not using a separate user to do the API calls, then it will be difficult to distinguish between actions taken by the team, and actions taken using a team member's API key programatically.
One option would be that if you're linking to an entity in your system, then you attach the link to the card as an attachment, then when you receive a card creation event after that, check to see if the link already exists on the card back to the entity in your system and if it does, assume that the card creation notification was a result of the card having been programatically created.
Thanks for the suggestions @Iain Dooley ! You are correct in what I want to do. The problem with the bot approach is as you mentioned, the user part. We still want case 1 (so e1 -> card1) to be linked to the user that initiated it from the e1 side (we have a mapping from users in our system to your trello user, so the api request from e1->card1 is done on behalf of the user).
> One option would be that if you're linking to an entity in your system, then you attach the link to the card as an attachment
Can you attach a comment on card creation? Because then this would work! I couldn't see that you could though. So you'd still get the web hook event with no comment in yet right?
@ali you can't post with a comment, but you can create a new card with a link included which will be added to the card as an attachment:
When you receive the notification, query the card to find out if there is a link to the entity in your system (just put your internal entity URL onto the card as an attachment) if the link exists, then this card was created by your system.
Otherwise, you can also post label IDs when creating the card, so you could have a system label like "Bot Created" (with no colour so it doesn't pollute your coloured label space) and likewise you can then query the API when you receive a card created webhook notification to confirm whether or not the card was created programatically or manually
If you had to thrive a new habit during a lockdown, what would it be? Trello
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event