botman / studio

Ready to use BotMan + Laravel framework
331 stars 90 forks source link

How do I add botman 2.0 in an existing laravel 5.6 project? #60

Open TeamTracer opened 6 years ago

christophrumpel commented 6 years ago

Hey @TeamTracer ,

there is no official guide to do so. I would ask in the BotMan Slack channel, I am sure there are some people who already did that. If you need help you should also provide exact problems and errors, please!

Generally speaking, you need to:

But I haven't done it myself yet.

TeamTracer commented 6 years ago

@christophrumpel, I tried to replicate botman studio, everything is working except the botman.php route. Codes written there doesn't seem to work. I also edited the app/providers/routeserviceprovider.php but it still doesn't work.

prdpspkt commented 6 years ago

Follow these steps:

  1. composer require botman/botman
  2. composer require botman/driver-facebook or driver you need
  3. Copy config files from botman studio config folder to your project folder. And set them properly.
  4. Then create a controller YourController with two methods. use following code:
    
    <?php
    namespace App\Http\Controllers;

//load BotMan use BotMan\BotMan\BotMan; use BotMan\BotMan\BotManFactory; use BotMan\BotMan\Drivers\DriverManager; class MessengerController extends Controller { //load facebook messenger driver, or driver you need DriverManager::loadDriver(\BotMan\Drivers\Facebook\FacebookDriver::class); $cacheDriver = new \Doctrine\Common\Cache\PhpFileCache('cache'); $botman = BotManFactory::create(config('botman', new DoctrineCache($cacheDriver))); $botman->hears('hi', function (BotMan $bot) { $bot->reply('Hello Yourself'); }); } ?>


5. In your routes/web.php file use:
`Route::match(['get', 'post'],'/webhook', 'MessengerController@webhook');`
christophrumpel commented 5 years ago

@TeamTracer any updates here?

TeamTracer commented 5 years ago

@christophrumpel, I haven't found any solutions. Instead I installed laravel 5.6, added botman and then replicated the remaining files of a fresh copy of botman studio. I wrote all the codes in the controller not in botman.php route.

zenia9012 commented 5 years ago

show your code in controller

jnk2006 commented 5 years ago

Is there no way to add conversations while using botman in an existing laravel project?

prdpspkt commented 5 years ago

You can create folder named conversations in app directory and use them like in botman studio.

jnk2006 commented 5 years ago

it isn't working that way. already tried!

startupengine commented 5 years ago

I am also somewhat frustrated in my attempt to add this to a Laravel 5.7 project. Would be great to see an official guide added to the docs.

jnk2006 commented 5 years ago

You’ve got to add the botman.php route in RouteServiceProvider.php

MeiRct commented 5 years ago

Any update on that? Official instructions would be great!

jnk2006 commented 5 years ago

https://course.buildachatbot.io/?utm_source=botman-docs&utm_medium=navigation&utm_campaign=video_course

I subscribed to the $25.00 pack and saw the videos. They had all the information for adding botman to existing project and even for starting-from-scratch project. I honestly forgot how I did it, but the I do remember that the video has the required information.

PatrickSTM commented 3 years ago

I know, the topic is now 3 years old. But there seems to be a solution with this video from the creators of "Botman".

https://beyondco.de/course/build-a-chatbot/getting-started/add-botman-to-your-laravel-app

ianmartorell commented 3 years ago

I found the most straightforward way was to copy the botman-related files from the BotMan Studio Laravel project.