在 slack 上尝试为 laravel-botman 启用事件订阅时如何以正确的挑战值响应
How to respond with the correct challenge value when trying to enable event subscriptions for laravel-botman on slack
这不是我之前问题的重复。
我正在使用 botman 为我的 slack 应用程序创建一个机器人。
使用 slack api,我创建了一个机器人,我想在我的 laravel 应用程序上连接到 botman。我正在使用 ngrok 隧道本地主机。我必须先验证我的 url 才能将其用于机器人。好吧,我尝试验证 url 但我一直收到此错误。
Your request URL didn’t respond with the correct challenge value. Update your URL to receive a new request and value.
检查 ngrok 终端显示正在接收来自 slack 的请求,状态为 200。如果我使用邮递员重现请求,则返回挑战参数的值,在 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 中的质询参数强制响应,就像在我的路由文件中一样。
$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...
错误。
我错过了什么?或者我应该如何使用松弛驱动程序让它以正确的参数响应?网络驱动程序完美运行。
我注意到 slack api 需要 json 格式的挑战值。
只是做 return $payload->get('challenge');
。不成功。我将其更改为 return response->json( return $payload->get('challenge'));
。这让我的 url 得到了验证。
我不确定这是否是整个 botman slack-driver 的问题,我没有发现其他人有同样的问题。
这不是我之前问题的重复
我正在使用 botman 为我的 slack 应用程序创建一个机器人。
使用 slack api,我创建了一个机器人,我想在我的 laravel 应用程序上连接到 botman。我正在使用 ngrok 隧道本地主机。我必须先验证我的 url 才能将其用于机器人。好吧,我尝试验证 url 但我一直收到此错误。
Your request URL didn’t respond with the correct challenge value. Update your URL to receive a new request and value.
检查 ngrok 终端显示正在接收来自 slack 的请求,状态为 200。如果我使用邮递员重现请求,则返回挑战参数的值,在 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 中的质询参数强制响应,就像在我的路由文件中一样。
$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...
错误。
我错过了什么?或者我应该如何使用松弛驱动程序让它以正确的参数响应?网络驱动程序完美运行。
我注意到 slack api 需要 json 格式的挑战值。
只是做 return $payload->get('challenge');
。不成功。我将其更改为 return response->json( return $payload->get('challenge'));
。这让我的 url 得到了验证。
我不确定这是否是整个 botman slack-driver 的问题,我没有发现其他人有同样的问题。