Slackbot Attachment - Is there something wrong with this?

I am using botkit by howdy to call the api for the postMessage method. This gives me an error invalid_array_argwhen I pass the binding property. Something is wrong with the way it gets POSTED

bot.api.chat.postMessage(
        {
            channel : '#general',
            text    : 'hi',
            parse   : true,
            username: '@' + bot.identity.name,
            as_user : true,
            icon_url: listOfMessages.logoUrl,
            attachments: [{"pretext": "pre-hello", "text": "text-world"}]

        }, function (err,res) {
            if(err) console.log(err);
            console.log(res);
        }
    );
+4
source share
1 answer

I ran into the same problem and fixed it by building an array.

attachments: JSON.stringify([{"pretext": "pre-hello", "text": "text-world"}])
+14
source

All Articles