Botkit: Require_delivery does not work for me

Created on 21 Mar 2017  路  2Comments  路  Source: howdyai/botkit

I'm trying to send a sequence of instructions to the user with pictures illustrating the steps he should take, but the images are not being posted in the correct order, nor with their instruction message.

var slackController = Botkit.slackbot({
require_delivery: true,
});

var slackBot = slackController.spawn({
token: process.env.SLACK_TOKEN
}).startRTM();

slackController.hears(['.*'], ['direct_message', 'direct_mention', 'mention'], function(bot, message) {
slackController.log('Slack message received');
middleware.interpret(bot, message, function(err) {
if (!err){

  //N脙O 脡 GOODBYE E INDENTIFICOU UMA INTEN脟脙O
  if(!(typeof message.watsonData.intents[0] == "undefined") && message.watsonData.intents[0].intent != 'goodbyes'){
    //Impressora
    if(message.watsonData.intents[0].intent == 'Impressora'){

      for(var i = 0; i < 13; i++){
        if(i == 0 || i == 2 || i == 9){
            bot.reply(message, message.watsonData.output.text[i]);
        }else{
          switch(i){
            case 3:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[3],
                "image_url":message.watsonData.context.Img1,
              }]});
              break;
            case 4:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[4],
                "image_url":message.watsonData.context.Img2,
              }]});
              break;
            case 5:
                bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[5],
                "image_url":message.watsonData.context.Img3,
              }]});
              break;
            case 6:
                bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[6],
                "image_url":message.watsonData.context.Img4,
              }]});
              break;
            case 7:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[7],
                "image_url":message.watsonData.context.Img5,
              }]});
              break;
            case 8:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[8],
                "image_url":message.watsonData.context.Img6,
              }]});
              break;
            case 10:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[10],
                "image_url":message.watsonData.context.Img7,
              }]});
              break;
            case 11:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[11],
                "image_url":message.watsonData.context.Img8,
              }]});
              break;
            case 12:
                bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[12],
                "image_url":message.watsonData.context.Img9,
              }]});
              break;
            case 13:
              bot.reply(message, {attachments:[{
                "text": message.watsonData.output.text[13],
                "image_url":message.watsonData.context.Img10,
            }]});
            break;
          }
        }
      }
    }
bug help wanted

Most helpful comment

I believe this is still broken

the require_delivery does not appear to work as intended. I am looking at the Facebook bot specifically, but:

after delivery, code only appears to update within a convo:
convo.sent[s].delivered = true;
so when using bot.reply the require_delivery doesn't appear to do anything

additionally, I do not see where in the code the bot checks if there are messages waiting for delivery prior to sending.

All 2 comments

I resolved this.....

      bot.startConversation(message,function(err,conv){
        conv.say({attachments:[{
          "text": message.watsonData.output.text[0],
        },{
          "text": message.watsonData.output.text[1],
        },{
          "text": message.watsonData.output.text[2],
          "image_url":message.watsonData.context.Img1,
        },{
          "text": message.watsonData.output.text[3],
          "image_url":message.watsonData.context.Img2,
        },{
          "text": message.watsonData.output.text[4],
          "image_url":message.watsonData.context.Img3,
        },{
          "text": message.watsonData.output.text[5],
          "image_url":message.watsonData.context.Img4,
        },{
          "text": message.watsonData.output.text[6],
          "image_url":message.watsonData.context.Img5,
        },{
          "text": message.watsonData.output.text[7],
          "image_url":message.watsonData.context.Img6,
        },{
          "text": message.watsonData.output.text[8],
        },{
          "text": message.watsonData.output.text[9],
          "image_url":message.watsonData.context.Img7,
        },{
          "text": message.watsonData.output.text[10],
          "image_url":message.watsonData.context.Img8,
        },{
          "text": message.watsonData.output.text[11],
          "image_url":message.watsonData.context.Img9,
        },{
          "text": message.watsonData.output.text[12],
          "image_url":message.watsonData.context.Img10,
        }]});
      });

I believe this is still broken

the require_delivery does not appear to work as intended. I am looking at the Facebook bot specifically, but:

after delivery, code only appears to update within a convo:
convo.sent[s].delivered = true;
so when using bot.reply the require_delivery doesn't appear to do anything

additionally, I do not see where in the code the bot checks if there are messages waiting for delivery prior to sending.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

simpixelated picture simpixelated  路  3Comments

imjul1an picture imjul1an  路  3Comments

liornaar picture liornaar  路  3Comments

znat picture znat  路  4Comments

abinashmohanty picture abinashmohanty  路  4Comments