Google Forms
Give KIN to respondents by triggering an invoice when a form is submitted
Create a Promotion Token
Steps:
Create a promotion
Copy a promotion token and keep it safe. Use it in place of
XXXXXXXX
in the script below.

Open the Form Script Editor

Add a "OnSubmit" function
Copy/paste the following function to the code section. This code should run when the form is submitted.
var POST_URL = "https://perk.exchange/api/perks";
var CAMPAIGN_SECRET = 'XXXXXXXX'
function onSubmit(e) {
var form = FormApp.getActiveForm();
var allResponses = form.getResponses();
var latestResponse = allResponses[allResponses.length - 1];
var response = latestResponse.getItemResponses();
var userEmail = latestResponse.getRespondentEmail()
var payload = {"user_id": userEmail, "platform": "email", "url": "https://perk.exchange"};
var options = {
headers:{
"x-perk-token": CAMPAIGN_SECRET
},
"method": "post",
"contentType": "application/json",
"payload": JSON.stringify(payload)
};
UrlFetchApp.fetch(POST_URL, options);
};
Last updated
Was this helpful?