Install Botman Chatbot in Laravel

Hello artisans,

Today I’ll show you how you can set up Botman Chatbot in your Laravel app easily. Botman chatbot is a kind of framework where you can use the bots for multiple messaging platforms, including Slack, Telegram, Microsoft Bot Framework, Nexmo, HipChat, Facebook Messenger, WeChat and many more. So, let’s see how we can implement the chatbot in our application.

Table of Contents

  1. Install Botman and Botman Driver
  2. Create Configuration File for Botman
  3. Create and Setup Controller
  4. Create Route
  5. Modify blade file

Install Botman and Botman Driver

To install the Botman you just need to fire the below command

composer require botman/botman

And to install the Botman Driver fire the blow command

composer require botman/driver-web

Create Configuration File for Botman

This step is not mandatory so you can skip without hesitation. But for better performance create a directory under config\botman and create two files config.php and web.php and finally paste the following code.


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


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

Create and Setup Controller

At first, we need to create a controller so fire the below command to create a fresh controller.

php artisan make:controller BotmanController

This will create a file under App\Http\Controllers, open the file and paste the following code


namespace App\Http\Controllers;

use BotMan\BotMan\Messages\Incoming\Answer;

class BotmanController extends Controller
    public function handle()
        $botman = app('botman');

        $botman->hears('{message}', function($botman, $message) {

            if ($message == 'hi') {
                $botman->reply("write 'hi' for testing...");



    public function askName($botman)
        $botman->ask('Hello! What is your Name?', function(Answer $answer) {

            $name = $answer->getText();

            $this->say('Nice to meet you '.$name);

Create Route

Put the following route in your web.php.

Route::match(['get', 'post'], '/botman', [\App\Http\Controllers\BotmanController::class,'handle']);

Modify blade file

We reached the final step of our tutorial. here we need to modify our welcome.blade.php a little bit. So, paste the following code in your blade file

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>How to install Botman Chatbot in Laravel? -</title>
    <link href=",600" rel="stylesheet">

<link rel="stylesheet" type="text/css" href="">
    var botmanWidget = {
        aboutText: 'write something here',
        introMessage: "✋ Hi! I'm form"

<script src=''></script>


And that’s it. You’ve successfully implemented botman in your application. now if you run your app you will see the below output

Botman Chatbot

That’s all for toady. You can download this project from Github also. Thanks for reading.