1
votes

async feed_first(stepContext) 
{
    let company_card = MessageFactory.attachment(
      CardFactory.adaptiveCard(testfeedback)
    );
    
    return await stepContext.prompt("textPrompt", {
      prompt: company_card
    });
}


async feed_second(stepContext) {
    console.log("enter feedback second");
    console.log(stepContext.context.activity.value);
}

{
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
    {
      "type": "Container",
      "items": [
        {
          "type": "Input.ChoiceSet",
          "placeholder": "Placeholder text",
          "choices": [
            {
              "title": " 1",
              "value": " 1"
            },
            {
              "title": " 2",
              "value": " 2"
            }
          ],
          "style": "expanded",
          "id": "cho"
        },
        {
          "type": "ActionSet",
          "actions": [
            {
              "type": "Action.Submit",
              "title": "Submit"
            }
          ]
        }
      ]
    }
  ],
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}

so for this code what happens is, the card gets displayed, but on the bot emulator when the submit button is clicked, nothing happens. the console displays " Running dialog with message activity" and the same card is prompted again. the bot doesn't flow to the second step(feed_second) of waterfall dialog. what i would like for the code to do is to display "enter feedback second" on the console and then show the selected choice with the id "cho" for stepContext.context.activity.value agiain on the console. side note- i have added "feed_first" and "feed_second" while declaring the WaterfallDialog, so that's not the the issue

1
Can you describe the actual and expected behavior in more detail? Are you saying that you are prompted, but when you enter your text it reprompts? Or is it not letting you respond to the prompt at all? Can you share the larger context of your bot and how this dialog is called? - billoverton
(You will need to @ mention me if you want me to see your reply.) Like Bill said, you have not provided enough information for your question to be answered. However, it looks like you might be getting a value-based message activity from the submit action, which would mean the activity's text would be null and therefore cannot satisfy the text prompt. If that's the case, you can just serialize the value into the text property before calling continueDialog. It would help if you provided the Adaptive Card you're using. stackoverflow.com/help/how-to-ask - Kyle Delaney
@billoverton. hi, i have added and the card and explained how i want it work. thanks in advance. - Nitin Dharmapal
@KyleDelaney. hi i have added the card and explained how i want the code to work. thanks in advance - Nitin Dharmapal
Is my answer acceptable? - Kyle Delaney

1 Answers

0
votes

If you want to use an Adaptive Card's inputs with a text prompt, you will need to access the activity's value and serialize it into the activity's text somehow, as seen in this example. This information is in the dialogs section of my Adaptive Cards blog post, which you should read.

In JavaScript you can serialize the value into text like this:

/**
 *
 * @param {TurnContext} turnContext
 */
async sendValueToDialogAsync(turnContext)
{
    // Serialize value
    var json = JSON.stringify(turnContext.activity.value);
    // Assign the serialized value to the turn context's activity
    turnContext.activity.text = json;
    // Create a dialog context
    var dc = await this.dialogs.createContext(turnContext);
    // Continue the dialog with the modified activity
    await dc.continueDialog();
}

In your case, if you only need the result of one input then you can just use that property instead of serializing anything:

turnContext.activity.text = turnContext.activity.value.cho;