2

I have some intents set up in LUIS which work perfectly when the bot is asked a question. I want to convert some of these Q&A to an adaptive card. Currently I am able to achieve something like this:

If i click on any of the questions below the reply shows up within the card rather than as a reply from the bot.

This is my JSON (only the relevant part):

  "actions": [
{
  "type": "Action.Submit",
  "title": "About ",
  "data": {
    "action": "about"
  }
},
{
  "type": "Action.ShowCard",
  "title": "FAQs",
  "card": {
    "type": "AdaptiveCard",
    "style": "emphasis",
    "actions": [
      {
        "type": "Action.ShowCard",
        "title": "When are you open?",
        "card": {
          "type": "AdaptiveCard",
          "style": "emphasis",
          "body": [
            {
              "type": "TextBlock",
              "text": "We are open from Monday through Friday from 8:00am to 6:00pm.",
              "wrap": true
            }
          ],
          "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
        }
      },
      {
        "type": "Action.ShowCard",
        "title": "Do you have an office near me? ",
        "card": {
          "type": "AdaptiveCard",
          "style": "emphasis",
          "body": [
            {
              "type": "Image",
              "horizontalAlignment": "Center",
              "url": "https://i.imgur.com/gBVgI25.png",
              "size": "Stretch"
            },
            {
              "type": "TextBlock",
              "text": "AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA",
              "wrap": true
            }
          ],
          "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
        }
      },
      {
        "type": "Action.ShowCard",
        "title": "How quickly can we close? ",
        "card": {
          "type": "AdaptiveCard",
          "style": "emphasis",
          "body": [
            {
              "type": "TextBlock",
              "text": "8 to 10 days, it all depends on how it takes to get access to the property.",
              "wrap": true
            }
          ],
          "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
        }
      }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
  }
}

]

And this is my Code:

 protected async Task<DialogTurnResult> BeginChildDialogAsync(DialogContext dc, OnTurnProperty onTurnProperty)
    {
        var activity = dc.Context.Activity;
        var actionValue = onTurnProperty.Intent;
        switch (onTurnProperty.Intent)
        {

            case "Greeting":
                await dc.Context.SendActivityAsync("Hello there!");
                return new DialogTurnResult(DialogTurnStatus.Empty);
                break;
            case "LendingStates":
                await dc.Context.SendActivityAsync("AZ, CA, CO, FL, GA, HI, NC, NV, OR, SC, TN, TX, UT, VA & WA");
                return new DialogTurnResult(DialogTurnStatus.Empty);
                break;
            case "CloseCase":
                await dc.Context.SendActivityAsync("8 to 10 days, it all depends on how long it takes to get access to the property.");
                return new DialogTurnResult(DialogTurnStatus.Empty);
                break;

            case MenuDialog.Name:
                // todo: need to implement this one
                return await dc.BeginDialogAsync(MenuDialog.Name);

                break;


            break;


            default:
                await dc.Context.SendActivityAsync($"I don't know how to handle the action \"{actionValue}\"");
                return new DialogTurnResult(DialogTurnStatus.Empty);
        }
        return new DialogTurnResult(DialogTurnStatus.Empty);

    }

At this point I am not sure how to change my JSON or code so that if a user clicks on an option on the adaptive card it hits the right Case in my code. If I don't use the card and ask the bot "When are you open?" directly, i get the correct reply.

Sebastian Zolg
  • 1,921
  • 2
  • 14
  • 35
hkhan
  • 843
  • 2
  • 19
  • 45

2 Answers2

1

Your buttons are actually showing cards instead of posting data to bot, so there is no message sent tho the controller

Looking at the doc

I think the button type should be Action.Submit instead of Action.ShowCard

B. Lec
  • 312
  • 2
  • 13
1

@B. Lec is correct. You need to use something like:

"type": "Action.Submit",
    "title": "How quickly can we close?",
    "data": {
    "intent": "CloseCase"
     }

Note: There's really no point in sending "How quickly can we close?" to LUIS. You already know that this should map to the "CloseCase" intent.

I have an answer to a similar SO question, if you need additional context/help.

mdrichardson
  • 7,141
  • 1
  • 7
  • 21
  • I only needed to change the JSON for this to work. Can you tell me what your code above does and why is it useful? – hkhan Apr 12 '19 at 00:40
  • 1
    I just edited it out. The reason it was there is because if you have an Adaptive Card with an Input box, when the user submits it, the data is stored on `Context.Activity.Value` instead of the normal `Context.Activity.Text` so the code was meant to help capture it. I forgot that button presses (like your card) still go to `Context.Activity.Text`. If you look at my link, you can see what I mean and how to do it, still. – mdrichardson Apr 12 '19 at 15:25
  • I saw your link and it does make sense to me. Thank you! – hkhan Apr 12 '19 at 17:11