使用node.js难以解决松弛应用程序的问题。我正在使用在故障(Howdy)上托管的Starter Botkit(glitch.com

到目前为止,我所能完成的工作非常完美,它与用户开始了交流,一个又一个地问了几个问题,并以一个摘要结尾,包括用户给机器人的所有答案。

module.exports = function(controller) {

 controller.hears(['reminder'], 'direct_message', function(bot, message) {

 bot.startConversation(message, function(err, convo) {
   convo.say('Ok, let me help you with that ...');

   // Ask Target
   convo.ask('Who should I remind ?', function(response, convo) {

    convo.setVar('target', response.text);
    convo.next();

   });

   // Ask About
   convo.ask('About what ?', function(response, convo) {

    convo.setVar('about', response.text);
    convo.next();

   });

   // Ask Date
   convo.ask('Date ?', function(response, convo) {

    convo.setVar('date', response.text);
    convo.next();

   });

   // Ask Time
   convo.ask('And what time ?', function(response, convo) {

    convo.setVar('time', response.text);
    convo.next();

   });

   convo.say('Got it, I should remind {{vars.target}} : {{vars.about}} on {{vars.date}} at {{vars.time}}');
   convo.next();

  });
 });
};


现在,我想更多利用Slack通过API提供的所有methods,例如reminders.add方法。在编写使用此方法的函数时,找不到任何起点。或者如何将其包含在上面的代码中。我是初学者,请耐心等待:)

据我了解,botkit文件中已经处理了所有Oauth流程(只需要提供所有密钥,然后在我的团队中安装该应用程序即可)

最佳答案

我为您阅读了BotKit文档,发现它们显示了一个示例,您可以通过bot对象上的api属性直接访问Slack api。

https://github.com/howdyai/botkit/blob/master/readme-slack.md#working-with-slack-integrations

bot.api.channels.list({},function(err,response) {
  //Do something...
})

09-10 11:34
查看更多