Hey @Maarten,
Not sure if you still need help, but I’m posting a solution here for future reference.
This is the general flow you’ll need:
I’m assuming most steps are pretty straightforward, but if you need help with this, let me know.
The code step is used to parse data from the email.
Change the emailContent variable to match your email’s content. You may need to tweak the code to fit your exact email content, but this example should guide you.
Here’s the code I used:
exports.code = async function code(inputs) {
const emailContent = inputs.emailContent;
const extractInformation = (key, content) => {
const regex = new RegExp(`${key}:\\s*(.*?)\\s*(?=\\n|$)`, 's');
const match = content.match(regex);
return match ? match[1].trim() : null;
};
return {
name: extractInformation('Name', emailContent),
email: extractInformation('Email', emailContent),
phone: extractInformation('Phone', emailContent),
company: extractInformation('Company', emailContent),
industry: extractInformation('Industry', emailContent),
stateProvince: extractInformation('State/Province', emailContent),
country: extractInformation('Country', emailContent),
activationDate: extractInformation('Activation Date', emailContent),
activationEndDate: extractInformation('Activation End Date', emailContent)
};
};
This script will output a JSON object like this, which can be used in subsequent steps:
{
"name": "Sjaak Henk",
"email": "Sjaak@henk.com",
"phone": "0031505050505",
"company": "Henk.com",
"industry": "Architecture",
"stateProvince": "Utrecht",
"country": "NL",
"activationDate": "10-15-10",
"activationEndDate": "17-15-10"
}