Matheus208 Matheus208 - 1 year ago 144
Node.js Question

Microsoft BotFramework: How to send raw JSON message to channels?

I'm using Node.js and BotBuilder v3.1.1.

Previously, we had

that we could use to send raw data to the channel we are connected with.

That proved useful for quick testing and using new features that aren't implemented on the library yet.

How can I do this on the current version v3, since the sendMessage method was removed?

Answer Source

I think this is what your after, as I was looking for something similar myself. What's needed is sourceEvent which is replacing channelData. I'm aware this card can be made by the builder but for an example it works fine.

bot.dialog('/', [
function (session) {
    var msg = new builder.Message(session).sourceEvent({
            facebook: {
                    notification_type: "REGULAR",
                    attachment: {
                        type: "template",
                        payload: {
                            template_type: "generic",
                            elements: [{
                                title: "Some Title",
                                image_url: "",
                                subtitle: "Some amazing subtitle",
                                buttons: [{
                                    type: "postback",
                                    title: "GO",
                                    payload: "demo"

Works great for Facebook, at least in my tests. One thing I'm struggling with is how to handle the postback from the button in node.

Update: So I answered my own secondary question about the postback here.


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download