我想将聊天机器人集成到我的 symfony 网站中。所以我看到有 Botman,它是一个 PHP 框架,它满足了我的需求,但是我没有找到有关它与 Symfony 集成的文档。所以因为它也在 PHP 和 symfony 中,所以我开始使用 Composer 安装它,然后司机也一样。
这是我遵循的步骤
作曲家需要 botman/botman
作曲家需要 botman/driver-web
在我的额头上做一个控制器
我的控制器
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');
}
我的观点 对于我的观点,我没有起点,我不知道该怎么做,这就是为什么我只是将 botman 的 css 和 js 放入其中
<!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>
但没什么可做的,我的渲染中只显示了一段css和js代码。可以帮助我谢谢。
慕仙森