Search code examples
botframeworkadaptive-cards

Bot Framework V3, How to get Adjacent Submit Action buttons in an adaptive card with c#


I am trying to get adjacent submit actionsDesired submit action,rather than the default action buttons(one below the other) that we get in an adaptive carddefault submit action buttons. Please refer the images attached.

It would be helpful if you can let me know how can we achieve this using C#. Thanks for the help in advance.


Solution

  • Unfortunately, the button orientation in the Botframework is channel specific. The only channels where it is possible to align buttons on the same line is WebChat and DirectLine, but the process to change the button alignment in those two channels is quite complicated.

    A simple way to solve your issue would be to create two columns and add a selectAction attribute to each column. That way when the user clicks on the column it will invoke the corresponding action. This approach works with the OpenUrl and Submit actions but doesn't work with the ShowCard action. The only other downside to this approach is that each column will not be formatted the same as the other buttons (there's no way to put an outline around each column), but you can add an image to each column to get the desired UI.

    Hope this helps.

    {
    "type": "ColumnSet",
    "spacing": "Medium",
    "columns": [
        {
            "type": "Column",
            "selectAction": {
                "type": "Action.OpenUrl",
                "url": "https://www.microsoft.com/"
            },
            "items": [
                {
                    "type": "TextBlock",
                    "horizontalAlignment": "Center",
                    "size": "Large",
                    "weight": "Bolder",
                    "color": "Accent",
                    "text": "Set due date"
                }
            ],
            "width": 1
        },
        {
            "type": "Column",
            "selectAction": {
                "type": "Action.OpenUrl",
                "url": "https://www.microsoft.com/"
            },
            "items": [
                {
                    "type": "TextBlock",
                    "horizontalAlignment": "Center",
                    "size": "Large",
                    "weight": "Bolder",
                    "color": "Accent",
                    "text": "Comment"
                }
            ],
            "width": 1
        }
    

    enter image description here