Baendron
Baendron

Reputation: 33

Customizing ReceiptCard for Microsoft Bot-Builder

I'm currently trying to create a ReceiptCard that shows outstanding balance for a target account. Is there any way to remove the Tax and Total fields from the generated card when it is displayed in the Bot Framework Emulator?

Method for generating ReceiptCards

private ReceiptCard GenerateNewReceiptCardAccount(Account account)
{
    return new ReceiptCard()
    {
        Title = "Account Number: " + account.AccountNumber.ToUpperInvariant(),

        Facts = new List<Fact>
        {
            new Fact("Reference Month:", account.MonthRef),
        },

        Items = GetReceiptItemListAccount(account),

        Buttons = new List<CardAction>
        {
            new CardAction(
                ActionTypes.OpenUrl,
                "More Details",
                "https://github.com/amido/azure-vector-icons/blob/master/renders/file.png",
                "https://gmail.com")
        }
    };
}

Method for generating ReceiptItems

private List<ReceiptItem> GetReceiptItemListAccount(Account account)
{
    List<ReceiptItem> ri = new List<ReceiptItem>();

    ri.Add(new ReceiptItem("30-Days Outstanding Balance", price: "$ " + account.Outstanding30Days.ToString("F")));
    ri.Add(new ReceiptItem("Current Outstanding Balance", price: "$ " + account.OutstandingCurrent.ToString("F")));
    ri.Add(new ReceiptItem("Total Outstanding Balance", price: "$ " + account.OutstandingTotal.ToString("F")));

    return ri;
}

The result I'm getting right now in the Emulator window: ReceiptCardEmulator

Upvotes: 3

Views: 96

Answers (1)

Eric Dahlvang
Eric Dahlvang

Reputation: 8292

This PR fixes the issue: https://github.com/Microsoft/BotFramework-WebChat/pull/603 by ensuring tax and total have a value before showing.

It just isn't in the latest emulator yet. It is in the WebChat control, available here: https://cdn.botframework.com/botframework-webchat/latest/botchat.js & https://cdn.botframework.com/botframework-webchat/latest/botchat.css

Pro Tip: You can also these files and replace the ones under C:\Users[YourUserName]\AppData\Local\botframework\ on windows - updating your local emulator.

Upvotes: 1

Related Questions