Skip to main content

gcal.googlecalendar.onnewevents

Home > @runlightyear/gcal > GoogleCalendar > onNewEvents

GoogleCalendar.onNewEvents() method

This API is in beta and may contain contain bugs. Can be used in production with caution.

On new events

Signature:
static onNewEvents(props: OnNewEventsProps): {
webhook: string;
action: string;
};

Parameters

ParameterTypeDescription
propsOnNewEventsProps
Returns:

{ webhook: string; action: string; }

Example 1

On new events

import { GoogleCalendar } from "@runlightyear/gcal";

GoogleCalendar.onNewEvents({
name: "onNewEvents",
title: "On New Events",
run: async ({ data }) => {
console.info("New events", data);
},
});

Example 2

On new events with matching title

import { GoogleCalendar } from "@runlightyear/gcal";
import { SKIPPED } from "@runlightyear/lightyear";

GoogleCalendar.onNewEvents({
name: "onNewMatchingEvents",
title: "On New Matching Events",
variables: [
{ name: "term", description: "Event title must contain this term" },
],
run: async ({ data, variables }) => {
const testEvents = data.filter((event) =>
event.summary.includes(variables.term!)
);

if (testEvents.length === 0) {
throw SKIPPED;
}

console.log(`New events matching ${variables.term!}:`, testEvents);
},
});