n8n Masterclass
0/24 complete

Module 06 · AI Nodes in n8n

Connecting Claude and OpenAI Nodes to a Workflow

25 minfocused lesson5practical steps4grounded questions4source links
Open lesson + course map

On this lesson

Course outline

AI nodes add probabilistic generation to a deterministic workflow. Connect them only after defining the task, permitted data, provider terms, model/version, schema, evaluation, cost limits, and human approval. Node availability and model names change; verify current n8n and provider docs.

// concept

Choose the Smallest AI Task

Good first tasks: classify a synthetic enquiry into an allowed taxonomy, summarize approved public text, or draft a response for review. Avoid using a model as payment verifier, legal/tax authority, identity decision, or database authorization layer.

Create separate provider credentials with minimum access and budget alerts. Never put API keys in prompts or Code nodes. Record provider, model identifier/alias, temperature/settings where exposed, prompt version, and data controls.

Maintain a provider-change checklist covering credentials, allowed data, model availability, pricing date, context/output limits, rate quotas, evaluation results, and fallback. Switching a node is a production change, not a cosmetic replacement.

// concept

Enforce Structured Output

Request a schema:

// json6 lines
{
  "category": "sales|support|other",
  "summary": "string <= 200 chars",
  "needs_human": true,
  "evidence_refs": ["input:message"]
}

Validate after the model. Reject unknown enum, excess length, missing fields, or invented evidence. Model output cannot choose credentials or tool permissions.

// worked_example

Worked Example

A synthetic Lahore service enquiry is classified. OpenAI and Claude configurations are evaluated against the same 30 labelled fixtures. The workflow measures exact category match, unsafe claim rate, invalid JSON, latency, and estimated cost.

The selected configuration writes only a DRAFT classification. Low-confidence, unsupported, and protected topics route to human review. The business can swap provider only after rerunning the evaluation; no model is declared permanently best.

// failure_cases

Failure Cases to Diagnose

6 cases to diagnose

  • Entire CRM record sent

    minimize input.

  • Model name assumed current forever

    record and re-evaluate changes.

  • Free-form output drives branch

    schema-validate.

  • AI marks payment paid

    use provider evidence.

  • No provider outage path

    queue or human fallback.

  • Cost cap absent

    limit input, calls, retries, and tenant spend.

// pakistan_angle

Pakistan Angle

Do not send CNIC, bank, health, student, employee, or private customer data to an AI provider without necessity, authority, and appropriate terms. Use synthetic or redacted fixtures during development.

Test English, Roman Urdu, and code-switched messages from the intended audience. Do not infer education, religion, ethnicity, or ability to pay from language.

// hands_on

Hands-On Exercise

5 steps

  1. Define one bounded AI task.

  2. connect two provider nodes using protected credentials.

  3. enforce one output schema.

  4. run the same labelled fixtures.

  5. set cost, retry, fallback, and human gates.

// completion_rubric

Completion Rubric

6 checks — tick as you verify

0/6

// sources

Sources

// check_yourself

Check yourself

4 questions · answers and options are taken word-for-word from this course

0/4
  1. 1 / 4 · diagnose

    Your work shows this failure mode: “Model name assumed current forever.” What does the lesson tell you to do about it?