π Add to Chrome β Itβs Free - YouTube Summarizer
Category: N/A
No summary available.
00:00
Watch this. I'm sending a message to my WhatsApp automation.
You can see it received the message, processes it with the AI agent, and sends a reply back. Now, most people think that you need to go through endless verification on WhatsApp
00:15
Business Cloud and end up paying $50 to $200 a month in order to do this. But I'm going to show you how to build this exact same system completely free in less than 20 minutes.
This is my new favorite way to deliver WhatsApp setups to clients and it's incredibly easy to
00:32
set up. It's reliable.
So stick around and in the next 10 to 15 minutes you'll have your own WhatsApp API running locally with Docker connected to NADN with full message persistence and web hook support. I'll give you every configuration file and walk through each
00:49
step. We'll be starting with Docker desktop.
We'll set up the evolution API with Postgress SQL. create a public tunnel with ngrock and connect it all to naden.
Now, if that sounds complex, don't worry. It's actually really easy to do and I'm going to show you the
01:05
exact setup. If you're new here, my name is Shub.
So, I have the step-by-step instructions in my private school community, the AI automation incubator. If you're interested in joining, you can check it out in the link below.
So, we'll be installing the evolution API. We'll expose our API via an NGO tunnel
01:24
and we'll integrate everything into N8N. So to get this done, we need Docker Desktop installed.
We need N8N which we already have and you will need to use some terminal and command line processes, but it's it's very easy. So don't worry about that.
So first off, head to docker.com and download Docker
01:40
Desktop. Choose whichever operating system that you're using.
Once you've installed Docker Desktop, fire up the terminal and create a folder wherever you want to install the Evolution API. So, I'm on my desktop right now.
So, I'm going to type in mkdir
01:56
evolution- API. And then I'm going to type in cd evvolution- to get into that folder.
Next up, we need to create a file called a docker compose file. This file is a set of instructions that tells Docker what
02:13
prerequisites are needed to install whatever software we're working with. Evolution API in this case.
So, I'm just going to grab all of this, copy all of that, and then open a text editor. Let's use Sublime Text for now,
02:29
but you can use any text editor that you want. Paste in that file.
You'll notice that this file has some preset usernames and passwords. You can leave this as it is for testing, but I highly recommend that you change it whenever you use it for production.
You can leave everything else as is and then just hit save. Go
02:45
into the folder that you just created and call the file docker-mpose.yiml. Hit save.
That's that. Next, we'll need to create an environment file.
The environment file contains certain app secrets. The most important secret in
03:01
this case is going to be the API key. and we are going to create our own API key.
We don't need to get this from anywhere else. And I'll show you a quick and easy way to do that as well.
We also specify the port that we're using. Again, you can leave this at the default.
So, just go ahead and copy all
03:18
of this. Come back into your text editor.
Paste that in. And we need to replace this API key.
So, to generate a random API key, we can use chat GPT or Claude. Generate a random API key.
03:35
Just hit copy. Paste that in here.
Hit save and call the file env. And make sure you're in that same evolution- API folder that you had made earlier.
Hit save. If it gives you a warning, just continue.
And that is done. Next up, we
03:51
need to go back into the terminal and download evolution API and spin up our Docker container. So, let's go back to the terminal.
Make sure that you are in the folder that we were working with and type in docker composup-d. Come back to
04:06
the terminal and type in docker compose up d-d. Click allow if you once you hit that command you'll see that it's going to download all of the data.
It's going to download reddus. It's going to download the evolution API and it's also going to
04:22
download the postgress database. Now, since these are fairly large files, it may take a few minutes for this to complete.
So, just sit tight until everything is downloaded and installed.
04:39
And once that process is complete, you'll get the confirmation that all of these volumes and containers have been created and started. And we can confirm this by heading over to Docker Desktop.
And we will see that the evolution API containers are running. We have the
04:54
images and we have the volumes as well. All right.
So now that we've confirmed that the Evolution API and the database and everything is running, we can go ahead and test this in our browser. So I'm going to go ahead and copy this,
05:09
paste it in, and we'll see a 200 status. Welcome to the Evolution API.
It is working. Perfect.
Next, we need to be able to access our local computer from anywhere on the internet. And we'll do that using a service called ngrock.
So,
05:27
head over to ngrock.com. Go ahead and create an account.
It's free. I already have mine, so I'm just going to go ahead and log in.
Once you're in, just go ahead and download the agent for your operating system, Mac, Windows, Linux, whatever that may be. You can use the Homebrew
05:43
installation method or you can also download it as well. The instructions are pretty straightforward.
Download the file. Go ahead and unzip the file using this command.
Just make sure that the folder is correct. Um, go ahead and run this command, which will connect your
05:59
computer to your Ngro account. And the last step is to deploy the app online.
When you sign up, you're going to get an NGR domain that is unique to your account. And this is the domain that we'll use in N8 to actually connect to the evolution API.
The only difference
06:15
is that we're not going to use this command because we're not using port 80. We're actually using port 8080.
So I've already done this setup over here. So I'm just going to go back into the terminal and then type in ngrock http 8080 and I'll get a confirmation message
06:32
that the local host that we saw earlier is now being forwarded to this domain. So now that we have our URL, so we're just going to hold on to this URL for now.
We'll go back to the browser and connect our WhatsApp account to the evolution API. So we'll go to localhost
06:50
8080 which we had seen earlier and we're going to add / manager. So this is going to bring up the evolution manager where we drop in the server URL and we also want to drop in the API key that we generated earlier.
So let's go back to claude to find the API key that we
07:07
generated. Drop it in here and click login.
Not going to save that for now. So, here we have the evolution manager and this is where you can set up your WhatsApp web accounts.
So, to do that, I'm going to click on the instance button on the right. Give the instance a
07:22
name. I'm going to call it YouTube.
I'm going to call it YouTube tutorial. Under channel, leave it as Bailey's.
But if you have the WhatsApp cloud API, you can also use that. But assuming that you don't have it, just leave Bailey's.
07:38
Leave the token as the default. And you can either enter your number here or leave that blank.
Whatever works is fine. Hit save and you'll get a confirmation saying instant created successfully.
Now click on the instance and get the QR code to connect your WhatsApp web account.
07:56
All right. So I'm in and we'll see that I am connected.
It also pulled my WhatsApp display picture. Now to set this up with any there's one last step that we have to do and that is to head over to events web hook and enable a web hook.
So let's go ahead and enable the web hook first. We need to provide a URL
08:12
which we'll get from NAN. So let me go ahead and create a brand new workflow.
And for the first step, we're going to drop in a web hook. Starts the workflow when a web hook is called.
Drop that in. Grab the test URL for now.
But remember, once you move this to production, you're
08:28
going to have to change that to the production URL. I'm going to leave it at test for now.
Copy. Change the HTTP method to post.
and then come back into the evolution manager. Drop that URL over here.
Now scroll down. So there's a lot of different web hooks that you
08:43
could subscribe to, but for most WhatsApp agents, the only web hook that you'll require is messages_upsert. So this web hook will be called whenever you send or receive a message.
So I'm going to go ahead and enable that. Hit save.
If I scroll back up and
08:59
additionally, if you want to be able to process images and files directly, enable web hook base 64 as well. So, I'm just going to enable that.
Click save again. The web hook is applied successfully.
And we can go back into NAN and click listen for test event. And
09:15
then let me open up WhatsApp and just send a test message. So, this time I'm connecting it to my number.
Uh in the earlier demo, I had connected it to this number. So, I'm just going to go ahead and drop a message.
Hello. And we'll see that we have indeed received the message over here.
Perfect. Now, let's go ahead
09:33
and build out the AI agent. So, I'm going to go ahead and pin this so I don't have to keep sending myself a message to get this to work.
Let's give this workflow a name. WhatsApp setup YouTube.
Hit save. So, what we have set up so far
09:48
is the ability to receive WhatsApp messages. We also need to be able to reply to WhatsApp messages.
To set this up, we can either use individual API endpoints from evolution API. So, you have the send text endpoint, you have a send media endpoint.
Uh, this is
10:06
fairly complicated, but fortunately, if you have self-hosted NAN, there's a community note that you can install that takes all of that for you. So, let's go back into NAN and go to settings.
Click on community notes. And you'll see
10:22
that I already have Evolution API installed. If you don't have that installed, just go ahead and click the install button.
Navigate to this page. I'll leave it linked in the description.
Copy the name. Copy.
Drop it in here.
10:37
Click I understand and click install. This is not going to work for me because I already have it, but this is how you would do it.
And once that's installed, we can go back into the workflow and complete the setup. Now, a word of warning.
This community node is actually in Portuguese, but all the times that I
10:54
tested the English version, I was not able to get it to work. The Portuguese one works fine, and you should be able to figure out what the different endpoints are.
And we'll take a look at that as well. Let's go back.
So, now that we're back in the workflow, there is one problem that we need to solve. This web hook is fired anytime a message
11:12
is sent or received. Now, we only want the workflow to trigger when a message is received, not when a message is sent.
Because if you trigger it when the message is sent, it's going to get stuck in an infinite loop because it's going to send a message. As soon as that message is received, the web hook will
11:27
fire again and then you'll get stuck in an infinite loop and we don't want that. So, we can go ahead add an if node.
And if you scroll down to the data received from the web hook, you'll see that there is one data point called from me. And from me is now is currently set
11:44
to true. And in this instance, from me is true because it was me who sent the message.
So I'm going to drag this into here. And since this is a boolean, I'm going to open up the drop-down, go to boolean, and select is true.
And if I
12:00
click execute, we'll see that it has executed along the true branch. So if the message is from me, I don't want to do anything.
So I just type in do nothing. and that's that.
If the message was from somebody else, that's when we
12:16
want the workflow to kick in. So if the web hook goes down the false path, which is when from me is false, we can now add in our AI agent.
So let's drop in the AI agent for the source for the prompt is not going to be
12:31
the chat trigger node. Instead, we can define that below.
Collapse the web hook. go down and find conversation under message and drag that in here.
Assuming that the user input is the prompt that you want to work with. I'm not going to provide a system prompt for now since this is just a very basic demo
12:49
of how to set up the AI agent. We also need to give this AI agent a brain.
So, let's go ahead and drop in a chat model. Let's just use open AI to keep things simple.
We can also add memory so the AI agent remembers what has been said. You can set up more advanced memory uh using
13:06
Postgress but for this demonstration just use simple memory which is fine. Uh for the session key instead of the chat trigger note again select define below and for the key you can use the remote ID which is where the message was received from or who the message was
13:22
sent to. So just drop that in here.
And if you want you can give it any number of tools just to keep things simple. I'm just going to use the Wikipedia tool.
That's fine. And finally, we need to send the response from the AI agent back to whoever sent it to us.
So, we already
13:38
set up the evolution API node in NADN. I'm just going to go ahead and click the plus icon, search for evolution, open up the evolution API, and come down under this section, NVR texto, and forgive my pronunciation is send a
13:53
message. So, click here, set up your credentials.
I already have mine set up, but I'll show you how to do that again. So, I'm going to click create a new credential.
For the server URL, you need to grab the ngrock URL that we had earlier. So, go back into the terminal.
Find the ngrock URL. Copy.
Paste that in
14:12
here. And the API key is the API key that we generated using claw.
Copy. Paste that in here.
And hit save. And we'll see that the connection has tested successfully.
Perfect. I'm going to just hit save one more time.
I'm going to turn this off. and let's execute the
14:29
workflow. So let's unpin the web hook data.
Click execute. Come back to WhatsApp.
Let me send myself a message from that test number and we'll see that the workflow has triggered and it's gone into the AI agent. So let's go back, open this up
14:47
and complete the missing fields. So the name of the instance we can go to the web hook come down here and under body choose instance drop that in here.
Uh under the numero doestinario which is the destination number drop the remote
15:05
jid and under menage go ahead and drop the output from the AI agent. Now that's that hit save.
Now let's activate this say one more time and execute the workflow. And now if I send myself a
15:22
message from that test number, the workflow is going to trigger and it's going to send a reply back. Hello again.
How can I help you today? Perfect.
So there it is. A quick and easy way to set up WhatsApp using the evolution API.
Now this is for text
15:39
messages. If you wanted to send other kinds of messages, you could just go back into the evolution API, choose image, video, audio, document, and so on.
And at this point, we've only set up WhatsApp to run on our local machine.
15:54
Obviously, in production, this might not be practical cuz your machine may not always be online, but since we're using Docker, you can use any server which supports Docker containers. So you can use Digital Ocean, set up a Docker container, and repeat the entire process
16:11
that we did here on your Digital Ocean Docker container. Hook that up to Ngro and you'll have an always on API ready for you to connect to.
If you enjoyed this tutorial, I'd really appreciate it if you could give this video a like and
16:26
do remember to subscribe to the channel for more AI and automation content.