BotBuilderCommunity/botbuilder-community-js

Adding AdaptiveCard to DialogSet results in error

steps371 opened this issue · 5 comments

Hi,

Glad to see community js examples popping up!

I am trying to implement an adaptive card prompt inside of dialogs, but I cannot seem to replicate the brief example in the documentation mentioned here.

The code below is the run method of my top-level dialog.

public async run(turnContext: TurnContext, accessor: StatePropertyAccessor<DialogState>) {

    const cardJson = require('./cards/test.json');

    const card = CardFactory.adaptiveCard(cardJson);

    const promptSettings: AdaptiveCardPromptSettings = {
      card: card,
      requiredInputIds: ['inputA', 'inputB'],
      promptId: 'myCustomId',
    };

    const adaptiveCardPrompt = new AdaptiveCardPrompt(
      'adaptiveCardPrompt',
      promptSettings
    );

    const dialogSet = new DialogSet(accessor);

    //@ts-ignore -- see error below
    dialogSet.add(adaptiveCardPrompt);
    
    dialogSet.add(this);

    const dialogContext = await dialogSet.createContext(turnContext);

    const results = await dialogContext.continueDialog();

    if (results.status === DialogTurnStatus.empty) {
      await dialogContext.beginDialog(this.id);
    }
  }

I get a runtime error: DialogSet.add(): Invalid dialog being added

Typescript error:

Argument of type 'AdaptiveCardPrompt' is not assignable to parameter of type 'Dialog<{}>'.
  Type 'AdaptiveCardPrompt' is missing the following properties from type 'Dialog<{}>': onPreBubbleEventAsync, onPostBubbleEventAsync, hashedLabelts(2345)

Any workarounds, suggestions or solutions will be appreciated!

szul commented

@mdrichardson Any brief thoughts on this? I'll try to run through it over the weekend, if not.

@szul @steps371 Brief thoughts are that I know Dialogs got reworked quite a bit in 4.9 and I believe they now require providing a type when extending. I haven't looked into it much. Might have time to later this week, but @steps371 might be able to downgrade botbuilder packages to 4.8 for now.

szul commented

I think our current packages are sitting on 4.8. I have a PR for 4.9 in draft, but I need to test all the samples before making it non-draft. If nobody gets to it before me, I'll be able to debug/test when I run through those samples.

Thanks for the responses, unfortunately we need 4.9 for some of the new features like carousel and speech-to-text. Any idea when the packages will refer to 4.9?

szul commented

@steps371 Hopefully in the next 1-2 weeks.