Sahar Ben-Shushan
Sahar Ben-Shushan

Reputation: 297

Quick replies in Microsoft Bot Framework, web chat platform

I'm using MS Bot framework with Facebook & web chat platforms. There is any way to use quick replies in the web chat?

because MS bot framework doesn't support quick replies for the web chat framework.

enter image description here

Upvotes: 4

Views: 1837

Answers (2)

Joe Mayo
Joe Mayo

Reputation: 7513

You can use suggested actions, which disappear when clicked. Here's a sample, modified from the Bot Framework documentation, on how to do that:

var reply = activity.CreateReply("Hi, do you want to hear a joke?");
reply.Type = ActivityTypes.Message;
reply.TextFormat = TextFormatTypes.Plain;

reply.SuggestedActions = new SuggestedActions()
{
    Actions = new List<CardAction>()
    {
        new CardAction(){ Title = "Yes", Type=ActionTypes.ImBack, Value="Yes" },
        new CardAction(){ Title = "No", Type=ActionTypes.ImBack, Value="No" },
        new CardAction(){ Title = "I don't know", Type=ActionTypes.ImBack, Value="IDontKnow" }
    }
};

Upvotes: 3

GeralexGR
GeralexGR

Reputation: 3582

You can use a HeroCard in order to implement such functionality. HeroCard can be used globally on bot framework and the appearance of the dialog is up to platform's design.

For your case you could use something like this:

 private async void HiMessage(IDialogContext ctx)
    {
        List<CardAction> list = new List<CardAction>();
        list.Add(new CardAction { Title = "Yes", Type = ActionTypes.ImBack, Value = "yes" });
        list.Add(new CardAction { Title = "No", Type = ActionTypes.ImBack, Value = "no" });
        list.Add(new CardAction { Title = "I don't know", Type = ActionTypes.ImBack, Value = "dontknow" });
        HeroCard hero = new HeroCard();
        hero.Title = "Hi";
        hero.Text = "Do you want to hear a joke?";
        hero.Buttons = list;
        var msg = ctx.MakeMessage();
        msg.Attachments.Add(hero.ToAttachment());
        await ctx.PostAsync(msg);
    }

You can further explore the rich cards from this

Upvotes: 0

Related Questions