Botframework-sdk: How to send Facebook's Quick Replies

Created on 25 Aug 2016  路  3Comments  路  Source: microsoft/botframework-sdk

Hi, it doesn't seems the botbuilder framework support Quick Replies from Facebook:
https://developers.facebook.com/docs/messenger-platform/send-api-reference/quick-replies

Would it be a workaround for it or plan for next release? Thank you

Most helpful comment

@kenyeung128 I just tried using channel data in C# per @willportnoy 's suggestion and it's working

public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            var message = await result;

            var reply = context.MakeMessage();
           // reply.Text = "test";

            var channelData = new JObject();
            var child = new JObject();
            child.Add("content_type", "text");
            child.Add("title", "Red");
            child.Add("payload", "DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED");
            channelData.Add("quick_replies", new JArray(child));
            reply.ChannelData = channelData;

            await context.PostAsync(reply);
            context.Wait(this.MessageReceivedAsync);
        }

All 3 comments

The node version supports quick replies: more information on https://github.com/Microsoft/BotBuilder/issues/585.

The C# version might support it through channel data - I haven't tried it myself.

@kenyeung128 I just tried using channel data in C# per @willportnoy 's suggestion and it's working

public async virtual Task MessageReceivedAsync(IDialogContext context, IAwaitable<IMessageActivity> result)
        {
            var message = await result;

            var reply = context.MakeMessage();
           // reply.Text = "test";

            var channelData = new JObject();
            var child = new JObject();
            child.Add("content_type", "text");
            child.Add("title", "Red");
            child.Add("payload", "DEVELOPER_DEFINED_PAYLOAD_FOR_PICKING_RED");
            channelData.Add("quick_replies", new JArray(child));
            reply.ChannelData = channelData;

            await context.PostAsync(reply);
            context.Wait(this.MessageReceivedAsync);
        }

great! @ejadib It works! Since this only works for facebook, I would put a if-clause to check if it's a facebook channel too.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

peterbozso picture peterbozso  路  3Comments

mattlanham picture mattlanham  路  3Comments

hailiang-wang picture hailiang-wang  路  3Comments

arpan14 picture arpan14  路  3Comments

vaditya04 picture vaditya04  路  3Comments