Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Microsoft Bot Framework attachments for Facebook messenger

Microsoft Bot Framework messages with buttons in Facebook Messenger

My question relates to the question linked aboved. I am writing a bot using node.js that does not use the bot builder sdk. I manually returning a compatible response for the ms bot connector service. This is working fine for a text response, but I wish to return more complicated responses, e.g the buttons/carousel you can return with messenger. Based on the question I linked above, I guessed the format and added the below:

response.attachments = [ { "Title": "Choose One: ", "Actions": [{ "Title": "Postback!", "Message": "Postback from button" }, { "Title": "Postback2!", "Message": "Postback2 from button" }] } ];

The top level title seems to do nothing but the actions render as postback type buttons correctly (they send the Message as the postback content). With messenger you also have the option to return url based buttons, and image urls.

As far as I can tell there is zero documentation on returning attachments using the node bot builder sdk. If there were I'd just write the bot with the sdk in order to obtain the response format.

So my question is, does anyone know how to correctly return both postback and url based buttons to the bot connnector service, including accompanying images, with or without the bot builder sdk?

Update 05/05/2016

So I found the link below and you can see a definition of the attachments property:

http://docs.botframework.com/sdkreference/nodejs/interfaces/_botbuilder_d_.imessage.html

If you follow it to the IAttachment specification, it makes me wonder how/why my code above works at all? As a test of that format I wrote in the following:

    var att = {};
    att.content = "I am content";
    att.contentType = "text/plain";
    att.contentUrl = "http://www.google.com";
    att.fallbackText = "I am fallback text";
    att.text  = "I am text";
    att.thumbnailUrl = "https://pbs.twimg.com/profile_images/638751551457103872/KN-NzuRl.png";
    att.title  ="I am title";
    att.titleLink = "http://yahoo.com";

Now in slack I get a fairly nice output from this: enter image description here

However in messenger I get "Service Error:Value cannot be null. Parameter name: source"

like image 932
stevepkr84 Avatar asked Oct 19 '22 10:10

stevepkr84


1 Answers

I found the info I needed. Not sure if it hadn't been published at the time or whether I was just hunting in the bot builder docs, but it's all detailed fairly well below.

http://docs.botframework.com/connector/message-actions/#navtitle

You have to tweak your message a little for certain integrations, e.g Skype doesn't really seem to support attachments.

like image 116
stevepkr84 Avatar answered Nov 02 '22 13:11

stevepkr84