title: Adaptive Card response from a WaterfallStep Dialog MS Bot framework v4
body: <p>I am trying to send an adaptive card which has 2 options for user to select.
  When user submit the response from adaptive card I am receiving :</p>
  
  <pre><code>Newtonsoft.Json.JsonReaderException: Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path ‘[‘BotAccessors.DialogState’].DialogStack.$values[0].State.options.Prompt.attachments.$values[0].content.body’.
  </code></pre>
  
  <p>Full code example Link : <a href="https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-dialog-manage-complex-conversation-flow?view=azure-bot-service-4.0&amp;tabs=csharp" rel="noreferrer">Manage a complex conversation flow with dialogs</a></p>
  
  <p>Modification made in HotelDialogs.cs:-</p>
  
  <pre><code>public static async Task&lt;DialogTurnResult&gt; PresentMenuAsync(
                  WaterfallStepContext stepContext,
                  CancellationToken cancellationToken)
              {
                  // Greet the guest and ask them to choose an option.
                  await stepContext.Context.SendActivityAsync(
                      "Welcome to Contoso Hotel and Resort.",
                      cancellationToken: cancellationToken);
                  //return await stepContext.PromptAsync(
                  //    Inputs.Choice,
                  //    new PromptOptions
                  //    {
                  //        Prompt = MessageFactory.Text("How may we serve you today?"),
                  //        RetryPrompt = Lists.WelcomeReprompt,
                  //        Choices = Lists.WelcomeChoices,
                  //    },
                  //    cancellationToken);
  
                  var reply = stepContext.Context.Activity.CreateReply();
                  reply.Attachments = new List&lt;Attachment&gt;
                  {
                      new Attachment
                      {
                          Content = GetAnswerWithFeedbackSelectorCard("Choose: "),
                          ContentType = AdaptiveCard.ContentType,
                      },
                  };
                  return await stepContext.PromptAsync(
                      "testPrompt",
                      new PromptOptions
                      {
                          Prompt = reply,
                          RetryPrompt = Lists.WelcomeReprompt,
                      },
                      cancellationToken).ConfigureAwait(true);
              }
  </code></pre>
  
  <p><strong>Note: ["testPrompt"] I tried with Text Prompt and slightly customizing the TextPrompt to read Activity Value. If Text prompt is not the appropriate prompt for adaptive card response,please let me know is there any other prompt that can be used or some custom prompt will be helpful for this kind of scenario.</strong></p>
  
  <p>Custom Prompt:-</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Threading;
  using System.Threading.Tasks;
  using Microsoft.Bot.Builder;
  using Microsoft.Bot.Builder.Dialogs;
  using Microsoft.Bot.Schema;
  
  namespace HotelBot
  {
      public class CustomPrompt : Prompt&lt;string&gt;
      {
          public CustomPrompt(string dialogId, PromptValidator&lt;string&gt; validator = null)
              : base(dialogId, validator)
          {
          }
  
          protected async override Task OnPromptAsync(ITurnContext turnContext, IDictionary&lt;string, object&gt; state, PromptOptions options, bool isRetry, CancellationToken cancellationToken = default(CancellationToken))
          {
              if (turnContext == null)
              {
                  throw new ArgumentNullException(nameof(turnContext));
              }
  
              if (options == null)
              {
                  throw new ArgumentNullException(nameof(options));
              }
  
              if (isRetry &amp;&amp; options.RetryPrompt != null)
              {
                  await turnContext.SendActivityAsync(options.RetryPrompt, cancellationToken).ConfigureAwait(false);
              }
              else if (options.Prompt != null)
              {
                  await turnContext.SendActivityAsync(options.Prompt, cancellationToken).ConfigureAwait(false);
              }
          }
  
          protected override Task&lt;PromptRecognizerResult&lt;string&gt;&gt; OnRecognizeAsync(ITurnContext turnContext, IDictionary&lt;string, object&gt; state, PromptOptions options, CancellationToken cancellationToken = default(CancellationToken))
          {
              if (turnContext == null)
              {
                  throw new ArgumentNullException(nameof(turnContext));
              }
  
              var result = new PromptRecognizerResult&lt;string&gt;();
              if (turnContext.Activity.Type == ActivityTypes.Message)
              {
                  var message = turnContext.Activity.AsMessageActivity();
                  if (!string.IsNullOrEmpty(message.Text))
                  {
                      result.Succeeded = true;
                      result.Value = message.Text;
                  }
                  else if (message.Value != null)
                  {
                      result.Succeeded = true;
                      result.Value = message.Value.ToString();
                  }
              }
  
              return Task.FromResult(result);
          }
      }
  }
  </code></pre>
  
  <p>Card Creation Method:-</p>
  
  <pre><code>private static AdaptiveCard GetAnswerWithFeedbackSelectorCard(string answer)
          {
              if (answer == null)
              {
                  return null;
              }
  
              AdaptiveCard card = new AdaptiveCard();
              card.Body = new List&lt;AdaptiveElement&gt;();
              var choices = new List&lt;AdaptiveChoice&gt;()
              {
                  new AdaptiveChoice()
                  {
                      Title = "Reserve Table",
                      Value = "1",
                  },
                  new AdaptiveChoice()
                  {
                      Title = "Order food",
                      Value = "0",
                  },
              };
              var choiceSet = new AdaptiveChoiceSetInput()
              {
                  IsMultiSelect = false,
                  Choices = choices,
                  Style = AdaptiveChoiceInputStyle.Expanded,
                  Value = "1",
                  Id = "Feedback",
              };
              var text = new AdaptiveTextBlock()
              {
                  Text = answer,
                  Wrap = true,
              };
              card.Body.Add(text);
              card.Body.Add(choiceSet);
              card.Actions.Add(new AdaptiveSubmitAction() { Title = "Submit" });
              return card;
          }
  </code></pre>
  
  <p>Thanks!</p>