🧰 Prerequisites and how to use
Each box below is a prompt or command to copy and run, with 🎯 goal e ✅ how to verify. Replace what’s between <chaves>. Prerequisites: connected GitHub repository, connected Trigger.dev account, the Trigger.dev MCP e o Firecrawl MCP installed in the assistant (restart after installing), project initialized, and env vars in the dashboard. Build in layers: deploy → manual test → fix → repeat.
The difference between this module and the previous one is who triggers it the agent. Before, it was you. Now there are two different triggers: one clock (cron, on a schedule) and a doorbell (webhook, triggered by an event). Both run in the cloud — without you present.
Illustrative diagram — same cloud platform (the “coordinator” in cyan), two triggers: the clock wakes the first; an external request wakes the second.
🔁 Scheduled research agent
What it is
The first agent is a scheduled task that runs on its own every morning: through a trigger cron, it takes a fixed topic, searches the web for content with Firecrawl, synthesize with AI and write a structured row to the Google Sheets — without you present. The entire task fits in a single file, morning-research.ts, with the topic at the top (easy to change and version).
What is it?Cron — a scheduler with 5 fields (minute, hour, day-of-month, month, day-of-week). E.g.: 0 8 * * * = "at 8 a.m. every day". Firecrawl — a tool that searches and extracts content from web pages in a clean format. Task (task) — a hosted unit of work that the platform runs.
🎯 Goal: confirm that the Firecrawl MCP is available before planning.
Do you have access to the Firecrawl MCP server? If not, configure it—the key is in my .env file.
✅ How to verify: the AI confirms it's configured (or installs it by reading the key from .env). Restart the assistant after installing any MCP.
🎯 Goal: plan the scheduled research task.
Quero construir uma tarefa agendada que rode totalmente sozinha toda manhã. Ela pega um tópico fixo (<tópico>), busca na web com Firecrawl, sintetiza os achados e grava uma linha no Google Sheets. Sem perguntas no meio da execução, trate erros sem quebrar e registre log em cada passo. Me ajude a planejar isso.
✅ How to verify: the spreadsheet should have a tab Sheet1 with a header (date, topic, summary, sources, status). The task starts in a single file with the topic at the top.
Why learn
This is the first agent that "lives on its own"—it closes the agentic gap between running locally and being in production. Note that you embed error handling and logging from the very first prompt: a hosted agent doesn't have you nearby to fix things right away, so it needs to be robust from the start.
Key concepts
Schedule in 5 fields.
Web search.
Topic at the top, versionable.
Error + log in the first prompt.
🔐 OAuth refresh token (and the terminal fallback)
What it is
In the cloud, there’s no login window for the agent to click. Instead, it uses a refresh token: a long-lived credential that automatically renews access (access token). For Google, you need four values in the .env and in the dashboard: client ID, client secret, refresh token e o sheet ID.
What is it?Access token — short-lived access key that expires in minutes. Refresh token — long-lived key that exchanges for a new access token without a new login. Sheet ID — the spreadsheet identifier, which appears in the URL between the slashes after /d/.
🎯 Goal: get the refresh token when the interface method fails.
O método pelo OAuth Playground deu "Access blocked: this app's request is invalid". Gere um script de terminal que use meu client ID e secret do .env para imprimir uma URL de autorização. Vou abrir no navegador, autorizar, e o terminal vai imprimir o refresh token. Aí eu colo no .env e nas env vars do painel.
✅ How to verify: the terminal prints a URL → you authorize it in the browser → it prints the refresh token. Paste it into the .env e in the platform’s env vars (dev and prod).
🗺️ Where to find each credential
Client ID and secret: Google Cloud Console → APIs & Services → Credentials (create an OAuth2 client ID and a new client secret). Sheet ID: in the spreadsheet URL, between the slashes after /d/. Firecrawl key: in the firecrawl.dev dashboard → API Keys. Use OAuth, not a service account — tell the AI this so it can adjust the fields in the .env.
Why learn
The refresh token is the classic friction point when hosting agents—and the “official” path (OAuth Playground) sometimes simply fails. Get to know the terminal fallback unblocks the deploy when you need it most, instead of leaving you stuck on an error screen.
Key concepts
Renews without logging in.
ID, secret, token, sheet.
Terminal script.
Notify the AI.
🐛 A bug that only appears in production
What it is
After the deploy, you triggers a manual test in the dashboard (you can’t wait for the scheduled time) and reads traces in real time. Production errors have a reality of their own: in this project, Firecrawl returned success: false but with results — but under the ownership web instead of data. The actual response format differed from what the code assumed.
Illustrative diagram — the human debugging loop: trace → error → AI → fix → redeploy → rerun. The key step is copying the error complete with context.
🎯 Goal: return the production error with context for the AI to fix.
O run falhou em produção. Aqui está o erro completo do trace: <cole o erro do passo que ficou vermelho> O Firecrawl retornou resultados, mas numa propriedade "web" em vez de "data", e success veio false. O formato da resposta do SDK difere do que assumimos. Corrija o parsing e me diga o comando de redeploy.
✅ How to verify: after redeploying, the platform reruns it and the run turns green (e.g., 8 results, success status). Watch out for false clues: here, the initial suspicion was the production key, but it was correct—the error was in the format.
✅ Error handling proved its value
Even when Firecrawl failed, the task didn’t break: it even recorded a partial row in Sheets (data, topic, summary, no sources, status=partial) — exactly what the prompt asked for. It’s proof that “handle errors without breaking” pays off from the very first prompt.
Why learn
Production is where theory meets reality: response formats change, timeouts happen, env vars disappear. The core skill isn’t “never make mistakes,” it’s the human debugging loop — read the trace, copy the full error (not your summary), return it with context, and redeploy.
Key concepts
Don't wait for cron.
Copy everything, with context.
Confirm before blaming.
A partial line is okay.
📄 Webhook report (payload → .docx → Drive)
What it is
The second agent is triggered by event, not by the clock. It receives an payload JSON via webhook (with the fields: company name, sector, objective, challenge), generates a report in .docx and saves it to the Google Drive. The AI builds the report sections (executive summary, industry context, challenges) from just these four fields.
What is it?Payload — the data that arrives with the webhook request (e.g., { "company": "Acme", "industry": "Construção" }). .docx — Microsoft Word document format. Folder ID — the identifier of a Drive folder, to organize the output (without it, the file lands in the root folder).
🎯 Goal: plan the webhook-triggered task that generates the report.
Quero uma tarefa disparada por webhook (via um form / HTTP request). Ela recebe um payload JSON com os campos: <nome da empresa, setor, objetivo, desafio> Gera um relatório .docx e salva no Google Drive. Sem perguntas no meio, trate erros sem quebrar, registre log em cada passo. Me ajude a planejar.
✅ How to verify: the task creates types for the payload and normalizes the form labels. Optional: provide a folder ID from Drive to organize the output.
🎯 Goal: test locally BEFORE connecting any form.
Suba o dev server e teste a tarefa de relatório com este payload:
{ "company": "<Acme>", "industry": "<Construção>",
"goal": "<dobrar leads>", "challenge": "<ciclo de venda longo>" }
✅ How to verify: the run appears, the .docx is generated, and the file is in Drive—all of this before of connecting the form. Testing locally first saves a debugging cycle.
Why learn
This agent teaches you how to trigger event-based: it responds to an external request, not a clock. It’s the pattern that connects any source (form, another system, a button) to an agent that produces an artifact—and testing locally first is the discipline that keeps you from debugging two problems (your form and your task) at the same time.
Key concepts
Request data.
.docx in Drive.
Organize the output.
Before the form.
🔔 Webhook as a "digital doorbell" + Bearer auth
What it is
A webhook is a “digital doorbell”: a URL that listens for data; when someone “rings” it (makes a request), it wakes up the task and passes the payload along. Since the URL can be shared (it can go on a website or in an email), you protect it with a header Authorization: Bearer + your secret key.
What is it?Header (header) — extra information that travels with the request. Bearer token — an auth scheme where the key goes in the header Authorization: Bearer <chave>; anyone who doesn’t send the right key is rejected.
🎯 Goal: configure the n8n HTTP Request node to ring the doorbell with auth.
Method: POST
URL: <url-do-webhook-da-tarefa> (inclui o ID/nome da tarefa, ex.: webhook-report)
Authentication: None (a auth vai pelo header)
Send Headers: ON
Name: Authorization
Value: Bearer <sua-chave-secreta> ← "Bearer" + ESPAÇO + chave (do painel → API Keys → secret)
Send Body: ON → JSON
campo: payload → { company, industry, goal, challenge }
✅ How to verify: be careful with the space after "Bearer" (common error). Without the correct token, the task rejects the request. With it, the run appears in the panel with the payload visible.
Why learn
The webhook URL is public by nature—anyone who discovers it can “ring the doorbell” and use your resources. The Bearer is the basic lock: without the right key, the request is rejected. It’s the first line of security for any agent that accepts external triggers.
Key concepts
The digital doorbell.
Data in the body.
Key in the header.
"Bearer " + key.
📋 No-code form → webhook
What it is
To give the agent a human face, you build a no-code form that, when sent, makes the request to the webhook with the payload. In n8n, it's just two nodes: one Form Submission (the four fields + submit button), and the HTTP Request from the previous topic. The form tool is interchangeable—any tool that accepts a webhook/API will work.
What is it?No-code — build something by dragging blocks, without writing code. Form Submission trigger — a node that creates a form and triggers the workflow when someone submits it.
🎯 Goal: connect the form to the webhook and run an end-to-end test.
1. Form Submission trigger: 4 campos de texto (empresa, setor, objetivo, desafio) + enviar. 2. HTTP Request: configurado como no tópico 5 (POST + Bearer + body payload). 3. Mapeie cada campo do form para o payload. 4. Execute o nó do form com dados de teste e confira o run no painel. 5. Para o teste final: PUBLIQUE o form em produção e use a URL de produção.
✅ How to verify: the run appears on the platform with the form payload, and the report lands in Drive. Note: some form tools fail on the API side—if yours does, switch to n8n.
Why learn
The form connects a real person to the agent without you having to write a frontend yet — that comes in module 5.3. It’s the fastest way to give an automation an interface and prove the end-to-end workflow with a real submission.
Key concepts
Form + HTTP Request.
Form → payload.
Production URL.
Any form with an API.
🐙 GitHub pipeline → automatic deploy
What it is
Instead of deploying manually for every change, you connect the repository GitHub to the hosting platform: each push triggers the deploy automatically. That way, the code in the repository is the source of truth, and iterating with AI publishes the latest version. The manual step is a repository secret that gives GitHub permission to deploy.
What is it?commit / push — save a snapshot of the code and send it to the cloud. .gitignore — list of files Git should ignore (the .env NEVER goes up). Repository secret — a secret stored on GitHub, used by deploy automations.
🎯 Goal: make every push to GitHub publish automatically.
[prompt] Configure the flow so that when I iterate with you, the code is sent to GitHub and GitHub automatically deploys it to the platform. Confirm that .env is in .gitignore and create a secure .env.example. [manual step on GitHub] Settings → Security → Secrets and Variables → Actions → Repository Secrets → New Repository Secret Name: TRIGGER_ACCESS_TOKEN Value:
✅ How to verify: make a small change, push it, and see the deployment run automatically. The .env must not appear in the repository (check that it’s in the .gitignore).
Why learn
Manual deployment is an easy step to forget and get wrong. Automating it means that "what’s in the repository is what’s live" — and that iterating takes only a conversation with the AI and a push. It’s the habit that separates a prototype from a maintained system. (Track 6 covers GitHub and Trigger.dev in more depth.)
Key concepts
Push = publish.
The repo decides.
Lets you deploy.
.env never gets uploaded.
📊 Check runs, traces, and the schedule
What it is
Since the agent runs without you, the dashboard it’s how you know it’s healthy. Learn to read: the list of runs (runs), the trace for each one (each row is one step), the schedules (the active cron job + the next scheduled time) and the separation dev vs. prod. Also check the actual row that appeared in Sheets.
What is it?Run — one execution of the task. Trace — the step-by-step record of that run (inputs, outputs, errors). Schedule — the cron rule that triggers the task. dev vs. prod — test environment vs. live environment; a task may accidentally be running only in dev.
🎯 Goal: confirm that both agents are healthy and configure alerts.
[ ] Em Schedules, a tarefa morning-research aparece com o cron (ex.: 0 8 * * *)
e o próximo horário (amanhã, 8h).
[ ] O último run está verde; o trace mostra cada passo.
[ ] A linha apareceu no Google Sheets / o .docx no Drive.
[ ] A tarefa está em PROD, não só em dev.
[prompt] Adicione retries com backoff exponencial (até 3, começando em 30s)
para falhas transitórias, e configure um alerta por <e-mail/Slack> quando
um run ou deploy falhar.
✅ How to verify: the schedule shows the next run; a test run turns green; the alert fires on a run forced to fail. Remember: retries handle failures transient, not logic bugs.
Why learn
Observability is what makes a hosted agent reliable: when you're not there, runs, traces, schedules, and alerts are your eyes. A common mistake is to leave the task only in dev and assume it's live—always confirm the environment. And alerts close the loop: you only act when something actually fails.
An external call occasionally fails due to a timeout, but the logic is correct. What’s the right remedy?
📌 Module Summary
Authorization: Bearer (watch the spacing)..env never uploads.Next Module:
5.3 — Full-Stack App (Lead Qualifier) + Frontend for n8n: from agent to product with an interface, auth, and payments.