Facebook Messenger bot with ChatGPT and Make.com
Watch on YouTube ↗ Subscribe on YouTube ↗
Written guide: Facebook Messenger Auto-Replies With Make.com and ChatGPT
Build a Make.com scenario that watches Facebook Messenger, drafts a reply with ChatGPT and sends it back, then set up the Facebook developer app and webhook it needs. The bot is not shown working live because Meta business verification was not yet approved.
Video summary
Make.com tutorial for a Facebook auto-reply bot / Messenger chatbot without custom servers.
The video covers 12 parts: Introduction to Messenger Bot Automation, Key Benefits & How Automation Saves Time, Setting Up a New Scenario in Make.com, Creating Your Facebook Developer App, Connecting Your Facebook Page, Configuring Web Hooks and API Setup, Integrating ChatGPT for Replies, Sending Automated Responses via ChatGPT, Troubleshooting Web Hook Issues, Business Verification & Permissions, Testing and Going Live, and Conclusion & Final Tips.
What this video covers
What you build
A three module Make.com scenario that receives Messenger messages through a webhook, creates a reply with OpenAI, and sends it back on Messenger.
Tools used
Key steps
- 2:15 - Create a new Make.com scenario with the Facebook Messenger Watch Messages trigger, a webhook and a verify token of your choice.
- 3:30 - Create an app in Facebook Developers with the Other use case and Business type, linked to your Facebook page.
- 4:41 - Connect your Facebook page to the app and generate the page access token.
- 8:12 - Add an OpenAI Create a Completion module that writes a reply to the incoming message text.
- 9:47 - Add a Messenger Send a Message module using the access token and map the ChatGPT result into the message text.
- 12:04 - Fix the failing webhook verification by creating a new webhook in Make.com and pasting its URL and verify token into the app.
- 13:36 - Request the pages messaging permissions and submit business verification before switching the app to live.
Not covered
- A real message and automated reply are never shown, since business verification was still pending.
- Replying to Facebook comments is not covered, and Mike says he is unsure whether that is possible.
- Prompt design for safe or on brand replies is not tested beyond a one line instruction.
In this video
- 0:00 Introduction to Messenger Bot Automation
- 1:30 Key Benefits & How Automation Saves Time
- 2:15 Setting Up a New Scenario in Make.com
- 3:30 Creating Your Facebook Developer App
- 4:41 Connecting Your Facebook Page
- 5:36 Configuring Web Hooks and API Setup
- 8:12 Integrating ChatGPT for Replies
- 9:47 Sending Automated Responses via ChatGPT
- 12:04 Troubleshooting Web Hook Issues
- 13:36 Business Verification & Permissions
- 15:37 Testing and Going Live
- 17:15 Conclusion & Final Tips
Questions and answers
Why did the Messenger webhook fail to verify?
The callback URL kept failing in the Facebook app. Creating a brand new webhook in Make.com and using its URL and verify token fixed it.
Which ChatGPT model is used for replies?
A GPT-4 model is selected in the OpenAI Create a Completion module and asked to create a reply to the Facebook message.
What is needed before the bot can go live?
You need to request the pages messaging permissions and pass Meta business verification, which involves uploading ID that matches your personal profile name.
Keep learning
Transcript
Hey there, welcome to the channel. In this video, I'm going to show you how to build a Facebook Messenger bot, which uses ChatGPT to respond to messages automatically on Facebook. And we're going to be using Make this. So, I've actually got an article open right here that shows how to build out one of these automations. And it's going to look something like this. and we're going to be building it out in this tutorial. So hopefully you enjoy watching. Please subscribe to the channel.
If you get value from this tutorial and let's get started. So I'm over here in the help center form make.com and this flow is showing uh an automation which will watch for messages on Facebook Messenger and then decide what to do based on some sort of filter here. So, we're passing it through a router and it's going to send a message or it's going to perform some sort of action on the message, transform it, create a reply, and send it back in Messenger.
Read the rest of the transcript
So, this is a pretty simple automation to build out. It's not going to take very long. Pretty much the most difficult part is setting up the app within the Facebook developer developer portal. So, that's something we're going to have to do. And then this will basically just automate your message sending on Facebook, right? So it saves time and money for your business. That way you don't have to hire a virtual assistant or do it yourself. You could just automate the process.
And for me, I have a Facebook page with about 166,000 followers on it and I get a lot of messages and comments as well. I'm not sure if there's a way to do this for comments. Um, but it can respond to messages automatically. So, if you want to save time and money for your business, this is a powerful automation to build out. And if you want all of the templates, including this one, there's a link to join my Skool community in the description below.
You're welcome to check that out. And with that being said, let's get into it. So, I'm going to come over to make.com. This is my scenarios tab right here. As you can see, I've got a lot of them built out already. And in this case, I'm just going to create a new scenario. So, I'm going to click up here. You could also choose to use a template to do this as well, but in my case, I usually just build them from scratch.
So, I'm just going to type in Messenger right here. And right away, you will see there's a Facebook Messenger app right here. And I can just click on watch messages. This will trigger when a new message is received. So, that's all there is to it. And then you will need to add your web hook right here. So that's just a listening device basically that will be monitoring for new messages. And you can just type in your verify token which can be anything.
You can just make whatever up you want here. And then you'll just connect up your web hook. And this we're actually going to put into the app in Facebook developers. So this web hook right here. Just going to copy and paste this and put it into our app. So now that this is connected, it's going to be listening on this web hook right here. And so now we're going to come over to developers.fas.com/apps. And this is where we're going to create our app for Facebook Messenger.
So I'll come back over to the help article here. As you can see, we need to create an app. Choose other. Uh add the app name. create the app and then select messenger and click setup. So that's what we're going to do here. We're going to click on create app and I'm just going to call it ma messenger auto automated messenger, right? Let's try that.
There should be a way to connect it up to my Facebook page because that's where I actually want to be listening for the messages. And then we're going to add the email address. And under use cases, we're just going to select other right here. And then click next. And from here I believe I'm just going to we need to create and manage business assets like pages. So I'm going to select business. And this is where we select. Okay.
So here I can actually select my business portfolio. I'm going to connect it to the app to my Facebook page right here. This is the particular one that I want to uh send messages on. So we're just going to click on create app. and do need to verify here and that will create the app for me which I can then use for verification and connecting it up in make.com. So I did receive a code on my phone so I just need to enter that real quick.
There we go. Authentication is required in order to create the app. It takes a little while, but should be created any second here. There we go. So, it's now created our own custom app inside Facebook developers. And this is where we're going to set it up so we can customize the way we interact with people on Messenger. That's what we want to do. So, I'm just going to click on set up right here. And this is where we're going to set up the API right here.
So, it looks like we have to refresh the page. Now, here's the web hook right here. So, we're going to copy and paste in that particular web hook that we got from over here inside make.com. We're going to put that into our custom app here. And then for verify token, we can just put messenger app. It can be whatever you want. And then we're just going to click on verify. and save. Looks like the callback URL of verify token couldn't be validated.
Please verify the provide information or try again later. Um, so I may need to refresh this page. It looks like let's give that a try. Just going to come back over to tutorial here. Scroll down. Configure web hook. We need to add the callback URL, which is what I've done. You'll be prompted to fill in the edit callback URL and verify token fields. this these required values can be generated through make. Right? So let's try that again. Looks like it was having an error before.
Just going to enter in the verify token and click on verify save. Hopefully it works. Fortunately, it's still not working. So need to figure out what's going on here. I'm going to copy that to the clipboard. Come back over here and verify and save. And once again, it's still not working. So, for now, I'm just going to connect up my Facebook page. Maybe I need to do this step first to generate access token and set up web hook subscriptions.
So, I'm going to log into my personal profile and then select my Facebook page right here and then click save. So, I may need to do this step first before I connect up the web hook. There we go. So now the Facebook page should be connected to the app and there it is. Now we need to add subscriptions. So in this case I want to be monitoring for messages, right?
So I'm just going to select messages here and looks like once again having an issue with the web hook. So hopefully nope, still not working. So let's generate a token because I'm going to need this for another step. That's the uh access token right there. So, we're going to come back over here and just start building out the automation for now. So, next step is we can just send a message right away or we can perform some sort of action on it.
So, in this case, I want to run it through ChatGPT and come up with a response for the message. So, I'm just going to select OpenAI ChatGPT create a completion right here. and mine's already connected. You will need to do this uh through platform.openai.com. You need your API key. I've already shown how to do that in many of my other videos, so you can check those out. And for model, usually I just select uh GPT4 latest right here. So, I'm going to use GPT4.
And now I can select a role. So user and text content is going to be the message text right here. And I'm just going to tell it to create a reply to this Facebook message. Right? And then you enter in the message text that you get from the previous step. That's all there is to it. And completion tokens you can just leave as 2048. That's good. So now it's going to watch for messages.
get the message, run it through ChatGPT to create a response, and then the last step is just going to be to send a message. So all this is going to do is first of all, I need that access token that I got from my app. So I'm going to enter that in and it should create the connection here. And there we go. So in this case, message type is going to be response and I'm looking for message text right here.
So for message text, I'm going to simply click and drag in the result that ChatGPT generated right here. And that's going to be we don't really have to worry about this. We can leave it empty. Quick reply. Looks like you can also add a quick reply as well. So this is basically just like a little thing that has it could be like hello, you know, something they can enter in that will be a quick reply.
But for in this case, I'm just going to leave that off. And look, you can even select set set the notification type that they're going to receive as well. So, could be sound on screen notification or no notification. I'm just going to leave it as the default. And then click save. So, that's pretty much the complete automation that I've set up in a couple of minutes. And we're just going to name this automated messenger bot. something along those lines. Right?
So, this can just wait uh we can turn on uh wait for data immediately as it arrives. First, we have to click save and then we can turn this on. So, it's just going to be waiting for new messages coming in using this web hook. But, we still have to make sure that the messenger app is connected is set up properly. So, we're going to come back over here. And again, we're still getting the web hook web hook subscription failed.
So, I'm going to come back over here and see what we need to do specifically. I'm figuring this out as I'm going along. So, just bear with me. If we come down here, it says edit callback URL. So, that's where we enter the URL of the web hook and then click verify and save. So, it should work. Uh, under generate access tokens, click connect. So, that's what we've done. Choose the pages you want, which I've already done.
Uh, return to generate access token and then click generate. So, that's what we're using for connecting that up, which I've already done. And this just shows how to set up the connection. So, now we just have to figure out why this web hook is not working correctly. So, I'm going to come back over here and I guess we could just create a new web hook, right? Let's just use that. That could be the issue actually. So, I'm going to use Messengerbot as the verify token.
I'm just going to create a new web hook and start over from scratch. So, I can remove this other one. And then I'm going to input this. And let's see if this does the trick. Okay. So, that's what I had to do. I had to just create a new web hook. That's all there is to it. And okay, so now the web hook is connected up properly in the messenger app.
Uh make need to make sure to add subscriptions here as well for messages so that it can actually you know check for messages. And then this last step is just to complete the app review. So to send and receive messages, request pages messaging permissions. So it looks like I actually need to add uh another one here as well. So if I click on edit, I need to come over to it looks like what pages messages. So if I search for pages here, I'm not seeing it.
So okay. Okay. So I just need to do request permission here. There we go. So that it can actually monitor messages on the page. So I'm just going to request permission. And there we go. Successfully requested five of five permissions right there. So that's pretty much all there is to it. And then now looks like we may need to Yeah. So we there's a last step where we need to submit business verification. And this usually I have some issues with unfortunately. Um it's still not approved.
Basically you just have to upload your identity like passport and these sorts of things to verify your business. And I also need to do this for my WhatsApp messaging automation as well. So, I do need to figure out how to finally set this up. But that's the last step and then you can just submit it for review. Um, and you should be off to the races.
Um, unfortunately I'm not going to be able to show you how to how this works in practice since I haven't completed that business verification. But pretty much if we run this, it will just be waiting for new data and then once it receives a message, it will run it through ChatGPT. And this module I can actually just rename. So create response, right? And then that's going to send the message. So, pretty simple automation to set up.
Like I say, the most difficult part is um setting everything up in Facebook developers. And I will I would recommend turning it this from development onto live as well. Once all these steps are set up and the most difficult part is just the business verification, you'll need to upload some documents and your name has to match on your personal profile to your ID. So, just something good to know. And then you can pretty much configure the web hook.
Uh, looks like you can even monitor messages from within here as well. And that's that's going to be the callback URL. So, once again, I'm just going to copy and paste this. Looks like it didn't take over here. And verify token once again is going to be messengerbot. There we go. Verify and save. And then you can just switch it on to live once everything's set up properly and you've verified your business. As you can see, it's getting a lot of fields here as well.
So you can you can monitor for emails. If we want to test this, you can turn that on to subscribe. We can test it here as well. So we can get all of these fields. And this is a good way to uh generate leads as well. So, you could basically just be building your email list as messages are coming in. I would recommend turning on first name, last name, email, maybe location as well. And yeah, there's a lot of different fields you can monitor here.
And under messenger, we have API settings, which we don't have to go into too much, but you can see all of your API settings here if you want to set this stuff up, which we've already done. And then once again the last step is just to request permission and verify the business and then should be all set. You will be able to start sending messages automatically with replies coming from ChatGPT for this module. You could also set up a uh messaging assistant as well.
If you want to build out your own custom assistant within ChatGPT then you can also add that module and then you can just message an assistant instead. So, if you have your own assistant, you could you could do that. And then you can issue very specific prompts. Um, and it only has one task and that is to create professional replies on Facebook Messenger. So, that's pretty much all there is to it.
Just let it start running and it will send the messages on your behalf automatically 247 while you sleep. And uh, yeah. So, if you want more information about any of these automations, link in the description below to my free Skool community. You can get all these templates, tutorials, courses, everything inside there. Look forward to seeing you in the inside the community hopefully. And with that being said, thank you so much for watching. Please subscribe and I'll see you in the next one. Thanks for watching.
Sign it all.



