Build Your Own AI Team
Lesson 7

It runs without you

What you walk away with
An agent that works while you are with a client. You stop visiting it, and it starts arriving.
Time
About twenty minutes, and most of that goes on deciding what time you want it.
Cost
Nothing new. The same cents per run you were already paying.

This is the shortest lesson in the course and the one that changes what you have. Up to now your agent is a very capable thing you have to remember to go and use, which makes it a tool. After today it produces its work before you open your laptop, which makes it an agent.

The one idea

A cron trigger is a schedule Cloudflare keeps for you. At the time you name, it wakes your worker up and runs the job, whether or not your laptop is open and whether or not you remembered.

Your worker already has the code for this. It has been sitting in the template since lesson 5, waiting for a schedule to exist.

Check the job before you schedule it

A schedule only wakes your agent up. When it wakes, all it has is its job and whatever it can read by itself.

So if your agent cannot start until you tell it something (which client, which lab came back, what happened on a call), a schedule will have it write the same thing every morning. That job has a good home in a Claude Project or a ChatGPT Project, where you are the trigger. You paste the job description in once as the project's instructions, then type the one detail each time and get the draft back.

For this course, go back to your list from lesson 1, take the next one down that can run on its own, and rewrite JOB. It takes about ten minutes on the same worker, and everything you have built so far still counts.

1Pick the time, and pick it properly

Do this before you touch Cloudflare, because it is the only decision in the lesson that matters.

Pick a time you will actually read it. An agent that runs at 3am and leaves you something you get to on Thursday is a filing cabinet. One that runs an hour before your day starts is a colleague.

Pick a time early enough to be useful and late enough to be current. For most practices that lands somewhere between 5am and 7am. If your agent reads live data, running it too early means it looked before the day had anything in it.

Match the rhythm to the job. A follow-up agent earns its keep daily. A weekly review agent does better on a Sunday evening or a Monday morning, and running that one every day just teaches you to skim past it. More often is worse rather than better, and an agent producing something you have stopped reading costs you more than one producing less.

2Set the schedule

  1. Open your worker in Cloudflare, then Settings.
  2. Find Trigger Events (some accounts label it Triggers), click Add, and choose Cron Triggers.
  3. Enter the schedule in cron format, which is five fields and reads stranger than it works.

Some of them you can paste exactly as they are.

You wantEnter this
Every day at 6am UTC0 6 *
Every weekday at 6am UTC0 6 1-5
Every Monday at 7am UTC0 7 1
Every Sunday at 6pm UTC0 18 0

Reading left to right, the five fields are minute, hour, day of month, month, and day of week, and a * means every one of them.

  1. Click Add (on some accounts the button says Deploy), then check that your trigger is listed under Trigger Events.

⚠️ Cloudflare runs on UTC and it has no idea where you are. This is the single most common thing to get wrong in this lesson, and it shows up as an agent arriving in the middle of your afternoon. Work out the difference between your own time and UTC, then apply it to the hour field. The quickest way is to search "current UTC time" and compare it with the clock on your screen. Five hours behind UTC and wanting 6am your time gives you 0 11 *.

If your clocks change for daylight saving, your difference from UTC changes with them, twice a year, while UTC itself stays put. So the week the clocks move, your agent starts arriving an hour early or an hour late, and you fix it by moving the hour field by one.

Get it wrong the first time and nothing breaks. You change one number in the trigger and deploy again.

3Give it somewhere to leave the answer

Your agent runs at 6am while you are asleep, so it needs to put the answer somewhere that will still be there when you wake up. That somewhere is a KV namespace, which is a small store belonging to your worker.

The storage has to exist before your worker can be connected to it, so this part happens in two places.

First, make the storage.

  1. In the left menu, open Storage & Databases, then Workers KV. If you can't spot it, type "KV" into the search bar at the top of the dashboard.
  2. Click Create instance.
  3. Name it after your worker with -memory on the end, so follow-up-agent-memory, and click Create.

Then connect it to your worker.

  1. Go back to Workers & Pages and open your worker.
  2. Open the Bindings tab, which is its own tab now and lives outside Settings.
  3. Click Add binding, choose KV namespace, and click Add binding again.
  4. The Variable name has to be exactly MEMORY. Your worker looks for that word and nothing else.
  5. Pick follow-up-agent-memory from the dropdown and click Add binding. That deploys it for you.

/health now says memory is true, which is four of the five.

Without this your agent still runs and still thinks, and the answer evaporates. You would find nothing waiting at /latest and no clue as to why.

4Prove it, rather than waiting until tomorrow

Do not go to bed hoping.

  1. Visit /run?key=yourpassword by hand once, which confirms the job and the key still work.
  2. Then visit /latest?key=yourpassword. Your answer should be sitting there in plain text, and that is the proof your memory binding is wired up.
  3. Now test the schedule itself, without waiting until tomorrow. Go back to Settings, then Trigger Events, and add a second cron trigger a few minutes from now, the same way you did in Part 2. If it is 2:10pm your time and you are five hours behind UTC, that is 15 19 *. Add it, and go and make a coffee.
  4. Come back and visit /?key=yourpassword, which shows the whole record your agent saved, including when it ran. Find the line beginning "ranAt". It should show a time from the last few minutes, later than the run you did by hand in step 1, and if it does, your schedule works and nothing about tomorrow is a hope. (That time is written in UTC, the same clock your trigger uses.)
  5. Delete the temporary trigger. The one you set in Part 2 is still there.

Step 3 is the one to make yourself do. Running it by hand proves the job works, and it proves nothing whatsoever about the schedule, which is the part that has to work while you are asleep.

Give it a few minutes of grace. Cloudflare's schedules run a few minutes loose, so a cron set for 6:00 can land at 6:04, and you can leave it exactly as it is.

If ten minutes have passed and the time has not moved, the cron never ran. Check that the trigger is listed under Trigger Events in your worker's Settings, and add it again if it's missing.

If this step does not do what it says here, stop and post it in the VIP chat. Do not push through it and do not sit on it. I cannot fix what nobody tells me about, and you are almost certainly not the only one on this exact step today.

5Go and look tomorrow

Tomorrow morning, before you open anything else, visit /latest?key=yourpassword.

Something will be waiting that you did not ask for and did not remember. Read it properly, because you are about to spend two weeks deciding whether it is any good, and lesson 8 is how you make that call.

✅ You now have

If something looks wrong

What you seeWhat it meansFix
/latest says "Nothing yet" after the schedule firedUsually the cron trigger never got addedOpen Settings, then Trigger Events, check it is listed, and add it again if it's missing
It arrives at the wrong time of dayThe UTC offset, almost every timeRecalculate the hour field in the trigger and deploy again
/latest is blank after the schedule firedThe last run failed, and a failed run saves no answer. Almost always the AI key or the credit rather than the scheduleVisit /run?key=... by hand and read the error it gives you
/latest shows an old answer and never updatesThe schedule never firesOpen Settings, then Trigger Events, check the trigger is listed, and add it again if it's missing
memory still says false at /healthThe binding is named something other than MEMORY, or the storage was made and never connectedOpen your worker's Bindings tab and add the binding again with MEMORY as the Variable name, that exact word
It writes the same thing every morningIt has nothing new to read, so the job needs you to hand it something each timeRead Check the job before you schedule it, near the top of this lesson

If your screen looks nothing like this, drop it in the chat and I will answer you there.

Stuck, or something not flowing? Tell me

Post it in the VIP chat and ask your question there. If a step does not work, if your screen does not match what is written here, or if something just reads confusingly, that is worth saying out loud.

I am building this while you are walking through it. If you do not tell me a thing is broken, I do not know it is broken, and it stays broken for whoever comes next. Tell me and I will fix it as fast as I can.

Wins go in the same place. They tell me which parts are landing.

Print this or save it as a PDF with Cmd+P, or Ctrl+P on Windows.