diff --git a/apps/webapp/app/components/samples/custom-event.ts b/apps/webapp/app/components/samples/custom-event.ts index 2c4d627c2..d979202ac 100644 --- a/apps/webapp/app/components/samples/custom-event.ts +++ b/apps/webapp/app/components/samples/custom-event.ts @@ -12,6 +12,7 @@ new Trigger({ name: "user.created", //todo define the schema for the events you want to receive //this example accepts JSON like this: { id: "123", admin: false } + //you can use z.any() to accept any data, but you won't get payload validation or type inference in run() schema: z.object({ id: z.string(), admin: z.boolean() }), //todo define or remove the filter //filters are optional, but can be used to filter out events diff --git a/apps/webapp/app/components/samples/scheduled-cron.ts b/apps/webapp/app/components/samples/scheduled-cron.ts index 43022f7aa..7aa2c4e3f 100644 --- a/apps/webapp/app/components/samples/scheduled-cron.ts +++ b/apps/webapp/app/components/samples/scheduled-cron.ts @@ -7,8 +7,13 @@ new Trigger({ // For security, we recommend moving this api key to your .env / secrets file. // Our env variable is called TRIGGER_API_KEY apiKey: "${apiKey}", + //todo set your CRON expression here + //this example runs every Monday at 2:30pm UTC + //this site is useful when writing CRON: https://crontab.guru + //you don't have to wait to test, use our "Test" button on your workflow page on: scheduleEvent({ cron: "30 14 * * 1" }), run: async (event, ctx) => { + //this function is run every Monday at 2:30pm UTC await ctx.logger.info("Received the cron scheduled event", { event, wallTime: new Date(), diff --git a/apps/webapp/app/components/samples/scheduled.ts b/apps/webapp/app/components/samples/scheduled.ts index 12ac0d3f9..7ac9fe8d4 100644 --- a/apps/webapp/app/components/samples/scheduled.ts +++ b/apps/webapp/app/components/samples/scheduled.ts @@ -7,8 +7,12 @@ new Trigger({ // For security, we recommend moving this api key to your .env / secrets file. // Our env variable is called TRIGGER_API_KEY apiKey: "${apiKey}", + //todo set how often you want your event to fire here + //this example runs every 5 minutes, the first run will be 5 minutes after the workflow is first connected + //you don't have to wait to test, use our "Test" button on your workflow page on: scheduleEvent({ rateOf: { minutes: 5 } }), run: async (event, ctx) => { + //this function is run every 5 minutes await ctx.logger.info("Received the scheduled event", { event, wallTime: new Date(), diff --git a/apps/webapp/app/components/samples/shopify-create-new-product.ts b/apps/webapp/app/components/samples/shopify-create-new-product.ts index e225d4574..fe9ce5470 100644 --- a/apps/webapp/app/components/samples/shopify-create-new-product.ts +++ b/apps/webapp/app/components/samples/shopify-create-new-product.ts @@ -9,6 +9,9 @@ new Trigger({ // For security, we recommend moving this api key to your .env / secrets file. // Our env variable is called TRIGGER_API_KEY apiKey: "${apiKey}", + //todo define the schema for the events you want to receive + //this example accepts an empty JSON object: {} + //you can use z.any() to accept any JSON, but you won't get nice types in the run function on: customEvent({ name: "shopify.products", schema: z.object({}),