gpt4 book ai didi

javascript - Botkit 的监听处理函数未在 Slack channel 上回复

转载 作者:太空宇宙 更新时间:2023-11-04 01:45:07 28 4
gpt4 key购买 nike

我目前正在与 slack-starter-chatbot 合作在 Slack 上创建聊天机器人。我正在使用 hears 处理函数。在文件夹 skill/sample_hears.js 中,我有以下代码。

module.exports = function(controller) {

controller.hears(['^hello$'], 'direct_message,direct_mention', function(bot, message) {
bot.reply(message, "Hi there, you're on workspace: " + message.team)
});

// listen for a message containing the world "food", and send a reply
controller.hears('^food$','message_received',function(bot, message) {
// do something!
bot.reply(message, 'What do you want to eat today?')
});

};

但是,当我在 Slack channel 上输入 foodhello 时,机器人不会回复。我知道 ngrok 端点是根据我从 Slack channel 获得的响应来工作的。 您好,您正在工作区:T674NXXXX 这是 ngrok

的输出
Session Status                online
Session Expires 6 hours, 57 minutes
Version 2.2.8
Region United States (us)
Web Interface http://127.0.0.1:4040
Forwarding http://b6dXXXX.ngrok.io -> localhost:3000
Forwarding https://b6dXXXX.ngrok.io -> localhost:3000

Connections ttl opn rt1 rt5 p50 p90
0 0 0.00 0.00 0.00 0.00

可能是什么?

最佳答案

我认为发生这种情况是由于机器人正在监听的事件类型:['direct_message', 'direct_mention']。如果您在消息中提及机器人,您应该会收到回复。

如果您希望机器人监听任何 channel 中的任何消息而不需要直接提及机器人,您应该监听 ambient 事件。

关于javascript - Botkit 的监听处理函数未在 Slack channel 上回复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51737280/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com