Dheeraj Bhaskar
Dheeraj Bhaskar

Reputation: 19049

Using parse.com to receive Trello webhooks

1. Goal

I want to use parse.com to receive Trello webhook.

1a. Why?: Because I want to monitor my trello model and receive say a push notification on my android device and do neat things from the push notficiation (I'm an Android Dev)

2. What I've tried

2a. Setup on parse.com

  1. I've created an app on parse.com
  2. Obtained the keys (REST keys for the REST api)
  3. Checked the above endpoint with Postman, works perfectly.

2b. Setup on trello.com

  1. I've obtained an api appkey and secret; with full write on all boards, never expires
  2. Tested the above with Postman, works perfectly fine.
  3. PROBLEM: Posted to the following using Postman (of course with proper details for key, token, model, etc.

Request=

$.post("https://trello.com/1/tokens/[USER_TOKEN]/webhooks/?key=[APPLICATION_KEY]", {
  description: "My first webhook",
  callbackURL: "https://api.parse.com/1/functions/webhookReceiverTrello",
  idModel: "4d5ea62fd76aa1136000000c",
});

Response Try=

URL (https://api.parse.com/1/functions/webhookReceiverTrello) did not return 200 status code, got 401

3. What is the problem?

Parse.com expects auth keys, etc as header. AFAIK Trello can NOT DO that.

How do I get a trello webhook to call a parse.com cloud function ?

Upvotes: 1

Views: 374

Answers (1)

Dheeraj Bhaskar
Dheeraj Bhaskar

Reputation: 19049

Use a proxy (a simple web app will do)

This is how I did it:

Receive the webhook on a simple web app and make the necessary post call to parse.com

  • I used heroku for hosting
  • I used MeteorJS for the web app

Note: An issue you could encounter:

  • Trello.com sends calls to webhooks in proper order i.e. a card was created, the same card was updated, etc.

  • When you receive the webhook and make (proper) post calls, they will be received out of order at parse.com i.e. a card was updated and then it was created. This is just due to the way internet works, if you need an explanation, it's another SO question. ;)

This took me a while to figure out; mentioning so that you don't also spend your time with this.

A Fix: I don't know a simple/efficient way to fix this. Please let me know if you do. One possible solution is to queue all POST calls i.e. make POST call 1 and when a successful callback is gotten do the next one. Trello.com seems to do this in a more quicker fashion, it doesn't seem like they wait for a callback given how quick successive calls are received.

Upvotes: 0

Related Questions