N8N Email Reply Automation

In this section are the code steps for the e-mail reply automation

Code:

// Get the raw "From" value from Gmail trigger

const rawFrom = $json["From"] || "";

// Extract email using regex

const match = rawFrom.match(/([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})/);

// Return cleaned email if found

return [

{

json: {

cleanEmail: match ? match[1] : null,

originalFrom: rawFrom

}

}

];

Code1:

var rows = $items("Get row(s) in sheet");

if (!rows || rows.length === 0 || Object.keys(rows[0].json).length === 0) {

return [{ json: { proceed: true } }];

} else {

return [{ json: { proceed: false } }];

}