Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,467,924
Community Members
 
Community Events
177
Community Groups

Receive a webhook using trellinator

I have been trying to Receive a shopify webhook to my trellinator google app script. In my research I have found out that my code should run on doPost function and then send a 200 OK response.

I have performed some tests and my code is running fine, but the webhook keeps triggering as if it did not received the 200 OK response.

I know that trellinator uses doPost function to execute some code, and I do not know how to receive my webhook on top of trellinator platform. 

Below you can find the doPost function I am taltking about

function doPost(e)
{
var hooks = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Custom Webhooks");
var htmlOut = false;

//Here is were I execute my function
myFunction(e);

//My function ends
if(hooks)
{
new IterableCollection(hooks.getDataRange().getValues()).each(function(row)
{
if(this[row[0].trim()] &&(htmlOut === false))
{
htmlOut = this[row[0].trim()](e);
}
});
}

if(htmlOut === false)
{
if(e.postData)
{
var notifText = e.postData.contents;
var htmlOut = doPosting(notifText);
}

else
{
var htmlOut = HtmlService.createHtmlOutput("<p>Processed Notification</p>");
}
}

else
{
var htmlOut = HtmlService.createHtmlOutput("<p>Processed Notification</p>");
flushInfoBuffer();
}
return htmlOut;

}

1 answer

@Carlos Pozos Ochoa I'll reply here as well as in Reddit :)

Note that you shouldn't ever need to edit any of the Trellinator files.

This is an undocumented feature, but just create a sheet in your Trellinator spreadsheet called "Custom Webhooks" then put your function names in the first column, no header column. So in your case you would just enter

myFunction

into cell A1.

These functions will be called before the Trellinator notification processor, if you return "true" from your function, processing will stop, that is the notification will not proceed to be passed into your Trellinator functions.

If you return "false" then the notification will be passed onto your Trellinator functions. So an example of a custom webhook might be something like this:

https://gist.github.com/iaindooley/c344cc62c08858736ce18e8cf920c44e

 

Thank you Iain, I have tested the code you propose and it is executed right. The problem is that I should reply shopify in a 5 second window with the 200 OK response, but looking at my logs "myFunction" is taking longer than that time to reply, so the webhook is firing continously. Is there anyway I can add my function to your trellinator queue? So this way I can anwer inmediately to shopify and let my funciton execute later.

Iain Dooley Community Leader Jun 08, 2021

@Carlos Pozos Ochoa yep just use the same URL that is set up for all your other boards. You can see by running this piece of code:

https://gist.github.com/iaindooley/ee64dd680d1991ede55aa5cb7ef843bd

just grab your token from the Configuration tab and put it in there. You can use that webhook directly the same as you would use the published script URL, it just queues the requests and forwards them onto the script anyway

Like Carlos Pozos Ochoa likes this

Awesome, it worked perfectly. Thank you very much for all your work and the knowledge you share. 

Like Iain Dooley likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events