Hey Manan, I found a way to trigger script from webhook action.
It’s by Deploying it as a web app.
Let’s have a look at the code of the WhatsApp Message trigger.
function doGet(e) {
return ContentService.createTextOutput("This is a GET Request!");
}
function doPost(e) {
var body = JSON.parse(e.postData.contents);
Logger.log(body);
var name = body["params"]["Name"]["value"];
var message1 = body["params"]["Message"]["value"];
var number = body["params"]["Number"]["value"];
var payload = {
"username": "YOUR_USERNAME",
"password": "YOUR_PASSWORD",
"receiverMobileNo": number,
"receiverName": name,
"message": message1,
// "message": message2,
// "filePathUrl":image,
}
var options = {
'method': 'post',
'payload': payload
// 'contentType': 'multipart/form-data',
};
var url = "https://app.messageautosender.com/message/new";
var response = UrlFetchApp.fetch(url, options);
}
After Saving this file, click on Deploy (Blue Button on right side of the script window)
Then, Add deployment as a web app,
Change Access to anyone, and tap deploy.
Copy URL and paste it to Webhook Action on Glide.
That means It’ll trigger this web app URL when clicked.
Important: You’ve to deploy every time when you change the code snippets.
Paste any kinda function to doPost() function, you can trigger that from the glide app.