maalls/botman-bundle

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 5

Watchers: 2

Forks: 1

Open Issues: 0

Type:symfony-bundle

v1.2.2 2018-02-22 10:25 UTC

This package is not auto-updated.

Last update: 2024-04-28 02:27:12 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/