n8n: How To Use the ChatGPT Model

n8n makes it easy to build powerful automations, and with the rise of AI, the possibilities are only expanding. If you've ever wanted to combine n8n's workflow engine with the intelligence of ChatGPT, you're in the right place. In this guide, you’ll learn n8n how to use ChatGPT model effectively to build smart, automated workflows using OpenAI's API. Whether you want to create chatbot flows, summarize emails, or enrich data with natural language—this tutorial walks you through it step by step.

Why Use ChatGPT in n8n?

Integrating ChatGPT into your n8n workflows lets you bring natural language processing, intelligent decision-making, and advanced content generation into your automations. Here are a few common use cases:

  • Writing and replying to emails automatically
  • Summarizing documents or chat history
  • Generating blog content or product descriptions
  • Translating text in real-time
  • Creating dynamic chatbot conversations

Once set up, everything can happen without manual intervention, 24/7.

Prerequisites

Before starting, make sure you have the following:

  • A working setup of n8n (self-hosted or cloud)
  • An OpenAI account with a valid API key (get one here)
  • Basic familiarity with n8n's interface

If you're new to installing n8n, follow the step-by-step Docker installation guide.

Step 1: Add Your OpenAI API Key to n8n

To use ChatGPT in your workflows, you need to authorize n8n to communicate with OpenAI.

How To Add OpenAI API Credentials

  1. Go to n8n and click the "Credentials" tab.
  2. Click "New credential" and select "OpenAI API".
  3. Name your credential (e.g., My OpenAI Key).
  4. Paste your OpenAI API Key into the required field.
  5. Save the credentials.

Need help with credentials? Check the OpenAI API key integration guide.

Step 2: Create a New Workflow in n8n

Now, let’s create a basic workflow that sends a prompt to ChatGPT and gets a response.

Example Use Case: Summarize a Text

We’ll build a workflow that receives a text input and responds with a summary using ChatGPT.

Step-by-Step Instructions

  1. Start with a Trigger Node

    • Use a Webhook trigger to receive incoming POST requests.
    • Set the HTTP Method to POST, and configure the "Response Mode" to "On Received".
  2. Add a Set Node (Optional)

    • Use this node to define a sample input or test data. For example:
      • text: "n8n is a powerful open-source automation tool that enables users to connect different services and automate tasks. It features a user-friendly visual workflow builder."
  3. Add the OpenAI Node

    • Drag in the “OpenAI” node.
    • Choose the credential you created earlier.
    • Set Resource to “Completion” (if you're using GPT-3) or “Chat” (for GPT-4 style).
    • Configure the inputs:
      • Model: gpt-3.5-turbo (or desired)
      • Prompt/Message: Use n8n expression like:
        Write a short summary of the following text:
        
        {{$json["text"]}}
        
  4. Add a Respond to Webhook Node

    • This closes the loop and sends the response from ChatGPT back to the requestor.
    • Under JSON Response, return the generated summary:
      {
        "summary": {{$json["choices"][0]["message"]["content"]}}
      }
      

Your workflow should now look like this:

Webhook Trigger -> Set Node -> OpenAI Node -> Respond to Webhook

You can now test your workflow by sending a POST request with a text field to the webhook URL.

Quick Overview: OpenAI ChatGPT Node Fields

Here’s a table to help you quickly understand the important fields in the OpenAI node for ChatGPT:

Field Description
Model Choose gpt-3.5-turbo or a GPT-4 version if available
Resource Use "Chat" for chat-like interactions
System Message Set the behavior of the AI (optional)
User Message The dynamic content you want to process
Temperature Controls creativity (0 = focused, 1+ = creative)
Max Tokens Limit the length of the response

Example Workflows Using ChatGPT in n8n

Once you know n8n how to use ChatGPT model, here are some practical ideas you can build:

Smart Email Assistant

Use a Gmail trigger -> OpenAI node -> Send a reply based on email content. You can also train it to maintain tone using a system message.

Blog Post Generator

Input titles or topics, and let ChatGPT create outlines or drafts. Combine it with the Creatomate integration to turn text into social videos.

Conversational Agents

You can even build entire chatbots by maintaining memory and context using chat history. Learn how in this guide: Create a fully functional chat agent using n8n.

Tips for Using ChatGPT with n8n

  • Prompt engineering matters. The better your prompt, the better your results.
  • Use system messages to control ChatGPT’s role, tone, or restrictions.
  • Combine nodes. You can first clean the input using a Function node before feeding it to ChatGPT.
  • Limit tokens. If you're on a free or trial usage plan, keeping token limits low will help save costs.

Logging and Monitoring AI Workflows

When working with AI, it’s crucial to track outputs. Add a logging node like HTTP Request (post to Airtable or Notion) to store both requests and responses.

If your workflows fail, refer to this guide on mastering error handling to set up retries and alerts.

Use Cases Beyond Text

While summarization and chatbots are common, here are more advanced ChatGPT applications in n8n:

  • Translation (set system prompt accordingly)
  • Content rewrite with tone shift (e.g., formal to friendly)
  • Customer support pre-screening
  • Code explanation or bug diagnosis when connected to Git

FAQ

How much does it cost to use ChatGPT with n8n?

n8n itself can be free if self-hosted. The cost comes from OpenAI, based on tokens consumed. GPT-3.5 is cheap, while GPT-4 is pricier.

Can I keep a conversation going across nodes?

Yes, use the "chat" resource in the OpenAI node and maintain context by passing the entire message history each time. You can store history in a memory or database node.

What’s the difference between “Completion” and “Chat” in OpenAI node?

“Completion” uses older GPT models (like text-davinci-003), while “Chat” uses the newer chat-native models like GPT-3.5-Turbo or GPT-4.

Can I build multi-agent systems using n8n and ChatGPT?

Yes! n8n allows you to integrate multiple AI tools and build systems where different agents handle different tasks, as seen in CrewAI vs n8n agent battle.

Is there a limit to how long the input/output can be?

Yes. Each request has a token limit, including input + output. GPT-3.5 supports ~4,000 tokens, while GPT-4 can go up to ~8,000 or more depending on model type.


Once you know how to use the ChatGPT model in n8n, you unlock the ability to automate advanced, intelligent workflows that save time and generate value instantly. Dive deeper by connecting other services like Google Sheets, Gmail, and Drive to build fully AI-infused pipelines.

★★★★★
50+ fixes, templates & explanations
Stuck with n8n errors?
Node-by-node breakdown.
Copy-paste templates.
Beginner friendly.
Get the n8n Beginners Guide
Built by AgentForEverything.com
Comments
Join the Discussion and Share Your Opinion
Add a Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Newsletter
Get The Latest Agent Templates & Guides, Straight To Your Inbox.
Join the #1 AI Automation newsletter.