Trigger google calendar event x hours before

Hi,

I’m trying to set up a bot that sends a tweet, 3 hours before an event from google calendar starts.

Currently I’m doing this with Zapier but I want to do more things and that’s why I’m trying pipedream.

For example, this is what I have with Zapier:

The problem is with the timer, that no matter what I do, is not triggering any event from google calendar.

I tried, changing the timer to every hour, minute, second, etc. without luck.

My question is, how do I fix it? And how does timer exactly works? Because if I set the timer every hour but an event starts, for example at 19:15, is not going to trigger, right?

(As I’m a new user I can only post one image)

@esdevenimentscardedeu Thanks for reaching out. Could you click the Share button at the top-right of your workflow and share it with dylan@pipedream.com? I’d like to take a look at the configuration.

@esdevenimentscardedeu Thanks. Currently this event source checks for when an event’s start time has passed. If you want to check for events starting within N hours, you can modify the event source’s code by clicking on the edit code and configuration link in the trigger step. Are you familiar with Node.js code?

Hi Dylan!

Thanks for the answer. Yes, I’m familiar. What are your approach?

Thanks

Right now the code only looks for event start times in the future based on the scheduled configuration. e.g. if you’re running the event source every 5 minutes to poll for new events starting, we’ll only look 5 minutes in the future.

You can modify that section to look for events N hours in the future, for example:

const intervalMs = 1000 * 60 * 60 * 3 // 3 hours

Hi,

Ok, understood. So one last question, this code you provided, will look for an events that start 3 hours in the future, right? But, it will only look for events that starts on o’clock? If for example I have events that start at 9:15, 10:30 or 11:45 it will also work?

What do you think?

Best

It will actually look for any event that starts within 3 hours. So if you’re running the source every 15 minutes, it will run like so:

  • 0:00 (midnight) → looks for any event that starts between 0:00 and 3:00
  • 0:15 → looks for any event that starts between 0:15 and 3:15
  • etc.

Does that help?

Hi, kind of, but I want to be sure that I’m doing it correctly.

So, I have changed the code with what you suggested and it triggered 2 of 3 events on my calendar. The last one I had to do it manually.

I think that it was because the last event didn’t started at o’clock:

So, my question is, how do I set up the trigger to fire every event regardless of whether it starts with a period, and a quarter, and a half, etc? And that it does not consume too much.

image.png

(I can’t post more than one image :frowning: )

Thanks for all your help by the way.

So I believe you’ll just need to adjust your forward-looking interval a little longer to capture the events that you want.

In this example, where we’re looking 3 hours in the future:

0:00 (midnight) → looks for any event that starts between 0:00 and 3:00

You will find events that start at any time between 0:00 and 3:00. For example, you’d find events that start at 1:15, 2:30, etc.

If you’re not finding the events you need, do you simply need to extend the forward-looking interval to 4 (for example)? That way, you’d capture events further in the future. For example, the run at 0:00 would look for any event that starts between 0:00 and 4:00. This would capture any events the start, at any time, between 0:00 and 4:00. For example, you’d capture events that start at 0:15, 1:27, 2:45, 3:20, etc.

Does that help?

So, what I want is to send a tweet 3 hours before an event start. This is the code that fix that, thanks to you:

const intervalMs = 1000 * 60 * 60 * 3 // 3 hours

I think that the problem was that I needed to set the timer at 15 minutes (it was at every hour) so it will check, for example, at 9:00, at 11:45, at 14:15 and at 20:30.

image

Is this the correct way to do it? Is there a way to reduce the amount of invocations?

Thanks

In this model, where we poll Google Calendar for new events, this is the best way. And if you want this accuracy - trying to get tweets sent 3 hours before the event, as close to the event time as possible - it’s necessary to run the source at this frequency.

In the future we can provide a trigger that simplifies this case and fires an event at the start of an event, and doesn’t require polling. I’ll add that to our backlog.

Ok, Thank you very much for all the help you provided.

Hi @dylburger , do you provide the trigger that simplifies this case and fires an event at the start of an event, and doesn’t require polling?