如何在BotKit Facebook中捕获音频消息接收或图像接收

时间:2017-12-27 07:10:37

标签: image facebook audio messenger botkit

我一直在使用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();
        });
    });
});

1 个答案:

答案 0 :(得分:0)

facebook启动项目中有贴纸,图片和音频回复的示例:https://github.com/howdyai/botkit-starter-facebook/blob/master/skills/sample_events.js

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