This topic was automatically generated from Slack. You can find the original thread here.
I am creating a workflow that whenever a new Google calendar event was added to a calendar it will automatically create a Notion page on a database. But, I need to filter recurring events that will be added to the calendar, I don’t need to add recurring events to the notion database. What steps to I need to take to make the workflow.
To create a workflow that adds a new Google Calendar event to a Notion database, while filtering out recurring events, follow these steps: ### Step 1: Set Up the Trigger 1. Google Calendar Trigger: - In the Pipedream UI, search for the Google Calendar app. - Select the New Event Created trigger. - Connect your Google Calendar account. - Choose the calendar you want to monitor. ### Step 2: Filter Out Recurring Events 1. Filter Step: - Add a new step using the Filter app. - Use the condition to check if the event is a recurring event. Google Calendar events have a property called recurrence. If this property exists, the event is recurring. - Set the condition to proceed only if recurrence is not present. Here’s an example of how you might set up the filter condition in a code step: ```
export default defineComponent({ async run({ steps, $ }) { const event = steps.trigger.event; if (event.recurrence) { $.flow.exit(“This is a recurring event, exiting workflow.”); } }, });
To convert a date and time to Pacific Standard Time (PST) in a Pipedream workflow, you can use a Node.js code step. Here’s an example of how you can achieve this using the date-fns-tz library, which provides utilities for time zone conversions: import { zonedTimeToUtc, utcToZonedTime, format } from 'date-fns-tz'; export default defineComponent({ async run({ steps, $ }) { // Example date and time in ISO format const date = '2023-10-01T12:00:00Z'; // UTC time // Convert the date to Pacific Standard Time const timeZone = 'America/Los_Angeles'; const zonedDate = utcToZonedTime(date, timeZone); // Format the date in a readable format const pattern = 'yyyy-MM-dd HH:mm:ssXXX'; const output = format(zonedDate, pattern, { timeZone }); return output; // Returns the date and time in PST }, }); ### Explanation: 1. Import the necessary functions: We use zonedTimeToUtc, utcToZonedTime, and format from the date-fns-tz library. 2. Specify the date and time: Replace '2023-10-01T12:00:00Z' with your date and time in ISO format. 3. Convert to PST: Use utcToZonedTime to convert the UTC date to Pacific Standard Time. 4. Format the date: Use format to format the date in a human-readable format. 5. Return the result: The converted date and time in PST is returned. You can add this code to a Node.js code step in your Pipedream workflow. If you need further assistance, feel free to ask!