How to record intents from buttons in Adaptive cards, developed using custom json templates from Rasa custom actions?

Viewed 342

Please do suggest if worked with developing adaptive cards from Rasa to MS Teams API: how to record the intent, when a user presses the buttons in the Adaptive cards in Teams!

I could easily do that with defining intent value to payload using below code

dispatcher.utter_message(
    text="Please make your selection", 
    buttons = [
        {
            "type": "messageBack", 
            "payload": "/Intent1", 
            "title": "Button1"
        },
        {
            "type": "messageBack", 
            "payload": "/Intent2", 
            "title": "Button2"
        }
    ]
)

But as we know, to render these adaptive cards in Teams API, one needs to pass json_message in the actions.py, the one in my case is

nm = {
    "attachments": [{
        "contentType": "application/vnd.microsoft.card.adaptive",
        "content": {
            "type": "AdaptiveCard",
            "version": "1.0",
            "body": [{
                "type": "TextBlock",
                "text": "So, would you like to programme?"
            }],
            "actions": [{
                    "type": "Action.Submit",
                    "title": "Button1"
                },
                {
                    "type": "Action.Submit",
                    "title": "Button2"
                }
            ]
        }
    }]
}

dispatcher.utter_message(json_message = nm)

Suggestions are welcome! Thanks in advance!

2 Answers

Figured out, posting here the required template with imBack card action.

{ 
    "type": "Action.Submit", 
    "title": "Button", 
    "data": {
        "msteams": { 
            "type": "imBack", 
            "value": "/intent" 
        } 
    }, 
    "style": "positive" 
}

I would use messageBack with displayText key for message appearance when user click on the button and text key for intent and entities payload send to Rasa server.

{
    "type": "Action.Submit",
    "title": "My MessageBack button",
    "data": {
        "msteams": {
            "type": "messageBack",
            "displayText": "I clicked this button",
            text: '/intent_name{"entity":"entity_value"}'
        }
    }
}
Related