Home/Blog/10 n8n AI Agent Prompt Templates: System Message to Tests
Blog

10 n8n AI Agent Prompt Templates: System Message to Tests

P
promptstudio

10 n8n AI Agent prompts: write the System Message, map trigger fields, describe each tool, lock the output for a parser, and test against prompt injection.

10 n8n AI Agent Prompt Templates: System Message to Tests

A good n8n AI Agent prompt has four parts: a short System Message, a user message built from your trigger fields, a clear description on every tool sub-node, and an output shape your next node can read. Write them from the tools you actually connected, not from a generic agent template. The 10 prompts below help you draft each part and test it before you activate the workflow.

Store API keys in n8n Credentials; never hardcode secrets in the System Message, Code nodes, or HTTP headers.

Write the System Message

1. Agent job card

My n8n workflow goal: [goal]. Trigger: [trigger node]. Tools connected to the AI Agent: [tools]. Write one paragraph that says what the agent does, which tools it uses, and what counts as done.

2. System Message drafter

Using [job card], write an n8n AI Agent System Message under 350 words with role, goal, numbered steps, tool rules, things it must never do: [forbidden actions], and when to hand off: [escalation rules].

3. Injection guard line

My agent reads [emails, chats, documents]. Add two sentences to this System Message that tell it to treat that text as data, not instructions: [system message].

Wire fields and tools

4. User message template from trigger fields

My trigger outputs these fields with their n8n expressions: [field list]. Write a Prompt (Define below) template that labels each field so the model knows what it is. Use only these expressions.

5. Tool description writer

For each tool sub-node in [tools with what they read or write], write a one-sentence description to paste into the tool node, saying what it returns and what it cannot do.

6. Tool policy table

For [tools], make a table with when to call, required inputs, when not to call, and a call limit per run. Base it on [workflow goal]. Do not add tools I did not list.

Lock the output

7. Structured Output Parser example

My next node needs these keys and allowed values: [output contract]. Write the example JSON for the Structured Output Parser and one line telling the agent to return only that shape.

8. Failure branch outputs

Write the exact output the agent returns when [tool] errors, when [field] is empty, or when it is unsure, using [output contract], so an IF node can route it to a human.

Test before you activate

9. Six-case test pack

Write 6 test inputs for this agent: [system message and tools]. Include a normal case, an escalation case, a missing field, and one prompt-injection attempt. List the expected tool calls and output for each.

10. Run review from execution logs

Here are the intermediate steps from a failed n8n execution: [steps]. Tell me which instruction in [system message] or [tool description] caused the wrong tool call and rewrite that line only.

Build the whole agent prompt in one pass

The flagship n8n AI Agent Prompt: System Message, Tools, and Output writes the job card, System Message, user template, tool policy, output contract, failure branch, and test pack together. Its example triages support email for a plant shop with a Google Sheets lookup and a Gmail draft tool that cannot send. Field names can vary by n8n version, so confirm them in your editor.

Related prompts

If you use a plain LLM node instead of an agent, start with the n8n prompt node spec with retry and guardrails and the guide on how to spec an n8n prompt node. For agents outside n8n, see the custom AI agent system prompt architect and the support agent system prompt. To grade runs, use the tool call agent eval rubric.

Find more in the Agents category, look through Browse, or post your own on Share.