Laravel 8.x Botman Chatbot Example Tutorial

In this lesson i will show you how you can setup Botman Chatbot in your Laravel application.BotMan is a framework agnostic PHP library that is designed to simplify the task of developing innovative bots for multiple messaging platforms, including Slack, Telegram, Microsoft Bot Framework, Nexmo, HipChat, Facebook Messenger, WeChat and many more.

In this laravel botman example tutorial you will learn from scratch. If you don't know how to add laravel chatbot then don't worry, you are a right place. I will show you step by step in this laravel chatbot tutorial.

So let's install botman in laravel 8. I will use fresh laravel app so that i can show you from scratch.



  1. PHP >= 7.1.3
  2. For BotMan Studio checkout Laravel's requirements

Getting Started

Now lets follow our project start to finis to complete How to Install Botman Chatbot in Laravel 5.


Step 1: Install Laravel 8

For getting fresh laravel app, open your terminal OR command prompt and run bellow command:

composer create-project --prefer-dist laravel/laravel blog


Step 2: Install Botman and Botman Driver

In this step we will install botman composer package and also install botman web driver. so we need to run following both command to install botman.


Install Botman:

composer require botman/botman


Install Botman Driver:

composer require botman/driver-web


Step 3: Create Configuration File

This step is not required to follow. But you can create configuration file for driver and cache. so let's create bot file on config folder and write code like as i gave you bellow:


return [
    'conversation_cache_time' => 40,
    'user_cache_time' => 30,



return [
    'matchingData' => [
        'driver' => 'web',


Step 4: Create Routes

Here, we need to add create routes for botman request. so open your "routes/web.php" file and add following route.


Route::get('/', function () {
    return view('welcome');
Route::match(['get', 'post'], '/botman', 'BotManController@handle');


Step 5: Create Controller

In this step, we need to create one controller as BotManController. in this controller we need to write code of botman reply and conversation. you can also write your own logic latter.


Read also How to import and export csv file in laravel ?



namespace App\Http\Controllers;
use BotMan\BotMan\BotMan;
use Illuminate\Http\Request;
use BotMan\BotMan\Messages\Incoming\Answer;
class BotManController extends Controller
     * Place your BotMan logic here.
    public function handle()
        $botman = app('botman');
        $botman->hears('{message}', function($botman, $message) {
            if ($message == 'hi') {
                $botman->reply("write 'hi' for testing...");
     * Place your BotMan logic here.
    public function askName($botman)
        $botman->ask('Hello! What is your Name?', function(Answer $answer) {
            $name = $answer->getText();
            $this->say('Nice to meet you '.$name);


Step 5: Update Blade File

In this file, we need to update some code on welcome balde file. we need to add botman widget in welcome.blade.php file.



Now we are ready to run our chatbot example with laravel 5.8 so run bellow command for quick run:

php artisan serve


Now you can open bellow URL on your browser:



Hope it will work for your app. You can also check botman official documentation to know more about botman. 


#laravel #botman-chatbot #botman #laravel-package