IFTTT Platform

IFTTT Platform allows you to create and publish applets, so you can share it with the others. Also it allows to put script that will execute after getting triggered. So you can modify output data and skip actions using TypeScript/JavaScript.

Example

// Building JSON body
const body = {
  embeds: [{
    author: {
      name: Trigger.UserName, // equals {{UserName}}
      url: Trigger.LinkToTweet // equals {{LinkToTweet}}
    },
    description: `*${Trigger.Text}*`, // equals *{{Text}}*
    color: 0x1da1f2, // equals 1942002 (hex ➤ decimal value)
    timestamp: Meta.triggerTime // equals YYYY-MM-DDThh:mm:ss.msZ (discord compatible timestamp)
  }]
};

// If you want to manually skip some triggers when some of ingredients match/not match something or allow to run only at certain time you can do this:
if (Trigger.Text.indexOf('skip') > 0) {
  MakerWebhooks.makeWebRequest.skip('this reason will appear in activity logs!');
}

// This action makes Web Request and sends webhook
MakerWebhooks.makeWebRequest.setBody(JSON.stringify(body));
// Done!

TS/JS cheat sheet

//== in ts/js quotes around keys can be omitted
let body = {"content": "text"};
// equals
let body = {content: "text"};
//== the difference between single and double quotes that you need to escape it between them own
let text = ['what\'s up?', "*\"winks\"*"];
// equals
let text = ["what's up?", '*"winks"*'];
//== if you want to add value inside string use *template literals*: ` ` with ${}
let message = 'hello, ' + name + '!';
// equals
let message = `hello, ${name}!`;
//== if variable is a string there's no need to use template literals
let zzz = `${ccc}`;
// equals
let zzz = ccc; // if variable is not string but it should be call ccc.toString() on it!
//== var/let/const
if ('variable'.might_be_reassigned) {
  use('let');
} else if ('variable'.assigned_only_once) {
  use('const');
} else if (not_sure()) {
  use('var');
}
//== check if string includes substring
let string = 'The quick brown fox jumps over the lazy dog';
let substring = 'fox';
let substring2 = 'cat';
let result = string.indexOf(substring) > -1; // equals true
let result2 = string.indexOf(substring2) > -1; // equals false
// explanation: IFTTT doesn't allow to use string.includes(substring) method
// so we have to use string.indexOf(substring) > -1 instead,
// which returns coordinates of substring and -1 if not found.
// > -1 is in range [0..+inf), >= 0 will work the same way
//== random value
let random = Math.random(); // returns float value in range [0..1) (1 excluded)
let random2 = Math.round(Math.random()); // returns 0 or 1
let random3 = Math.floor(Math.random() * 10); // returns integer value in range [0..9] (10 excluded)
let random4 = Math.floor(5 + Math.random() * 45); // returns integer value in range [5..49] (50 excluded)
//== random element in array
let arr = ['one', 'two', 'three', 'four'];
let picked = arr[Math.floor(Math.random() * arr.length)];