I would like to integrate a chatbot into my symfony website. So I saw that there was Botman which is a PHP framework and it meets my needs, but I find no documentation concerning its integration with Symfony.So as it is in PHP and symfony too, so I started to install it with composer and then the drivers too.
Here are the steps I followed
- composer require botman/botman
- composer require botman/driver-web
- make a controller in my forehead
My Controller
public function chatAction()
{
$config = [
// Your driver-specific configuration
// "telegram" => [
// "token" => "TOKEN"
// ]
];
DriverManager::loadDriver(\BotMan\Drivers\Web\WebDriver::class);
$botman = BotManFactory::create($config);
// Give the bot something to listen for.
$botman->hears('Hello', function (BotMan $bot) {
$bot->reply('Hello too');
});
// $botman->fallback(function($bot) {
// $bot->reply('Sorry, I did not understand these commands. Here is a list of commands I understand: ...');
// });
// Start listening
$botman->listen();
return $this->render('DoctixFrontBundle:Chat:index.html.twig');
}
My view For my view I have no starting point and I don't know what to do clearly, that's why i just put the css and the js of botman in it
<!doctype html>
<html>
<head>
<title>BotMan Widget</title>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/assets/css/chat.min.css">
</head>
<body>
<script id="botmanWidget" src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/chat.js'></script>
</body>
</html>
<script>
var botmanWidget = {
frameEndpoint: '/chat.html',
introMessage: 'Hello, I am a Chatbot',
chatServer : 'chat.php',
title: 'My Chatbot',
mainColor: '#456765',
bubbleBackground: '#ff76f4',
aboutText: '',
bubbleAvatarUrl: '',
};
</script>
<script src='https://cdn.jsdelivr.net/npm/botman-web-widget@0/build/js/widget.js'></script>
But nothing to do, I only have a display of a piece of css and js code in my rendering. Can help me Thanks.