Does anyone have a current script that is parsing any emails beiing received in the new “trigger when email received”. I am trying to parse the body, but I cannot figure out the inputs from the email received.
I get errors on all of the inputs. My reason for the inputs, is that the receivedDate didn’t work.
// Get inputs from the automation
let inputConfig = input.config();
let subject = inputConfig.subject;
let body = inputConfig.body;
let receivedDateRaw = inputConfig.receivedDate;
// Optional: log inputs (for testing)
console.log("Raw receivedDate:", receivedDateRaw);
console.log("Subject:", subject);
console.log("Body:", body);
// Parse date string into Date object
let receivedDate = new Date(receivedDateRaw);
// ✅ Function to get the next Tuesday
function getNextTuesday(date) {
let day = date.getDay(); // Sunday = 0, Monday = 1, ..., Saturday = 6
let daysUntilTuesday = (9 - day) % 7;
if (daysUntilTuesday === 0) daysUntilTuesday = 7;
let nextTuesday = new Date(date);
nextTuesday.setDate(date.getDate() + daysUntilTuesday);
// Format as YYYY-MM-DD
return nextTuesday.toISOString().split("T")[0];
}
// ✅ Function to extract body up to signature
function extractMessageBody(text) {
let endIndex = text.indexOf("Jason Hill");
if (endIndex !== -1) {
return text.substring(0, endIndex).trim();
} else {
return text.trim();
}
}
// Final processed fields
let DateValue = getNextTuesday(receivedDate);
let Title = subject;
let Item = extractMessageBody(body);
// Output variables for next automation steps
output.set("Date", DateValue);
output.set("Title", Title);
output.set("Item", Item);


