Trigger App Script via make.com

What are you trying to achieve?

Hi!, I want to run my App Script via make.com. I have data on a sheet, but i want to run it via make.com so it will proceed next steps in workflow. How can I do that?

Hi @Piotr_Jablonski, You’ll have to Deploy your AppScript as a webapp.

Then you’ll get the link after deployment. That’s your ‘webhook’ to send HTTP POST request to :

One of functions I call in my appscript looks like this :

function doPost(e) {
  // Parse the incoming parameters or data
  var action = e.parameter.action; // Get the 'action' from the webhook
  var type_vehicule = e.parameter.type_vehicule; // Get 'type_vehicule' from the webhook
  var nom_vehicule = e.parameter.nom_vehicule; // Get 'nom_vehicule' from the webhook
  var result;
  
  // Route the request based on the "action" parameter
  if (action === "majPlanning") {
    result = majPlanning(type_vehicule,nom_vehicule); // Call insertVehicle function with the passed type_vehicule
  } else if (action === "majFormulaires") {
    result = majFormulaires();
  } else {
    result = "Unknown action";
  }
  
  // Return the result
  return ContentService.createTextOutput(result);
}

The HTTP POST request module looks like this :

Mention me if you need more help.

2 Likes

Unfortunately, i have error (it seems that there is problem with permission). Claude and GPT is not helping :frowning: Do you have any idea what should i check? When i made new deployment, i changed:
“Execute as” to Me
“Who has access” to Anyone




Do you have any idea what goes wrong?

@Piotr_Jablonski, Try setting body type = empty? Did you deploy as a web app ? I just repeated the process and it worked, I don’t think there’s any more to it. Me and Anyone are good.

i tried with body type = empty. Yeah, i deployed as a web app. Still the same error.

@Piotr_Jablonski, Did you try executing the script inside apps script ? You might not have authorized the app first. You know, when you launch any script for the first time. That’s my last resort. Lol

Script is working (it was my first guess :smiley: ). Also, i tried with with GET, to check if URL is working (it is…)


@Piotr_Jablonski, How did you launch the script ? With post request or manually in apps script ? I’m talking about the authorization window you’re getting when launching the script manually. Maybe I misunderstood your reply and maybe you already authorized.

Can you try sending a post request from Postman to test the webhook link ?

sure i can, i lunch the script manually in app script. In Postman there is the same error (401 Unauthorized)

@Piotr_Jablonski, Wait… can you remove try-catch ? The error might be from the analyzeBookingPlatforms() function… what does the function do, does it call more APIs after ?

analyzeBookingPlatforms() is my main function which i want to run.

@Piotr_Jablonski, I’m pretty sure the error comes from the function analyzeBookingPlatforms(). You can know this by going in ‘Executions’ on your left sidebar in apps script. Your doPost() request may execute successfully, but maybe there’s 401 error in your analyzebookingplatforms() request (assuming it’s calling some other API which you don’t have correct auth token).

2 Likes

I changed code, it is working. Thank you !!!

2 Likes