1
votes

Next steps in the waterfall dialog flow are not getting called while using Action.Submit in Adaptive cards of Microsoft bot framework SDK V4 (Only when integrated with Microsoft teams)

This is nodejs code in Microsoft framework SDK v4. The problem exists only when integrated with Microsoft teams.

I have tried this in web chat and chat emulator. Action.Submit is calling the next steps on the waterfall dialog flow.

** Bot Code in NodeJS **

async endConversation(stepContext){
    console.log("on endConversation")
    await stepContext.context.sendActivity({
        attachments: [CardFactory.adaptiveCard(RatingCard)]
    });
    return await stepContext.prompt(TEXT_PROMPT, { prompt: '' });
}
async feedback(stepContext){
    console.log("on feedback == "+stepContext.result)
}

** Adaptive Card json **

{
  "type": "AdaptiveCard",
  "body": [
    {
      "type": "TextBlock",
      "size": "medium",
      "weight": "bolder",
      "color": "accent",
      "text": "Rate your experience!"
    },
    {
      "type": "TextBlock",
      "separator": true,
      "text": "Please rate your experience! Your feedback is very appreciated and will help improve your experience in the future. ",
      "wrap": true
    },
    {
      "type": "ColumnSet",
      "spacing": "Medium",
      "columns": [
        {
          "type": "Column",
          "selectAction": {
            "type": "Action.Submit",
            "data": "bad"
          },
          "items": [
            {
              "type": "Image",
              "horizontalAlignment": "Center",
              "url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
              "size": "auto"
            },
            {
              "type": "TextBlock",
              "horizontalAlignment": "Center",
              "text": "Bad"
            }
          ],
          "width": "auto"
        },
        {
          "type": "Column",
          "selectAction": {
            "type": "Action.Submit",
            "data": "ok"
          },
          "items": [
            {
              "type": "Image",
              "horizontalAlignment": "Center",
              "url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
              "size": "auto"
            },
            {
              "type": "TextBlock",
              "horizontalAlignment": "Center",
              "text": "Ok"
            }
          ],
          "width": "auto"
        },
        {
          "type": "Column",
          "selectAction": {
            "type": "Action.Submit",
            "data": "good"
          },
          "items": [
            {
              "type": "Image",
              "horizontalAlignment": "Center",
              "url": "https://upload.wikimedia.org/wikipedia/commons/e/ed/StarRatingGraphic.jpg",
              "size": "auto"
            },
            {
              "type": "TextBlock",
              "horizontalAlignment": "Center",
              "text": "Good"
            }
          ],
          "width": "auto"
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "version": "1.0"
}

Expected :

async method feedback is the next step on the flow which should be called when the user clicks on a star image in adaptive cards.

Actual :

The next step is not getting called. But its going to onMessage method in ActivityHandler base class.

The Interface Looks like The Adaptive Card for ratings

1

1 Answers

0
votes

It looks like Teams isn't handling string submit actions very well. I don't know if this is a new problem or if it always worked that way. Try making your submit action data an object instead of a string:

"selectAction": {
    "type": "Action.Submit",
    "data": {
        "rating": "bad"
    }
}

This will generate a textless message, so you'll need to extract the rating from the activity's value property. See this post for instructions on transferring a string from an activity's value property to its text property. See my latest blog post for more information about using Adaptive Cards with the Bot Framework.

EDIT: I've discovered that you can simulate an imBack in Teams using the format in this document:

{
  "type": "Action.Submit",
  "title": "Click me for imBack",
  "data": {
    "msteams": {
        "type": "imBack",
        "value": "Text to reply in chat"
    }
  }
}