📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

Build Your First AI Agent using ChatGPT in n8n in 5 minutes (No-code)

AI Agent Damian I Automation & No-Code5:45

Transcription

Today, I'm going to show you how to connect OpenAI models to your agents in n8n in just a few minutes, so you can build your first agent.

We will cover how to generate API keys and set up credentials so you can use models like GPT-4 or GPT-4 Mini, voice models, and embedding models.

We will build our agent on the n8n platform, and if you are not familiar with n8n, this is the best no-code platform for building agents and automation.

You can self-host it for free, and I've got a quick 3-minute tutorial on my channel, or you can go with their $20 a month cloud service, which includes a 14-day free trial and no payment details required.

If you are a beginner, don't worry; my channel has plenty of tutorials to help anyone get started. Use the link in the description to sign up, and let's get started.

First, we need to add the AI agent to our canvas. On the canvas, click the plus button and search for AI agent.

Now you can choose between different types of agents. For now, let's keep it simple and stick with the tools agent.

So now, let's configure the agent. Scroll down, click on add option, and you will see an option for the system message.

This is where you tell the agent how it should behave. For example, you can start with something simple like, "You are a helpful assistant."

Next, we need to choose our chat model. So let's click this plus button and search for OpenAI chat model.

We can scroll down; it's the last one. So now we need to connect our agent to one of the OpenAI powerful models.

To do this, you need to set up credentials. So click this little pen. As you can see, we need an API key to set up a connection.

Head over to openai.com/api, create an account, and log in. When you first create an OpenAI account, you receive $5 of free credits valid for three months.

Now click on settings. Under the usage section, you can see how many tokens you have used and how much you have left. This helps you keep track of your usage.

Now navigate to the API key section on the left-hand side and click on create new secret key. Give it a name, for example, "n8n demo."

Select project; it can be the default project, and hit create secret key. Now copy your API key, go back into n8n, and paste it right here.

It's saved? Yes, that's great! Now we are successfully connected.

So now let's add buffer memory so the agent can remember previous messages thanks to this note.

And finally, let's test it. So click on chat, and now you can ask the agent whatever you want. For example, "What's the capital of Thailand?"

Yes, that's it! You only need to go through this process once, as your credentials will be saved and used in other workflows.

Don't forget to subscribe to my channel. I will teach you how to build powerful agents and automation using no-code and low-code tools.

I am an AI and software engineer and have been running my automation agency for the past two years.

I have over 10 years of programming experience and a degree in software engineering and AI.

So see you in the next one!