AI turns a workflow from a task runner into a decision-maker. This tutorial shows you how to integrate OpenAI’s models into n8n to generate content, analyze text for sentiment and classification, extract structured data from unstructured text, and drive email content, all in real time. You will finish with a working content-generation pipeline.
Prerequisites
You need an OpenAI API key from platform.openai.com, a working knowledge of n8n basics, and a use case in mind such as content generation or text analysis.
Step 1: Connect your OpenAI account
Add an OpenAI node in n8n and create a new credential. Generate an API key at platform.openai.com, copy it, and paste it into n8n’s credential modal. Save and verify the connection so the node can authenticate.
Step 2: Basic prompt example
Start with a simple workflow that generates marketing copy. A first prompt might be:
Prompt: "Write a compelling product description for a {{product_name}} in 2-3 sentences."
Model: gpt-4
Temperature: 0.7
The double-brace expression pulls a value from earlier in the workflow, so the same prompt works across many products.
Step 3: Advanced techniques
Push output quality further with a few controls. Use a system prompt to define the AI’s role, for example “You are a marketing expert”. Set temperature lower (around 0.3) for consistent output and higher (around 0.9) for creative variety. Set max tokens to cap response length and cost.
Practical workflow: content generation
Combine these pieces into a real pipeline. The workflow receives product data from Airtable, sends it to OpenAI for description generation, stores the generated content back in Airtable, and notifies you when the batch is complete. This pattern scales from a handful of records to a full catalog.
Cost considerations
OpenAI API calls cost money. GPT-4 is more expensive but more accurate, while GPT-3.5 is cheaper and faster. Always set token limits so a runaway prompt or a large batch does not produce an unexpected bill.
Next steps
From here you can build a chatbot workflow, run sentiment analysis on customer feedback, translate content across languages, or assemble a research assistant. If you want help designing AI workflows that hold up in production, get in touch.
