rodchyn/botman-bundle

Installs: 8

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 1

Type:symfony-bundle

v1.2.3 2018-08-16 06:05 UTC

This package is auto-updated.

Last update: 2024-10-09 02:41:38 UTC


README

This bundle helps you configure and create BotMan within the symfony framework.

Requirement

Symfony 4, php 7+

Installation

Install the symfoy bundle using composer

composer require maalls/botman-bundle

Add the bot config in the config/service.yaml as parameter

parameters:
    botman:
        botman:
            conversation_cache_time: 30
        botframework:
            app_id: xxxxxxxxxx
            app_key: xxxxxxxxxx

Example

Create the bot via autowiring:

    // in src/Service/MyService.php
    function __construct(\Maalls\BotManBundle\Service\Factory $factory) {
        
        // Create BotMan with BotFramework Driver.
        $bot = $factory->createBotFramework(); // \BotMan\BotMan\BotMan

        // Config can be added or overwritten
        $bot = $factory->createBotFramework(["botman" => ["conversation_cache_time" => 5]]); 

        // OR with a specific driver
        $bot = $factory->create(\BotMan\Drivers\Telegram\TelegramDriver::class, ["telegram" => ["token" => "xxxx"]]);

        $bot->hears("(.*)", function($bot, $message) {

            $bot->reply("Anyway, hello.");

        });
    }

Testing

./vendor/bin/phpunit tests/