0

我一直在使用 Botkit Facebook Messenger,我可以完美地接收来自 Facebook 的短信,但是我无法捕获音频消息、图像或附件。

有没有人能够捕获这些类型的消息?

    var Botkit = require('botkit');
var controller = Botkit.facebookbot({
        access_token: process.env.access_token,
        verify_token: process.env.verify_token,
})

var bot = controller.spawn({
});

// if you are already using Express, you can use your own server instance...
// see "Use BotKit with an Express web server"
controller.setupWebserver(process.env.port,function(err,webserver) {
  controller.createWebhookEndpoints(controller.webserver, bot, function() {
      console.log('This bot is online!!!');
  });
});

// this is triggered when a user clicks the send-to-messenger plugin
controller.on('facebook_optin', function(bot, message) {

    bot.reply(message, 'Welcome to my app!');

});

// user said hello
controller.hears(['hello'], 'message_received', function(bot, message) {

    bot.reply(message, 'Hey there.');

});

controller.hears(['cookies'], 'message_received', function(bot, message) {

    bot.startConversation(message, function(err, convo) {

        convo.say('Did someone say cookies!?!!');
        convo.ask('What is your favorite type of cookie?', function(response, convo) {
            convo.say('Golly, I love ' + response.text + ' too!!!');
            convo.next();
        });
    });
});
4

1 回答 1

0

facebook 入门项目中有一个贴纸、图像和音频回复的示例:https ://github.com/howdyai/botkit-starter-facebook/blob/master/skills/sample_events.js

如果您在使用它们时遇到问题,请随时在 github 上创建问题!

于 2017-12-27T21:39:18.397 回答