📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

I Built a WhatsApp Chatbot + AI Agent in n8n for Small Businesses (free template)

The Recap | AI Automations36:19

Transcription

Over 200 million businesses use WhatsApp to talk to customers every day, and most of them have no automation, no AI, and no 24/7 support. That's a massive opportunity for businesses, agencies, and automation pros.

In this video, I'll show you how to build an AI-powered WhatsApp chatbot in N8N that can handle it all, from questions about hours and pricing to menus, locations, and appointment info in real time. We'll connect WhatsApp to N8N, plug in a large language model, feed it a business's website and docs, add guardrails for accuracy, and launch a rock-solid support workflow that runs on autopilot. By the end, we'll have a chatbot that turns inquiries into paying customers, even while you sleep.

All right, let's jump in. Let's go ahead and dive into a quick demo for our WhatsApp chatbot agent. Before we start chatting, I do got to run this green section here, which is going to be responsible for building the full knowledge base that's going to power all of our answers when we talk to the chatbot. So, I'm going to go over to this hotel that I stayed at last year that has a ton of different rooms, amenities, and events going on for its website and see if we can bundle that into a knowledge base. So, I got the URL. We're going to trigger this workflow, and that's going to kick things off. As this runs, we're going to go ahead and scrape every single thing from that website, bundle that together into a clean format, and then output it here so we can power every question that users and real customers ask our chatbot about that hotel.

Let's show this AI agent in action. Going from WhatsApp to our agent's brain here and replying with a message. "Hey, I'm going to be arriving by ferry tomorrow. Can you help break down how I should even get to the hotel? I know it's pretty far away and up the cliffs." So, that was just a transcription tool. I'm going to send this message in, and that should kick off our agent here from this WhatsApp message trigger, going into the brain of our WhatsApp AI agent, and then we should get a reply here pretty soon.

All right, so we got our message back, and let's go ahead and blow this up. So, we're very much looking forward to arrival tomorrow. You're correct. The hotel is beautifully set into the cliffs. That matches my experience. Here's a breakdown of the best way to reach us. Complimentary shuttle bus. So, that's the exact way that I ride. I remember it being a big confusion point when I first got to this hotel.

All right, let's move on to the next question. Let's see if we can ask it about the food options available at the hotel. I remember there being a breakfast service and this poolside uh bar that you'd be able to get food at as well. Let's see if it's able to come back with that information. So, I'll spin up this trigger and let's ask this question. "What uh food options are available at the hotel? I don't know if I want to go back into Positano every single night for food." We'll send that off. We got our trigger hit, and that's going to run through the agent once again.

All right, so we got a response. Let's pull this up. And I'm seeing the pool space, room service. That's something I remember as well. And we have the Las Sera restaurant. So that's covering both lunch and dinner. So it looks like that breakfast option was missing. Let's see if we can clarify that. "Are there any breakfast options?" Perfect. And there it is. That matches my experience with this buffet breakfast. Still at that same location as Lassera Restaurant.

Let's see if we can do one more here. I remember during my stay there is this funicular you had to take to get down to the beach club. And so let's ask how to get to the beach club. So we'll trigger this. "All right, how do I get to the beach club? I saw this listed on the website um but wasn't sure how to get down there if you guys are up on the cliffs." We'll send that in. Let's see what we get back. And perfect. We have our own private internal funicular for this very purpose. And then it breaks down some steps on how to get down there to the Remedies Beach House. Pretty impressive here. Answered all of my questions that I ran into issues during my stay. So honestly, I wish this existed prior to my visit.

By the way, if you want our team here at the recap to implement this exact type of WhatsApp AI agent for your business, just fill out that form linked down below and our team will be in touch.

So before we jump into N to N and go through node by node, I want to give you guys a brief overview of the game plan and the whole system we're going to be building. The first thing I want to cover here is actually going to be these first two bullets I have together. This is going to be the system we see up top here in green. That's going to be responsible for taking in a business website's URL, scraping together and extracting all information found on that business website, and bundling that information together into what I'm calling a business encyclopedia. This is going to be a well-formatted piece of markdown text content that's later going to get fed into our AI chatbot so we can respond to WhatsApp messages coming in from real customers. So that's going to be everything we see happening in green here.

After that's done and built out, we're going to move on to three and four, which are also together. This is going to be the setup process where we cover how to get started in WhatsApp Business API and how to connect those credentials into N8N. So, you're going to be able to use an AI agent to actually receive messages coming in from users and respond to those with the output of our AI agent. After that's done, we're going to go ahead and take the output of our business encyclopedia from before, wire that up to our system prompt here for this AI agent node, and so we can use all of that business information extracted from before to answer real customer questions.

Let's go ahead and dive into it. Let's dive in now to step number one, where we build our AI workflow to go ahead and scrape and extract all information from a given business website. I'm going to go ahead and click on execute workflow here for our form trigger that we have set up and then just paste in a URL of a hotel we want to build out as an example. So I just submitted that, and if I pin this, we'll have this for later executions. So very briefly, I'll pull this up. It's a very simple form where we have a text element with our website name here that we can just paste in and mark as required. So we received the website URL right here, and we can see this is the website we're going to try and scrape and gather all information for.

Let's go ahead and continue forward here to this second node, which is going to be called map website URLs. I'll go ahead and execute this and then chat through a little bit more about what is happening. So, if I open this up here, we're going to see that this is a Firecrawl node, which is one of the most recent community nodes added into N8N. Um, for those of you who aren't familiar, Firecrawl is this API and web scraping platform really built from the ground up with LLMs in mind. So, I'm a big fan. I use this to power a lot of my automations. And at a high level, basically, you can just give it a URL, and this platform is going to go out and return all of the text content in markdown format, which is perfect for us to later pass into a prompt or do extraction operations on top of that data received. So really helpful for speeding up your workflow, really helpful for what we're trying to do in this use case. For this first node we're calling into, we're going to be actually using this operation called map a website and get URLs. So I'll very briefly come over to the Firecrawl docs and just do a brief walkthrough of what is happening here. And so at a high level, we input a website and get all the URLs on the website extremely fast. Basically, we go one homepage URL as an input, and we're going to get a list back of every single URL that was able to be extracted from the website. So, we can see here we got a bunch of information like the gallery, um, different room options for this hotel, different bars, different suites. Um, looks like there's some information around restaurants and events, which is perfect for the information we want to consume when building out this business encyclopedia for our agent to have access to. So, this is a good start.

The other thing to mention here, I do have a Firecrawl API credential set up. If you need to set this up, go ahead and click new credential. Leave your base URL as the default here. And then if you log into the Firecrawl dashboard, you can come over and just grab your API key from the right-hand side of this dashboard. Paste it in, and then you'll be able to get up and running with this community node.

Let's move on to the next nodes. Here I have a little bit of data cleanup where I'm going to split out that list of links from before. We're going to go ahead and filter out any, you know, media files so we don't eat up the large context window we're going to be later processing this on. So, this is going to be things like, you know, gallery media uploads. I don't care so much about just images getting included in our business encyclopedia. And so, that's why I set up this exclude media filter this way. Depending on your business, your client's business, or your use case that you're building this for, you may need to think about this differently or approach this filter a little bit differently. It just depends on what you're doing and what you're building. So, just keep in mind you have that option there, or you could exclude this if you do want that media included. So, we're going to take that data. I'll go ahead and just run this here so we can see that data get filtered down. So, it looks like we kept 69 out of the 70 items that were extracted.

And then we're going to go ahead and run this scrape node, also built into the Firecrawl community node package, which is going to take in a single URL that we passed in, and it's going to scrape that page. Underneath the scrape options, I have this markdown format selected, which is just like what I was talking about from before, where we pass in a link. We're going to ask Firecrawl to go ahead and scrape the text content from this page and return back to us well-formatted markdown text content. So we don't have to worry about, you know, processing a bunch of the ugly HTML that we see on the page here and really keep down the token count when we're running a large prompt against this. So if we try to pass in just all this HTML, that's going to get expensive and very slow, and we may actually hit token limits depending on how many pages we're really scraping here from the business website. So I'll let that run here really quick, and we'll come back as soon as this scrape operation finishes.

All right, we're back, and we can see that we got 69 pages inputted and 69 resulting items outputted from our scrape URL operation. And so if I very briefly just look at this, we can see for an individual item here, we got success is equal to true for one page we tried to scrape. And then underneath here, we have this nicely formatted markdown content of all of that text content on the page, which is exactly what we're looking for.

On to the next step. I'm going to go ahead and execute this other filter I've set up, which is going to filter out any errors that happened during the scrape operation. And so maybe there's something set up on certain pages like a form where, you know, they have more enhanced security, and we don't necessarily care about that as much. And so we don't want, you know, this error message to later get included in this context we're building up and passing off to an LLM to build our business encyclopedia. And so it looks like in this one, we had one error happening. "Your request is invalid or cannot be processed by the service." Looks like an edge case here for some page that may be a bit more locked down or JavaScript heavy or just, you know, hit some kind of issue. The way we do this is we just use the JSON check here and we check that it does not exist. If that is the case, we're going to go ahead and keep that item before passing those 68 items through the rest of the pipeline. And in order for that to work, what I did on the previous scrape URL node, I'm going to go ahead and select this continue option under "on error." So that error message always gets passed through for us to consider in that filter.

Going forward, we now have this aggregate node and then this set field node, which are going to do some additional data transformations. So we'll go from these 68 items here to one item in our aggregate node where we use that data property and bundle everything together into a single output item. And then using that single output item, we're going to go ahead and do a JavaScript expression here that lets us format that markdown a little bit nicer for a later prompt we're going to be using. And so I set the website URL at top here. And so that's going to be the hotel we're trying to build this chatbot for. And then I'm using this JavaScript map expression that's going to go ahead and take every single page that was extracted, iterate over those, and give me some clean formatting here of what's the page title, what's the page description, what is the URL of the page that was scraped, and then underneath that, the important one is going to be returning the markdown content that was previously scraped. So we have this metadata up top. We get into all of that markdown content from the page we were able to extract. And then as we scroll down here, we can see we have a separator here where we join these results together by slash new, which it means new line, a couple of these separator dashes, and then another new line, which lets us set up the next page. And so we have this really big text field now that we're going to be able to have nicely formatted and passed into an LLM for further prompting. And so that's going to be the next step. We're going to do exactly that.

So I'll execute our build encyclopedia node so that can get started running, and I'll briefly walk through the prompt we have set up here. Like all other prompts we do in our agents and automations we build, always like to start out with number one, the role. What is the perspective role and what's the setup for this prompt? Going down, we then have our prime directives and the goals that this prompt is trying to accomplish. So we want information integrity. We want all information to be kept in here. We want this to be organized for hotel support. This is something where if you're building this for a non-hotel or non-hospitality business, your prompt may deviate a bit. For our case, we want this highly tailored for hotels. And so, we set it up this way. Make sure you change this if you're building this for different businesses. Going on, you know, no hallucinations. Again, tying back into the integrity of the data we want to be returned here. Deterministic structure. We want a well-formatted encyclopedia that is going to remain the same structure across multiple runs. And then source traceability for any information that was extracted. If you remember from before, we are passing in that URL from the page it was extracted from. This is setting up our agent and our encyclopedia here to be able to provide a link back to the source URL page of the hotel's website if a question comes up that is relevant to that, you know, website page, or we want to send that customer down the path to read more on the website. Not going to go through everything here. We will include this full prompt and this full N8N automation template completely for free if you click on that first link in the description of this video, which is going to be our school community. And so if you click on that, you're going to be brought to our school page here called AI Automation Mastery. In order to download the template and the prompts used for this video, just go to that N8N template section, find the post that matches the title of this video, and then you're going to be able to scroll over here and download the JSON files for all of the N8N templates and any markdown files for the prompts that were used throughout the whole process. Be sure to check there and join the community if you want to get access to this completely for free.

Going forward, we're going to be defining briefly what happens with our input format. Basically just breaking down that we're going to be passing in scraped pages and then dynamically inserting those scraped pages we built out from before. And then we're going to be detailing the output format we expect this prompt to fulfill as it's being executed by the LLM.

While this is running, there's one thing I do also want to make mention of, which is going to be the model selection for executing this prompt. I opted to go forward with using Gemini 2.5 Pro here, really because of the large token limit and large context window it's able to support. Other models like Claude have a bit of a smaller context window. And so if you're scraping a really large website, you know, kind of like a hotel that can have, you know, multiple room options, suites, restaurants, pools, bars, different policies and procedures, things like that. That's going to get really big as you bundle everything together and pass into this prompt. Would encourage you to also use Gemini 2.5 Pro here just to get good output from this very large context window and not run into token limit errors.

Looks like our prompt actually just finished running here. Let's go ahead and execute this final set encyclopedia result node so we can see what this looks like when everything is formatted together. We have some metadata up top for everything that was processed. A nice table of contents that was built out, going through all of the categories that we talked from before in that prompt construct section. And if we scroll through here, we can see a very detailed breakdown of everything this hotel is able to do, including its amenities, gyms, restaurants, rooms. Everything that we're talking about before, all gets included in this encyclopedia.

That covers it here for the initial setup for workflow number one. That's going to be building out our chatbot business encyclopedia. What we're going to do going forward here is going to be, you know, taking the output of this, copying this over, and then setting this as part of our system prompt in the WhatsApp AI chat agent. So it's always going to have that as a reference when answering questions.

One thing I do want to, you know, answer right now because I'm sure I'm going to get questions around this is why did I decide to go the direction of building an encyclopedia like this for the prompt instead of, you know, setting up a RAG pipeline? That's been something that's a bit of a hot topic and kind of up for debate recently. And so do want to address this right now and kind of share my take on the whole RAG system. My opinion on this is I think when you're starting out to build something, especially something as simple as a chatbot, it's always better to go for the most simple solution in the beginning. You know, the principle, "Keep it simple, stupid." That's an approach I want to embrace here and really reduce the number of moving parts that are going from receiving a user question to processing that question and returning a result. Yeah, you could set up a RAG pipeline and, you know, have some fancy retrieval system that's going to try and pull out the question exactly correct. But I think the more complexity that you layer in, there's more places where things can go wrong. Chunking is one problematic area. If you don't have a very strong strategy for chunking your data extracted from the website, you're going to increase your chances of getting hallucination or unhelpful information getting returned back to the user. Another area for more complexity here is there's just more services involved. You have to, you know, save everything that has been extracted in chunks into a vector store. You then, on every chat message, you're dependent on that vector store to be online and stable and operating fast to get a result back from there. If you're doing everything just in a system prompt and have a model that can handle it, like Gemini 2.5 Pro or the 2.5 series, that's one less moving part where things you have can go wrong. You're only dependent on the LLM being online instead of both an LLM, some vector store, and maybe even some reranker service all working together. Things can just go wrong. I fully encourage you guys, depending on your use case and your setup, to go for the most simple solution when you're building out AI agents and automations because more moving parts is going to mean that more things can break on you and go wrong.

Let's move on to step number three here, which is going to be setting up our connection and credentials inside of N8N, that's going to be able to communicate and connect with WhatsApp. This is going to allow us to trigger N8N automations and agents when we receive messages to our WhatsApp number, and it's going to allow us to reply back to the messages we're getting from customers from whatever response that our agent decides and pulls out from our business encyclopedia. So, let's go ahead and set this credential up from scratch so I can take you guys through all the steps because there's a fair bit involved.

The first thing we need is going to be our trigger. So, let's go ahead and add a WhatsApp Business Cloud trigger. And we're going to use this "on messages" trigger. And if I come here and click "create new credential," we're going to be prompted for our client ID and client secret that we don't have yet. We need to go over to business.facebook.com to go ahead and set up a new app that we're going to be able to plug into here. So, let's do that.

Now, I'm on business.facebook.com, facebook.com, and I'm logged in and am defaulted to my business portfolio that I've already gone ahead and created. If you're getting set up here for the first time, you may or may not see something like this. And so to create a new one, just click on this dropdown, go to "create a business portfolio," and go ahead and fill out this form with your own details. You're also going to be required to go ahead and verify this account either with a credit card number or a phone number verified on file in order to go forward with creating the app. So, be sure to do that as well. If you're setting this up for a client's business, you're going to need to get invited into their business portfolio account or have them set this up first so you can create and manage apps on their behalf.

Let's go ahead and do that now and set up this app. So, we'll come down to our business portfolio that we want to use. We'll go to "Accounts," "Apps," and then click on this "Add" button. We're going to go ahead and select "Create a new app ID." And if you don't have your account verified yet, that's where you're going to need to go through these verification steps with your phone number or credit card. I've done that already, so I can just click here. And that's going to take us to developers.facebook.com and take us through this wizard to set up our app. So I'll call this "N8NLucasHotel." We'll leave the contact email. And on "Use Cases," we want to scroll down to the bottom and click on "Other." That's going to take us to this step where we select what type of app we want to build. Make sure you are selecting "Business" here because you're not going to be able to change this in the future. Review all the details. So, N8N Lucas Hotel, we got our email, and we have our business portfolio selected here. This all looks good, and we'll go ahead and create this.

That's going to take us back to another page on developers.facebook.com. And we should have our new app selected from that dropdown. So, make sure you're on the correct app if you have multiple. We're going to go ahead and click on "Set up WhatsApp." And finally, we're going to come back here to "App Settings," "Basic," and we're going to see our "App ID" and "App Secret." These are going to be the first two values we want to grab so we can listen to triggers coming in from WhatsApp messages. So, I'll copy that now and we'll bring this into our N8N credential. So, client ID, app secret, we'll paste that in. And if I save this, we should get a green value here. So, our connection was successful. That's setting up step number one here for getting our WhatsApp trigger up and running.

So, now that we have our credentials set up here for the WhatsApp trigger, let's go ahead and build a simple AI agent that's going to be able to receive that message and come back with a response. So, we'll grab our AI agent node that's going to be connected to the chat trigger. We'll pull in an OpenAI chat model. Let's just use GPT-4o mini here. And let's go ahead and add in our final node we need here, which is going to be responsible for replying to the WhatsApp message we just received. So once again, we'll search for WhatsApp Business Cloud. Go under "Actions," and we want to use this "Send Message" action. If we come here to credentials, we're going to see we don't actually have that credential we created from before. Unfortunately, we do need to make a brand new credential to handle the sending of messages. But don't worry, I'm going to take you guys through that right now.

So, we'll create this credential. We're going to be prompted for an access token and a business account ID. So, let's come back over to our Facebook account inside developers.facebook.com. Make sure we have our app selected. We're going to come down to the left-hand side here under "WhatsApp." Click "API Setup" and load that page. The first thing we got to do here is click on "Access Token," and we're going to go ahead and click "Generate Access Token." That's going to take us through the series of guided steps where we need to approve this through our connected Facebook account that's logged in. So, I'll continue as my account, opt in to the current WhatsApp account only. I'll select that account. I'll review this, click "Save," and make sure that looks good. So, we have been connected to N8N Lucas Hotel. So, that's perfect. I'll exit out of there. And then we're going to have our access token that's populated. Let's go ahead and copy this. Come back to our N8N credential and paste that into the first text input. We then need our business account ID. We'll come back here to the developers.facebook.com website. We're going to look for the second section here where it says "Our WhatsApp Business Account ID." We'll copy this. We'll paste this into our credential, and then we're going to go ahead and save that. And we should get a green connection status. So, that all looks good. We now have the second credential set up that's going to allow us to respond back to incoming messages.

Let's open this up and fill out the details here so we can get a real message going back and forth. Let's select the test number from our account. Let's fill out our own number just for testing purposes. In a real scenario, we're going to go ahead and grab the sender's number so we can dynamically reply to each customer messaging in. But we just want to get a simple back and forth message working for now. Under "Message Type," we'll leave this at text. And then we'll say, "Hello from N8N hotel test." So we have that filled out, and that completes the setup we need for our simple WhatsApp trigger to a reply.

Final step that I just missing here is going to be actually connecting our AI agent to use the message that was sent in. So let's change this from "connected chat trigger" to "use defined below." And we're just going to go ahead and grab the text body that was passed into our WhatsApp trigger. So we can see, um, I just have a test message here, and that's going to get populated as the user prompt into our AI agent.

So let's go ahead and do a full test here of this end-to-end WhatsApp trigger to an AI agent to responding to a message. I'll go ahead and click on "Execute Workflow," pull up WhatsApp, and start a chat with this number here. This is going to be the exact number that's defined under our developers.facebook.com app we just spun up. And so we can see from test number, we're just going to copy that number, start a chat in WhatsApp, and be able to start talking to our agent. So I'll say, "Hello, can you help me with my hotel questions?" So we'll send that in, come back to N8N since we're listening. And we can see we got our message received from this trigger that's getting passed into our AI agent. And finally, we're going to send a message here at the end. It looks like on this one, we actually hit this error that I want to walk you guys through how to fix. So, "Bad request, please check your parameters. Recipient phone number is not in the allowed list." And so when using this test phone number here, looks like we do need to come back to our app inside the developer Facebook hub and go ahead and configure our own phone number here on the allow list. So I'll go ahead and add mine in. Hit next. We'll verify it. And it looks like we have that now whitelisted. So let's come back to N8N one more time. We'll go ahead and click "Execute Workflow." So our trigger will be listening. We'll pull up WhatsApp again, and let's just send the same message. See what we get back. So we got our WhatsApp trigger ran through our AI agent, and now we have a successful send message node here that is going to be replying with "Hello from N8N hotel test," and that matches what we defined here. So there you go. There is the end-to-end credential setup between WhatsApp triggers, WhatsApp message sending, all to an N8N agent.

Let's now move on to step number four here, which is going to be tying everything together by adding in all of our new credentials to our WhatsApp agent defined here. And then we're going to take that business encyclopedia we built from before and weave that into the system prompt for our AI agent so we can start answering real questions coming in from real customers.

So I'll come here. First thing we got to do is reactivate our two nodes here for the message trigger and sending a reply. Just like what we did from before, we don't have to go through the full setup again, but we want to trigger on message getting received. And we want to add in our credentials from before. It doesn't look like that's appearing. So, I'll give this just a quick refresh. And we should see our WhatsApp OAuth account added here. That's going to trigger on messages. So, that looks good. Let's go ahead and trigger our WhatsApp agent and see if we can get some test data coming in that we can work with. And so, I'll send another one. Say, "Hello hotel." And we should get this message appearing that we can pin and grab these properties out of. So that matches what we saw from before.

Let's now see if we can change this to a "defined below" user prompt. And then go ahead and drag in this user message here that was sent in from my WhatsApp message. So we have "Hello hotel" appearing as before. And now we're able to move on to the system prompt. This system prompt is going to be customized pretty heavily depending on what type of a business you're building this chat agent for. Again, our chat agent is going to be heavily geared towards the hospitality and hotel industry. And so, we're setting up the role here as a friendly and professional concierge for the hotel. So, we know we have a name here as Alex, and our sole purpose is to assist guests and potential customers by answering their questions via WhatsApp. So giving our agent context here on what its role is, what it's going to be doing. And below here is where we kind of define the playbook that Alex, our concierge here, needs to follow when answering questions. And so of course, kind of the basics here, like analyzing the request. We want them to read the user's request message and truly identify what they're asking for. Next, this is going to be an important one where we say to consult the encyclopedia. Um, this is going to be something we built to avoid hallucinations, avoid information getting made up or just incorrect facts. And so before formulating any answer, you must perform a deep research and targeted search within the hotel encyclopedia. This is going to be something we pass in here at the bottom, separated by this triple dash divider and this encyclopedia header. What I did when building this was I came back here, you know, took the output from our previous run on this green step, blew this up, and simply just copied what's here on the right side, and so I could use it in the system prompt. So, I'll grab this again, and we can just go through the process of re-adding that. And so, pretty big here, as you can see, as I scroll through this entire encyclopedia. Basically, it's covering everything we scraped from before that's going to be in this AI agent system prompt for it to reference at a moment's notice. And so that's part of this big prompt too. I really want to reiterate is consulting the encyclopedia before forming any answer. After that, just giving a bit more information on how to formulate an answer, what to do when information is missing, and detailing some additional rules and constraints for this AI agent to follow. If you want to get even fancier, you can, you know, control the agent's personality and give examples here for the tone it needs to follow. So I will just go ahead and refresh out of this since I had that set up before, and we can continue forward with the rest of the setup.

So we have our trigger, we have our agent getting that user message passed in, and we have our system prompt with the included encyclopedia for everything we scraped from before. The last thing we got to do is reenable this and then we're going to be able to reply to the message that was previously received. So, let's go ahead and listen to this message trigger so we can get a response back from our real encyclopedia.

So, I'm going to go ahead and ask our agent, "I will be arriving via ferry, how do I get to the hotel?" So, I'll send this in. We should see our trigger go through, and it does look we are missing one step with our sub-node called memory here. This is actually an interesting one that I'm glad came up so I can explain to you guys better how to approach this. When we define our memory key here, this is not going to be like a regular chat session where we're just chatting in and out of the window here. For a regular AI agent, we're going to be setting this up a little bit differently, and I want our agent to remember past messages that have came in from the same phone number. And so the way we're able to do that is by configuring a key here on our memory node. So we're going to change this to "defined below." Let's go ahead and do this as "AI hotel agent" as our prefix. And then I want to see if we can get that user's phone number as part of this key here. Let's go ahead and pin this. Execute this again so we can get some data pre-filled. So now we have all this context on the left-hand side here from our trigger into this system. I want to see if we can grab our message trigger and go ahead and get the phone number that was included here. And so I think that's under "contacts." And I'll just grab the first value of that and see if I can get an ID. So there we go. We have an identifier for the phone number that was just passed in. And that's going to be a unique key that gets saved here for, you know, every concurrent conversation going back and forth with customers. And so you can have, you know, five phone numbers messaging in at once. And by setting up this unique key here, you're going to avoid, you know, memory getting saved and shared across different customers. This is just something you you should set up in order to avoid the AI agents giving bad responses back or accidentally sharing details from another person's conversation. Let's go ahead and increase this context window to 30 just to give it a bit more history for any phone number messaging in. So, I'll go ahead and save that. Let's unpin this and give it another run here end-to-end.

So, I'll go ahead and click on "Execute Workflow" for message trigger. I'll go ahead and ask this question again. And we should see this kick off. So, our memory is working this time. No error. We're using the Gemini 2.5 Pro model as the brain. We should get a good answer back here that references the encyclopedia we built up. So, if I remember correctly from my stay there, the best way to get to the hotel is going to be going up some stairs and waiting for a shuttle at the street that's about at the midpoint. Let's open this up and see what the result is. So, "Hello. We're looking forward to welcoming you once you arrive at the ferryport in Positano. You have a couple of great options to get to the hotel. Complimentary shuttle, which is matching what I expect. We offer a free shuttle service for our guests that runs hourly. You can catch it from the Parco Thorne stop in the center of Positano for the short 10-minute ride up to the hotel." And then they have this extra water taxi service. So, honestly, pretty great example here that was able to be scraped from the web page of this hotel. So, pretty awesome so far.

The final thing we got to do here is connect the send reply node up. I'll go ahead and click D to reactivate it. I'll go ahead and blow this up and let's see if we can get the correct values wired up here. So, compared to what we did the last time where we just hardcoded a phone number, we need to come over to the message trigger here and go ahead and grab the WA ID, which is going to be the phone number of the person who sent in this message because we don't want to reply to, you know, your test number every single time. We want to make sure we're sending our message back to the person who messaged in. Going forward, we'll keep this as text. And then under text body, let's go ahead and go to the output of our WhatsApp AI agent. We'll drag that in, and that is going to give us this nicely formatted answer we had from before. So let's just click "Execute Step" and see if this sends. Looks like we got a success. And then we can see this nicely formatted message here breaking down how to get to the hotel after arriving by ferry. So pretty awesome. Um, it looks like we have a little bit of room for improvement here on the formatting of this message itself in order to stick to the WhatsApp messaging standards. And so that's something we're going to be able to address in the prompt here just by getting a few more iterations in.

>> All right, before you go, make sure to hit the like and subscribe button. Seriously, do it because we're going to be breaking down all of the AI automations that we use to run all of our businesses. They're super helpful, and we're going to break down exactly how we do them on this YouTube channel. So, make sure like and then subscribe, and then you'll get notified when we publish new workflows that can make your businesses run 20 times more efficiently, just like we're seeing here at the recap and the other businesses that we're running. The other item is join our school community for free. The link's in the description. You'll be able to get this template, this automation that we just ran through in this video, completely for free. You can go to school, navigate to the video that you want, and then you can download the JSON output for the N8N automation. So like and subscribe. Join our free community to get this automation for yourself.