If you've been using n8n for automations but haven't connected it to ChatGPT yet, this is the tutorial for you.
n8n has a native OpenAI node that makes it surprisingly easy to add AI to any workflow — no custom API code required. In this post I'll walk you through building a real working AI automation from scratch.
What we're building
A workflow that:
- Receives a webhook (from a form, Slack, or anything)
- Passes the input to ChatGPT
- Returns the AI-generated response — to email, Slack, Google Sheets, wherever you need it
This is the foundation pattern for almost every AI automation in n8n. Once you have this wired up, you can swap in any trigger and any output.
Prerequisites
- n8n running (cloud or self-hosted)
- An OpenAI API key (platform.openai.com)
- 10 minutes
Step 1 — Create a new workflow and add a Webhook trigger
- In n8n, click + New Workflow
- Add a Webhook node as your trigger
- Set the HTTP method to POST
- Copy the webhook URL — you'll use it to send test data
The webhook will receive a JSON body with whatever input you want to send to ChatGPT. For this tutorial we'll use:
{
"message": "Summarize the following in one sentence: n8n is an open-source workflow automation tool that lets you connect apps and automate tasks without writing code."
}
Step 2 — Add the OpenAI node
- After the Webhook node, click + to add a new node
- Search for OpenAI and select it
- Choose the Message a Model operation
- Create a new credential: paste your OpenAI API key
Model settings:
- Model:
gpt-4o-mini(fast and cheap — ideal for automations) - User Message:
{{ $json.message }}— this pulls the message from the webhook body - System Prompt (optional):
You are a helpful assistant. Be concise.
That's it. n8n handles the API call, authentication, and response parsing automatically.
Step 3 — Use the response
The OpenAI node outputs the response text at:
{{ $json.message.content }}
From here you can pipe it anywhere:
- Send Email node → email the AI response
- Slack node → post it to a channel
- Google Sheets node → log it to a spreadsheet
- Respond to Webhook node → return it to the caller as JSON
For testing, add a Respond to Webhook node at the end with body {{ $json.message.content }} — that way you can hit the webhook URL and get the AI response back in real time.
Step 4 — Test it
- Activate the workflow
- Send a POST request to your webhook URL with the JSON body above (use curl, Postman, or any HTTP tool)
- You should get back a clean one-sentence summary from ChatGPT in under 2 seconds
Real-world uses for this pattern
Once you have the base pattern working, here's what people actually build with it:
| Use case | Trigger | What ChatGPT does |
|---|---|---|
| Auto-classify support tickets | Email receive | Tags tickets by urgency/topic |
| AI email drafts | New CRM lead | Drafts a personalized outreach email |
| Form response summarizer | Tally/Typeform webhook | Summarizes long-form answers |
| Slack Q&A bot | Slack mention | Answers questions from a knowledge base |
| Invoice data extraction | Email attachment | Extracts line items into Google Sheets |
All of these use the same skeleton: trigger → OpenAI node → output node.
Common issues
"I get an authentication error" — double-check your OpenAI API key in n8n credentials. Make sure you're using a key from the project you have billing set up for.
"The response is empty" — check your expression path. In newer n8n versions the response is at {{ $json.message.content }}. In older versions it may be at {{ $json.choices[0].message.content }}.
"It's slow" — switch from gpt-4o to gpt-4o-mini. For most automation tasks the quality difference is negligible and latency drops from ~3s to ~0.5s.
Want pre-built workflows that already use this pattern?
I put together an n8n Workflow Starter Pack — 5 production-ready workflow JSONs you can import and run immediately, including a lead-capture AI workflow that uses OpenAI to score and categorize inbound leads automatically.
Get the n8n Workflow Starter Pack ($29) →
Drop a comment below if you get stuck on any of the steps and I'll help you debug it.
Top comments (1)
Here's the complete workflow JSON from the tutorial — paste this into n8n via Settings > Import Workflow:
Remember to add your OpenAI credential after importing. Let me know if you run into any issues!