Vipul Vipul - 3 months ago 25
C# Question

bot framework remove cardaction

I am using Bot Framework (Version 3.0, ASP.NET Bot Framework template) for one of my chatbot and using HeroCard & CardAction to get user's feedback. I have below issues:


  1. CardAction translated into inline keyboard on Telegram channel. That works fine and remain available to user to act mutiple time in chat area. How can I remove buttons from chat area once user has taken action using that button?

  2. Can I translate CardAction into reply keyboard (reply_markup) rather than inline markup?

  3. CardAction are working fine with Telegram but not working in Skype. Skype is showing them as external media.


Answer

The Bot Framework doesn't directly support Telegram's reply keyboard feature, but you can still send it via the message's channelData field. ChannelData is for sending channel-specific messages that aren't directly surfaced in the Bot Framework. In BotBuilder/NodeJS, this field is set using the message.sourceEvent method:

Example (untested):

var msg = new builder.Message(session);
msg.sourceEvent({
    telegram: {
        method: "sendMessage",
        parameters: {
            text: "This is a reply keyboard",
            parse_mode: "Markdown",
            reply_markup: JSON.stringify({
                "keyboard": [
                    [{ text: "1" }, { text: "2" }, { text: "3" }],
                    [{ text: "4" }, { text: "5" }, { text: "6" }],
                    [{ text: "7" }, { text: "8" }, { text: "9" }],
                    [{ text: "*" }, { text: "0" }, { text: "#" }]
                ]
            })
        }
    }
});
session.send(msg);

channelData field documentation: https://docs.botframework.com/en-us/csharp/builder/sdkreference/channels.html