2
votes

I am digging through all the great new stuff in v3 of the bot framework. One of the things that I am trying to do is create a dialog that responds with cards. But I cannot find a sample that shows how to do this.

I've tried to monkey with it on my own but haven't had much luck. In most of their code samples for Dialogs you cast the Activity object you get in your Post to an IMessageActivity class. Then when you respond you do so with just plain text. All the examples with cards have you create an Activity class. However because I've cast it to IMessageActivity I can't use the CreateReply method. And if I can't do that then when I create an Activity I get an error that the 'activityId' cannot be null.

Any advice, thoughts, or insight would be greatly appreciated.

Thanks in advance!

1

1 Answers

4
votes

I added this code to my dialog:

    protected override async Task MessageReceived(IDialogContext context, IAwaitable<IMessageActivity> item)
    {
        _message = (Activity)await item;
        await base.MessageReceived(context, item);
    }

    [field: NonSerialized()]
    private Activity _message;

    [LuisIntent("Ping")]
    public async Task Ping(IDialogContext context, LuisResult result)
    {
        Activity replyToConversation = _message.CreateReply("Should go to conversation, with a carousel");
        replyToConversation.Recipient = _message.From;
        replyToConversation.Type = "message";
        replyToConversation.AttachmentLayout = "carousel";
        .
        .
        .
        await context.PostAsync(replyToConversation);
        context.Wait(MessageReceived);
    }

I got it working in the emulator but not in Skype but I guess my problem is this one Rich Card attachments are not showing on web chat or Skype