Generate a full content brief from a keyword
Draft an outline, angle, and target audience for a Northwind article from a single keyword.
Published Oct 26, 2025
Northwind’s content team starts every article the same way: someone picks a keyword, then spends half an hour deciding the angle, who it is for, and what the sections should be. It is not hard work, but it is friction — and it stalls the writing before a single word is drafted.
This script turns that half hour into a few seconds. Give it a keyword and it asks Claude for a structured brief — an angle, a target audience, and a section outline — returned as JSON your code can use directly. It is a building block: call it from a menu, a form, or a loop over a backlog of keywords.
What you’ll need
- An Anthropic API key saved as
ANTHROPIC_API_KEYin Script Properties — see Store API keys and secrets securely. - Nothing else to start with. The script returns a plain object; where you put that brief — a Doc, a Sheet row, a log — is up to the caller.
The script
// Model used for briefs. Sonnet handles the light reasoning a good
// angle and outline need.
const BRIEF_MODEL = 'claude-sonnet-4-6';
// Token budget for one brief. Enough for an angle, audience, and a
// six-to-eight item outline.
const BRIEF_MAX_TOKENS = 1000;
/**
* Asks Claude for a content brief built around a single keyword.
*
* @param {string} keyword The topic to brief, e.g. "expense automation".
* @return {{angle: string, audience: string, outline: string[]}}
*/
function briefForKeyword(keyword) {
// Bail out early on an empty keyword — no point calling the API.
if (!keyword) {
throw new Error('briefForKeyword needs a keyword.');
}
// Pin the reply to a strict JSON schema so the result is parseable.
const prompt =
`Generate a content brief for Northwind on "${keyword}". ` +
'Return ONLY JSON — no prose, no markdown — in this shape: ' +
'{"angle": string, "audience": string, "outline": [string]}. ' +
'Use "outline" for an ordered list of section headings.';
// Call Claude and parse the JSON reply into a real object.
const reply = callClaude(prompt, BRIEF_MODEL, BRIEF_MAX_TOKENS);
return JSON.parse(reply);
}
/**
* Minimal Anthropic API call. The key lives in Script Properties — it
* is never pasted into the code.
*/
function callClaude(prompt, model = 'claude-haiku-4-5-20251001', maxTokens = 400) {
const key = PropertiesService.getScriptProperties()
.getProperty('ANTHROPIC_API_KEY');
const res = UrlFetchApp.fetch('https://api.anthropic.com/v1/messages', {
method: 'post',
contentType: 'application/json',
headers: { 'x-api-key': key, 'anthropic-version': '2023-06-01' },
payload: JSON.stringify({
model,
max_tokens: maxTokens,
messages: [{ role: 'user', content: prompt }],
}),
muteHttpExceptions: true,
});
return JSON.parse(res.getContentText()).content[0].text.trim();
}
How it works
briefForKeywordfirst checks it was actually given a keyword and throws if not — a clear error beats a vague reply built from an empty topic.- It builds a prompt that names Northwind, states the keyword, and pins the
output to a fixed JSON schema: an
angle, anaudience, and anoutlinearray. A fixed schema is what makes the reply safe toJSON.parse. - It calls
callClaudewith the Sonnet model and a 1000-token budget — enough for a full outline without paying for headroom you will not use. callClaudereads the API key from Script Properties, posts the prompt to the Anthropic Messages API, and returns the trimmed text of the reply.briefForKeywordparses that text into an object and hands it back, so the caller getsbrief.angle,brief.audience, andbrief.outlinedirectly.
Example run
Call it with a keyword:
function tryBrief() {
const brief = briefForKeyword('expense report automation');
Logger.log(brief.angle);
Logger.log(brief.audience);
Logger.log(brief.outline.join('\n'));
}
The returned object looks like this:
{
"angle": "Show finance teams how to cut expense-report turnaround from days to minutes without new software.",
"audience": "Finance managers and operations leads at small companies who still process expenses by hand.",
"outline": [
"Why manual expense reports cost more than they look",
"What a good automation actually replaces",
"Building the workflow step by step",
"Handling exceptions and approvals",
"Measuring the time you get back"
]
}
From there a writer has a running start: the angle frames the piece, the audience keeps the tone honest, and the outline is the skeleton to fill in.
Run it
This is an on-demand helper, so trigger it however suits the team:
- To brief one keyword, write a small wrapper like
tryBriefabove, select it in the editor, and click Run. The brief appears in the execution log. - To brief a backlog, loop over a column of keywords in a Sheet and write each returned brief into adjacent cells.
- Approve the authorisation prompt the first time —
UrlFetchAppneeds permission to reach the Anthropic API.
Watch out for
- The reply must be valid JSON. The prompt asks for JSON only, but if Claude
ever wraps it in a code fence,
JSON.parsethrows. If that happens, strip the fence before parsing rather than reaching for regex. - Briefs are generated, not researched. Claude has no live view of search demand or competitors — treat the angle and outline as a strong first draft, not a validated content plan.
- Each call costs tokens. Briefing a long backlog in a loop adds up; batch thoughtfully and watch your Anthropic usage.
UrlFetchAppis subject to a daily call quota. A few briefs a day is nothing, but a bulk run over hundreds of keywords can hit the limit — spread large jobs across runs.- The model and token budget are tuned for a single brief. If you ask for a
much longer outline, raise
BRIEF_MAX_TOKENSso the JSON is not cut off mid-array, which would also break the parse.
Related
Generate and test email subject lines
A/B test AI-written Northwind subject lines for open rate — outputs ranked by past performance.
Updated Mar 3, 2026
Build retrieval-augmented Q&A over your data
Answer Northwind questions grounded in your own Sheet data — pass relevant rows as context.
Updated Feb 27, 2026
Build an AI weekly-report narrator
Turn Northwind metrics into a written executive summary — numbers in, prose out.
Updated Feb 23, 2026
Build a multi-step AI agent workflow
Chain Claude prompts to complete a Northwind task end to end — research → draft → critique → finalise.
Updated Feb 11, 2026
Adapt marketing copy per region
Localise Northwind tone and references by market with AI — same message, regional flavour.
Updated Jan 30, 2026