Can I define custom ingredients for an IFTTT applet triggered by Webhook?

711 Views Asked by At

I am writing an IFTTT applet that has a webhook with JSON payload as the trigger. In the filter code, I can parse the JSON and get any of the data out of it that I want. In my mapped action, however, I can only use the ingredients that came from the original trigger: EventName, JsonPayload, and OccurredAt.

Ideally I'd like to create new ingredients in the Filter code and have them available in the action template. Is this possible?

I have tried the following as filter code but neither the customer type nor the associated object of that type appear in the action template.

let payload = JSON.parse(MakerWebhooks.jsonEvent.JsonPayload)

// Payload looks like this:
// {
//   "dataSource": "Enphase",
//   "systemName": "My House",
//   "periodStart": "2022-05-05T00:00:00-04:00",
//   "periodEnd": "2022-05-05T23:59:59.999999999-04:00",
//   "periodEndDate": "05/05/2022",
//   "energyProduced": 99999 
// }

type SolarStatsEvent = {
   dataSource: string;
   systemName: string;
   periodStart: string;
   periodEnd: string;
   periodEndDate: string;
   energyProduced: number;
};

function fromJson(payload: any) : SolarStatsEvent {
   let newEvent: SolarStatsEvent = {
      dataSource: payload.dataSource,
      systemName: payload.systemName,
      periodStart: payload.periodStart,
      periodEnd: payload.periodEnd,
      periodEndDate: payload.periodEndDate,
      energyProduced: payload.energyProduced
   }
   return newEvent;
}

let solarStats = fromJson(payload);

NOTE: This has been asked before but not at a time when IFTTT had the filter capability. See IFTTT webhook to google sheets.

0

There are 0 best solutions below