这不是我之前的问题的重复here https://stackoverflow.com/questions/52850571/connecting-slack-to-botman-in-laravel-on-localhost.
我正在使用botman https://botman.io/为我的 Slack 应用程序创建一个机器人。
使用 slack api,我创建了一个机器人,我想在我的 laravel 应用程序上连接到 botman。我正在使用 ngrok 来隧道本地主机。我必须首先验证我的网址才能将其用于机器人。好吧,我尝试验证网址,但我不断收到此错误。
您的请求 URL 未使用正确的质询值进行响应。更新您的 URL 以接收新的请求和值。
检查ngrok终端显示正在接收来自slack的请求,状态为200。如果我使用postman重现请求,则会返回challenge参数的值,在slack上我仍然收到错误。我使用此代码在我的路线文件中加载 slack 驱动程序。
<?php
use BotMan\BotMan\BotMan;
use BotMan\BotMan\BotManFactory;
use BotMan\Drivers\Slack\SlackDriver;
use BotMan\BotMan\Drivers\DriverManager;
Route::match(['get', 'post'],'botman', function () {
DriverManager::loadDriver(SlackDriver::class);
// Create BotMan instance
$config = [
'slack' => [
'token' => '***slack Token***' //slack token
]
];
$botman = BotManFactory::create($config);
// give the bot something to listen for.
$botman->hears('hello', function (BotMan $bot) {
$bot->reply('Hello yourself.');
});
// start listening
$botman->listen();
});
我尝试使用 url 中的challenge 参数强制响应,就像我的路由文件中那样。
$payload = $request->json();
if ($payload->get('type') === 'url_verification') {
return $payload->get('challenge');
}
SlackBot::hears('keyword', function (Bot $bot) {
$bot->respond('lets begin');
});
这仍然不起作用,我仍然得到URL didn’t respond with the correct challenge value...
error.
我缺少什么?或者我应该如何使用 slack 驱动程序让它以正确的参数响应?网络驱动程序运行完美。