Skip to main content

Notifications

Copilot Studio - General
Answered

Adaptive Cards with Dynamic multi choice questions

Posted on by

I am upgrading a Chatbot project from PVA version 1 to version 2. 

 

With version 1 I was able to implement a dynamic multiple choice question using bot framework combine with PVA.

 

With version 2 this is no longer possible and the only way I can implement this is by using Adaptive Cards specifically version 1.6

 

Having said this, it seems that Adaptive Cards v1.6 is not yet supported by PVA v2. 

 

Do you have any idea when this version will be supported? Or maybe managed to work around this in some other way?

Categories:
  • non7775 Profile Picture
    non7775 4 on at
    Re: Adaptive Cards with Dynamic multi choice questions

    I got this one work too, 

    Thanks James

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Adaptive Cards with Dynamic multi choice questions

    Thank you @Anonymous -- that is good feedback and we are currently working on documenting more examples and use cases for dynamic adaptive cards / Power Fx.

  • Re: Adaptive Cards with Dynamic multi choice questions

    Cannot thank you enough. 🙏 Worked like a charm 👌

     

    I really could not find anything regarding the possible attributes for the ForAll loop. 

     

    Now is clear. thanks again.

  • Verified answer
    HenryJammes Profile Picture
    HenryJammes on at
    Re: Adaptive Cards with Dynamic multi choice questions

    Hi @Anonymous 

     

    I got it to work this way:

     

    HenryJammes_0-1698662251788.png

     

    In my repro, I initialize your array in a JSON format (like it would be passed from Power Automate) and then parse it as a table in PVA. The biggest difference is how I add the dynamic options to my adaptive card:

     

    HenryJammes_1-1698662340061.png

     

    Here's my topic YAML if you want to repro locally in a new topic:

     

    kind: AdaptiveDialog
    beginDialog:
     kind: OnRecognizedIntent
     id: main
     intent:
     displayName: Input.ChoiceSet
     triggerQueries:
     - Input.ChoiceSet
    
     actions:
     - kind: SetVariable
     id: setVariable_mVSHGE
     variable: Topic.SlotsJSON
     value: [ "1200-1300", "1300-1400", "1400-1500", "1500-1600" ]
    
     - kind: ParseValue
     id: j3NiV2
     variable: Topic.SlotsTable
     valueType:
     kind: Table
     properties:
     Value: String
    
     value: =Topic.SlotsJSON
    
     - kind: AdaptiveCardPrompt
     id: QTAqiH
     card: |-
     ={
     '$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
     type: "AdaptiveCard",
     version: "1.5",
     body: [
     {
     type: "Input.ChoiceSet",
     id: "snooze",
     label: "Snooze for",
     value: "Snooze",
     choices: ForAll(Topic.SlotsTable,
     {
     title: Value,
     value: Value
     }
     )
     }
     ],
     actions: [
     {
     type: "Action.Submit",
     title: "Snooze",
     data: {
     x: "snooze"
     }
     }
     ]
     }
     output:
     binding:
     actionSubmitId: Topic.actionSubmitId
     snooze: Topic.snooze
     x: Topic.x
    
     outputType:
     properties:
     actionSubmitId: String
     snooze: String
     x: String
    
     - kind: SendActivity
     id: sendActivity_w7gOrx
     activity: You selected {Topic.snooze}

     

    Let me know if that helps

  • Re: Adaptive Cards with Dynamic multi choice questions

    The list would be fetched dynamically from an array or json string return from a PA flow ex:

     

    1200-1300

    1300-1400

    1400-1500

    1500-1600

     

    The below is what should fetch the array dynamically from PVA context by addressing them via: Topic.Slots

     

    {
     '$schema': "http://adaptivecards.io/schemas/adaptive-card.json",
     type: "AdaptiveCard",
     version: "1.6",
     body: [
     {
     type: "Input.ChoiceSet",
     choices:
     ForAll(Topic.Slots,
     {
     text: Text(slot),
     type: "TextBlock",
     size: "medium"
     }
     )
     }
     ],
     actions: [
     {
     type: "Action.Submit",
     title: "slot",
     data: {
     x: "slot"
     }
     }
     ]
    }

     

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Adaptive Cards with Dynamic multi choice questions

    Downgrading to 1.5 works for me.

    Can you provide more details on what part should be dynamic and is not in your test?

     

    HenryJammes_0-1698661222805.png

     

  • Re: Adaptive Cards with Dynamic multi choice questions

    I am referring to this feature: https://adaptivecards.io/explorer/Input.ChoiceSet.html

    backnight1991_0-1698659807421.png

     

    The below sample gives an error in PVA unless the version is downgraded to 1.5 which leaves the dynamic input.ChoiceSet to be unsupported.

    {
     "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
     "type": "AdaptiveCard",
     "version": "1.6",
     "body": [
     {
     "type": "Input.ChoiceSet",
     "id": "snooze",
     "label": "Snooze for",
     "value": "${reminders.overrides[0].minutes}",
     "choices": [
     {
     "$data": "${reminders.overrides}",
     "title": "${minutes} minutes",
     "value": "${minutes}"
     }
     ]
     }
     ],
     "actions": [
     {
     "type": "Action.Submit",
     "title": "Snooze",
     "data": {
     "x": "snooze"
     }
     }
     ]
    }

     

  • HenryJammes Profile Picture
    HenryJammes on at
    Re: Adaptive Cards with Dynamic multi choice questions

    Hi @Anonymous,

     

    Do you have an example of the dynamic multiple option adaptive card JSON?

    Curious to understand what property works in 1.6 but not in 1.5 for your scenario.

     

    Henry

Helpful resources

Quick Links

Welcome to the Power Platform…

We are thrilled to unveil the newly-launched Power Platform Communities!…

Getting Started…

Welcome to the Power Platform Community! We appreciate your visit…

Welcome to the new Power Platform Community!…

We are excited to announce our new Copilot Cookbook Gallery in the Community…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 138,006

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,059

Leaderboard