How can I break up an event snippet into different columns in Google Sheets using the Gmail app as a trigger?

I get this error: Code Error
SyntaxError: The requested module ‘@U014LD91C7Q/platform’ does not provide an export named ‘cheerio’

I apologize for the confusion. It seems I made a mistake in my previous response. Pipedream does not provide an export named cheerio. Instead, you can use the html-to-text package to extract the text from the HTML content. Here’s an updated version of the code using html-to-text: import { htmlToText } from "html-to-text"; export default defineComponent({ async run({ steps }) { const htmlContent = steps.trigger.event.htmlContent; if (!htmlContent) { console.error("HTML content is undefined or missing"); return; } const textContent = htmlToText(htmlContent, { wordwrap: false }); const name = textContent.match(/Name:\s**(.**)/)?.[1]?.trim(); const email = textContent.match(/Email:\s**(.**)/)?.[1]?.trim(); const phone = textContent.match(/Phone Number:\s**(.**)/)?.[1]?.trim(); const owned_dog = textContent.match(/Have you ever owned a dog\?:\s**(.**)/)?.[1]?.trim(); const male_female = textContent.match(/Do you prefer a male or female puppy\?:\s**(.**)/)?.[1]?.trim(); const walk = textContent.match(/Are you willing to walk with the dog regularly\?:\s**(.**)/)?.[1]?.trim(); if (!name || !email || !phone || !owned_dog || !male_female || !walk) { console.error("One or more values are missing or undefined"); return; } return { name, email, phone, owned_dog, male_female, walk }; }, }); This code uses the html-to-text package to convert the HTML content to plain text, and then it uses regular expressions to extract the desired information.

I get a log: One or more values are missing or undefined

I apologize for the inconvenience. It seems that the regular expressions used in the code might not be matching the content correctly. To help you better, could you please provide a sample of the text content you’re trying to extract the information from? This will help me adjust the code to match the content accurately.

I understand you want to extract information from the provided HTML content. Let’s use the html-to-text package to convert the HTML content to plain text and then extract the desired information using regular expressions. Here’s the code: import { htmlToText } from "html-to-text"; export default defineComponent({ async run({ steps }) { const htmlContent = ` <!-- Your HTML content here --> `; if (!htmlContent) { console.error("HTML content is undefined or missing"); return; } const textContent = htmlToText(htmlContent, { wordwrap: false }); const allergies = textContent.match(/Does anyone in your immediate family have allergies to dogs\?\s**(.**)/)?.[1]?.trim(); const costsAware = textContent.match(/Are you aware of the costs associated with keeping a dog\?\s**(.**)/)?.[1]?.trim(); if (!allergies || !costsAware) { console.error("One or more values are missing or undefined"); return; } return { allergies, costsAware }; }, }); Replace <!-- Your HTML content here --> with the actual HTML content you provided. This code will convert the HTML content to plain text and then use regular expressions to extract the information about allergies and awareness of dog-related costs.

It worked!! Thank you!

You’re welcome! I’m glad it worked for you. If you have any more questions or need further assistance, feel free to ask. Happy coding!

I’d like to clean up the value of steps.trigger.event.payload.headers[1].value
in node js
From this value: “by 2002:a17:906:4a8d:b0:997:df32:7ebf with SMTP id x13csp1000253eju; Wed, 23 Aug 2023 21:15:25 -0700 (PDT)”
To this value: “Aug 23, 2023"

I’m glad you provided the input and desired output values. You can use a regular expression to extract the date from the given string and format it as required. Here’s a code snippet that you can use in a Pipedream code step: ```
export default defineComponent({ async run({ steps }) { const headerValue = steps.trigger.event.payload.headers[1].value; const dateMatch = headerValue.match(/\w{3}, (\d{1,2} \w{3} \d{4})/); if (dateMatch) { const formattedDate = dateMatch[1]; return { formattedDate }; } else { console.error(“Date not found in the header value”); } }, });

It worked! Thank you!
What if I wanted to change the date format to “10/14/2022”

I’m glad it worked for you! To change the date format to “MM/DD/YYYY”, you can use the moment library. Here’s the updated code: import moment from "moment"; export default defineComponent({ async run({ steps }) { const headerValue = steps.trigger.event.payload.headers[1].value; const dateMatch = headerValue.match(/\w{3}, (\d{1,2} \w{3} \d{4})/); if (dateMatch) { const originalDate = moment(dateMatch[1], "DD MMM YYYY"); const formattedDate = originalDate.format("MM/DD/YYYY"); return { formattedDate }; } else { console.error("Date not found in the header value"); } }, }); This code imports the moment library, parses the original date using the “DD MMM YYYY” format, and then formats it to “MM/DD/YYYY”.