AI Income LabJoin AI Income Lab ↗

n8n WhatsApp AI agent with OpenRouter and Meta's Cloud API

Jump to video chapters

Watch on YouTube ↗ Subscribe on YouTube ↗

By · · 9:40 · 608 views

Written guide: n8n WhatsApp AI agent setup guide

An n8n workflow for answering WhatsApp messages with an AI agent: a WhatsApp Business Cloud trigger, an OpenRouter chat model with memory, and a send-message node, set up through a Meta developer app. The Meta side tests fine, but the n8n send step still errors because the business number is not yet verified, so the workflow does not run end to end.

Video summary

In this N8N automation tutorial, you’ll learn how to set up a workflow to auto-send WhatsApp messages to leads from your Facebook Page using N8N and Meta's WhatsApp Business Cloud API.

The video covers 9 parts: WhatsApp Automation, WhatsApp Trigger Setup, Meta App Creation, API Keys Configuration, AI Agent Setup, OpenRouter Model Selection, WhatsApp Send Message, Webhook Testing, and Final Automation Summary.

What this video covers

What you build

A two-part n8n workflow that receives WhatsApp messages through a Meta webhook, replies with an AI agent on OpenRouter, and is meant to send the reply back through the WhatsApp node.

Tools used

Key steps

Not covered

Summary written from the video's transcript and chapters.

In this video

  1. 0:00 WhatsApp Automation
  2. 0:40 WhatsApp Trigger Setup
  3. 1:20 Meta App Creation
  4. 2:10 API Keys Configuration
  5. 3:00 AI Agent Setup
  6. 3:50 OpenRouter Model Selection
  7. 4:40 WhatsApp Send Message
  8. 5:40 Webhook Testing
  9. 7:00 Final Automation Summary

Questions and answers

Does the automation work?

Not yet in this video. The Meta webhook test passes, but the send step errors and the number is awaiting verification.

Why OpenRouter?

Mike wants to avoid burning ChatGPT or Claude credits on a high volume of messages and can pick cheaper models.

How long does Meta verification take?

Mike expects two or three days after submitting the business information.

Transcript

Hey there, welcome to the channel. In this video, I'm excited to share with you a simple automation that you can build out within a few minutes here in n8n. This is a WhatsApp messenger automation for my Facebook page. So, I have a Facebook page with 176,000 followers that I've grown over many years. And as you can see here, there's just a WhatsApp button so they can send me a message.

The only thing is I want to free up time and automate some of the message replies and that's why I've built this automation here. So, it's really pretty straightforward to set up. I'll go through it in this tutorial. If you wouldn't mind, please subscribe to the channel, like this video, and let's get into it. So, first of all, we just have a WhatsApp trigger right here.

Read the rest of the transcript

In order to add this, you're just going to want to search for WhatsApp, select WhatsApp business cloud, and then come down to triggers, and drop in an on messages note. And what this is doing is it's just basically a web hook. You can find the production and test URL right here, which we will have to use for meta developers a little bit later. And then you can add your credentials right here. So you need the client ID and the client secret.

In order to get this, you need to come over to Metaphor Developers and click on create a new app. Then you will be able to create your app in a couple minutes. Doesn't take very long. So, I'm just going to enter in messaging and then I'm going to put in my email address here and click on next. Then you will have to select your use case. In this case, I'm just going to say create an app without a use case and select next.

Again, you will select the Facebook page that you want to connect this up to this particular app. Select my page over here which is just mike abroad on Facebook and then click next. This part you don't have to worry about. Click next again. And then you're just going to create the app and go to your dashboard. Now I already have an app created for the WhatsApp automation. It's just called messaging app right here.

So I'm going to click on that and then we can get the app ID, the client ID and the client secret which is under app settings and basic. So, we're just going to come over here. I can copy in my app ID right here. We're just going to paste that in over here as we've already done. And then also the client secret, which you can show.

You will need to enter your password and then you can get the client secret and put it in here as well. So, that step's relatively easy. All you have to do is create the app and connect it up with an N. And then you will need to use this web hook URL, which I'll show you how to do a little bit later. And then from there, you're going to want to drop in an a AI agent. So just select AI agent over here.

And this part you can connect up using a chat model. So in this case, I've actually just selected open router, which is really useful in this particular case because chances are I'm going to be sending a lot of messages on WhatsApp and I don't necessarily want to burn through all my API credits unlike chatgpt or claude. And the really nice thing about Open Router is that they provide the API keys basically for free. So you can use any of the major LLM models.

Just come on over to Open Router and then you can select models here and you can browse all of the different models including Open AI right here. In order to get your API key, you're just going to come up to your profile here and click on keys and you can create a new API key within a few seconds here. And then you're just going to copy and paste that in to your n8n workflow over here right here.

So you copy and paste in the API key and then it's verified. And then you can select the model. So as you can see there's a lot of different models to choose from including Mistral. We've we've got Metal Lama in here, Google Gemma, Google Gemini, lots of different options. And I'm just going to use CGP4 in this particular case. They don't have CGP5 in here yet as far as I know. Oh, they do actually. So they do have chatgpt 5 as well.

So we could use that as well, but I'm just going to use GPT4 for now. And then you can also select you can add a memory model in here as well. So that it has memory based on previous conversations and can reference those as well. And then the next step is you just have to once again add in another WhatsApp module or node here for sending a message.

Now, this part is not quite working for me because they make it a bit tricky uh in Meta Developers to verify the business information, which I'm still waiting on Meta to get back to me. I just submitted it. So, once that's done, I should be able to send the messages using automation, but basically all you have to do is generate an access token over here within Meta Developers. you can just uh reconnect your Facebook account and then you've got the access token right here.

But it says there was a problem registering the number. Right now I'm just using a test phone number until my actual number is registered. So as you can see here, it just says the number is unregistered. So it's going to take a while to actually get a reply, probably two or three days from Facebook. And then once that's done, I should be able to uh send messages through Meta Developers, the app that I've created here. For now, I'm just using a test phone number.

And if I want to add that access token, I can just come over here to the send message node and enter in the access token right here. And then you're also going to want to put in your business WhatsApp business account ID, which is this one right here. So you can just copy and paste that in. And if I click on save, it's going to say that it's been verified. I can also retry as well. And it says connection tested successfully.

But when I actually go ahead and execute this step, it has an error. So it just says problem running workflow. Please resolve outstanding issues before you activate it. So the only thing that I can think of is it's because my number is not verified yet. Even though technically I'm just using a test number for now. But we can actually come down here and test this as well.

If we come down to configuration, we can select the the different use cases or basically models or nodes that we want to use in this account. So, web hook fields right here. That's the word I was looking for. Web hook fields. We could just scroll down and make sure to turn on messages right here because obviously we want to be able to send messages. And everything else you can just leave turned off for now.

And if I click on test here, I can actually send a test to that test number. And it says successfully tested the message web hook field. So it seems to be working correctly over here. And I've made sure to add the callback URL which you get from the WhatsApp trigger. So this is the test URL right here. We can just copy and paste this in. And now we've got the verify token.

We can also attach a client certificate which I think we can leave turned off for now. And we can just go ahead and test this again. So there we go. It works fine over here in meta for developers, but it's not working correctly in n8n yet. If anybody knows how to resolve this or if I just have to wait for my number to be verified through meta, uh, drop a comment down below if you've already resolved this.

And here we can also send a test message as well. So, I'm just going to try to send a test message to my Google voice number. And it looks like access token is missing. So, I need to generate the access token once again and just select reconnect. Then I should be able to send a test message theoretically to this number. So I can put in my Google Voice number right here. Just going to click next. I will need to actually verify this.

So I'm going to get a message through Google Voice over here. But once again, it says there was a problem registering the test number. So I think I just need to wait for the number to be verified under here. And that's through here. So under API setup, you will need to verify your number. And that's pretty much all there is to it. So that's how to build a complete automation. It's only basically only two nodes inside N.

And once this is all working correctly, it will automatically respond to messages. And then from here, you can actually just connect up, you know, an open AI model and it can part pass it through that and respond to the message using something like ChatGPT automatically. So that's basically what we're doing here. We're just running it through open router and then we've also connected up the memory and then it can respond automatically to the person which is super valuable because it saves time and money for your

business. You don't have to hire a virtual assistant or someone to do this for you. And also the time to respond is very important for messaging leads and making sure that you're able to close deals through WhatsApp. In this particular case, I've also automated another thing on Facebook where it's just sending messages automatically using a tool called Send Pulse, which I've already made tutorials about on this channel. So, that basically responds to comments and send messages on Facebook.

But now, I also want to automate this process for WhatsApp as well. So, basically, I can just turn this on once all the issues are resolved and it will start running automatically. You can just set this to run every time you get a new message. And that's pretty much all there is to it. Hopefully this tutorial was helpful for you. Again, please go ahead subscribe to the channel and stay tuned for more automation builds in n8n and also make.com coming soon.

I'm trying to release two to three of these per week, sometimes more. So, with that being said, take care, stay safe. Peace from Thailand. I will see you in the next

Not ready to join? Get the weekly build notes: new guides and tested builds in one short email.

You may also like