Build Your Own AI Team
Lesson 6

It thinks

What you walk away with
The same worker you deployed in lesson 5, now with a brain and a job. You ask it something and it answers as your agent rather than as a generic assistant.
Time
About forty-five minutes, and most of that goes on writing the job description rather than on clicking anything.
Cost
Cents. You pay your AI provider per run, and a run this size costs less than a penny.

Your worker has been sitting there since lesson 5 answering /health and doing nothing else with its day. Two things turn it into an agent and you add both of them today. It needs a key so that it can think at all, and it needs a job so that it thinks about the right thing.

The key takes four minutes. The job is the part only you can write, and it is the whole difference between an agent that saves you a morning and one that hands you paragraphs you rewrite every time.

1Get an AI key

You need a developer account with either Anthropic, the company behind Claude, or OpenAI, the company behind ChatGPT, and one of the two is plenty, so pick whichever you already lean on. Your worker reads the key you give it and has no preference between them.

A chat subscription is a different thing from what you need here. Paying for Claude or ChatGPT to use in your own browser does not include the key your agent uses. That key comes from a separate developer account, it is billed separately, and it is billed by usage rather than by the month.

Which works in your favor. A daily agent doing a job this size comes to a few dollars a month rather than another subscription.

If you use Claude. Go to console.anthropic.com, sign up, and add a small amount of credit. Then find API keys and create one. Give it a name you will recognize in six months, like your agent's name. The console also asks how long the key should last, offering a few preset lifetimes or Never. Choose Never. The key lives in one Cloudflare Secret, and an expired key stops your agent the morning it runs out.

If you use ChatGPT. Go to platform.openai.com, sign up, and add a small amount of credit. Then find API keys and create one, with the same advice about the name.

The moment the key appears on screen, put it in your password manager, in a new entry of its own called something like follow-up-agent, AI key, before you click anything else at all. This is the one-time display lesson 4 warned you about, and it behaves exactly the way that lesson said it would.

2Give the key to your agent

  1. Open your worker in Cloudflare, then Settings, and find Variables and Secrets.
  2. Click Add.
  3. Set the Type to Secret, because this one spends your money and is never Text.
  4. In Variable name, type ANTHROPIC_API_KEY if you went with Claude, or OPENAI_API_KEY if you went with ChatGPT, in capitals and underscores, spelled exactly like that.
  5. Paste the key into Value.
  6. Click Deploy, which is what keeps it (there's no separate Save button in this panel).

Visit /health again. aiKey now says true.

Your agent can think, and it has nothing to think about yet.

3Write the job

This is the lesson. Everything else in it is clicking.

You are briefing an assistant who is extremely capable, has never met you, starts every shift with no memory of the last one, and will do exactly what you wrote rather than what you meant. That last part is the one that trips people up. A human assistant fills in your gaps from context, and this one fills them in from nothing, so every gap you leave shows up in the output.

Open the job description template. It has seven sections with an example under each one. Fill it in, in your own words, and the finished thing becomes one setting on your worker.

The seven sections, and what each one is there to prevent.

SectionWhat it stops happening
1. Who it is, and what it ownsAn agent with no edges wanders off and helpfully rewrites something you never asked it to touch
2. What it does, every time it runs"Handle my follow-ups" is a wish. "Find X, check Y, draft Z" is a job you can tell it got wrong
3. What it hands youThe one you might be tempted to hurry, and the one that decides whether you save time or gain a reformatting job
4. How it should soundOnly matters if it writes things you send, and then it matters more than the other six put together
5. When it stops and asks youThe difference between an agent you trust and one you double-check forever. Lesson 8 is entirely about this
6. What it needs to know about your practiceA slice of the file you wrote in lesson 3, the part this particular job touches
7. When it runsLesson 7 turns this one into a schedule Cloudflare keeps for you

Lesson 3's rule about client information holds for your agent too. Keep client names and client health information out of the job and out of anything you point it at later, because everything your agent is given goes to your AI provider, and from lesson 7 on it keeps its answers in Cloudflare as well.

Nothing in this course's setup can hold client health information, because none of it comes with a BAA, the business associate agreement a company signs before it handles health information on your behalf. That includes Cloudflare, your AI key, and everything your agent keeps. If a job genuinely needs client names or health details to work, it belongs in a tool that signs a BAA with you, and the first place to look is the AI features inside the EHR you already pay for. Before you use those features with client information, ask your EHR's support team, in writing, whether they are covered by its BAA. Anything beyond that is a conversation for a HIPAA consultant who can look at how your practice is set up.

Section 3 is worth slowing down on. "A summary" feels like an answer while you are typing it. Then the agent hands back four paragraphs when you wanted three lines, and you spend a month rewriting its output before it occurs to you that the brief was the problem rather than the agent. Say the format, the length, and the order. Say what you do not want in there.

And it is going to be wrong the first time, in small ways that only show up once you read something it produced. That loop is the actual skill this course teaches. Change one section, run it again, read what comes back. Nobody writes a good job description from a blank page, including me.

4Put the job into your agent

  1. Go back to Settings, find Variables and Secrets, and click Add.
  2. Set the Type to Text, and this one is deliberate. You are going to rewrite it a dozen times as you tune it, and a Secret can never be read back, so every edit would mean retyping the whole job description blind.
  3. In Variable name, type JOB.
  4. Paste your whole job description into Value, all seven sections.
  5. Click Deploy.

/health now says job is true.

5Ask it something

Visit your agent's /run address with your password on the end.

https://follow-up-agent.yourname.workers.dev/run?key=yourpassword

It thinks for a few seconds and hands back a block of JSON with its answer inside. The answer sits on the line beginning "output", and it arrives with every line break written out as \n instead of an actual line break, which makes it a slightly ugly way to read something. Lesson 7 gives you a plain-text address for exactly that reason, so ugly is fine for today.

That answer was written by your agent, doing your job, in the context of your practice. Read it properly, because you are about to run the loop for the first time.

Whatever comes back wrong, the fix is almost always the job description rather than the agent. Edit JOB, deploy, run it again. Two minutes a round.

You may also see a line mentioning that there is no MEMORY binding. Correct, and expected today. Your agent has nowhere to put anything down yet, so the answer lives only in the page you are looking at, and lesson 7 gives it somewhere permanent.

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.

✅ You now have

Your agent still only runs when you go and visit it, which means you are still the one who has to remember it exists. Lesson 7 fixes that, and it takes twenty minutes.

If something looks wrong

What you seeWhat it meansFix
The AI call failed, ending in HTTP 401The key is wrong, or it went in with a stray space on the endCreate it again, paste it again, Deploy
The AI call failed, ending in HTTP 400Usually a MODEL variable, which is optional and which this course never asks you to createIf you added one, delete it and let your agent use its default
Something about your credit balance being too lowYour AI account has no money in itAdd a small amount at the console you signed up with
No JOB setThe panel closed before you clicked Deploy, or the name reads as something other than JOBOpen Variables and Secrets, check the spelling, and add it again if it's wrong or missing
The answer ignores half your briefAlmost always sections 2 and 3 being vaguer than they felt while you wrote themRewrite them as numbered steps and an exact output shape
It invented a detail about your practiceSection 6 is thinGive it the specific facts this job needs, and tell it to say so when it does not know

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.