Setup a Facebook Messenger chatbot in Laravel
BotMan is framework agnostic PHP library for creating chatbots. It supports multiple messenger platforms like
BotMan ❤️ Laravel
BotMan works perfectly together with Laravel. Marcel has provided a BotMan Laravel Starter which we are going to use here.
Install the Laravel application
First we need to clone the repository and install the dependencies.
And of course, like with every Laravel project, we create our environment config file and generate an application key.
Now we are ready to copy our Facebook Messenger tokens to our
.env file. We need the
Page Access Token which is linked to the Facebook page you want to use and the
Verify Token which is used to hook up this application and the Messenger application.
Also make sure you have these Facebook settings inside you
Your application needs to be available for the Facebook webhook. I am using Laravel valet to generate a public HTTPS URL.
test in your Messenger chat of the used page and you should get back “hello!”. Also try out
Start conversation and see an example of a
BotMan conversation. This should look like this:
Awesome right? When you take a look at the
botman.php file in the routes directory you will see why the two messages already worked out of the box.
Checkout the BotMan documentation to learn more about the features.
Wasn’t that easy? Now you got a chatbot running, try to create conversations yourself. This year will be full of chatbots and it is great to see more and more great tools like BotMan out there to help use building them.