I'm assembling a bot using the sample code of BotFramework v4.
I'm trying to receive a value using an AdaptiveCard, but I can't receive a value.
Currently, AdaptiveCard can be sent. An error occurs when you press Submit.
AddressjsonAsync finishes successfully and sends an AdaptiveCard.
However, there is a problem with the subsequent AddressAsync.
The following error occurs:
[OnTurnError] unhandled error: Object reference not set to an instance of an object.System.NullReferenceException: Object reference not set to an instance of an object.
I went to various sites and tried various solutions, but it was no good.
I don't know what caused it, nor what value it returned.
I want to get the result from AdaptiveCard somehow.
I want you to tell me what to do.
Please help me.
Language: C#
Framework: BotFramework v4
AdaptiveCard
{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
{
"type": "Container",
"items": [
{
"type": "Input.ChoiceSet",
"placeholder": "Placeholder text",
"choices": [
{
"title": "aaa",
"value": "aaa@address.jp"
},
{
"title": "bbb",
"value": "bbb@address.jp"
}
],
"style": "expanded",
"spacing": "None",
"id": "Address",
"isMultiSelect": true
}
]
}
],
"actions": [
{
"type": "Action.Submit",
"title": "OK",
"data": { "Address": "Address" }
}
]
}
MainDialog
private static async Task<DialogTurnResult> AddressjsonAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var tokenResponse = (FoundChoice)stepContext.Result;
if (tokenResponse != null)
{
var adaptiveCardJson = File.ReadAllText("./AdaptiveJsons/toaddres_adaptivecard.json");
var adaptiveCardAttachment = new Attachment()
{
ContentType = "application/vnd.microsoft.card.adaptive",
Content = JsonConvert.DeserializeObject(adaptiveCardJson),
};
var reply = stepContext.Context.Activity.CreateReply();
reply.Attachments = new List<Attachment>() { adaptiveCardAttachment };
return await stepContext.PromptAsync(nameof(TextPrompt), new PromptOptions { Prompt = reply }, cancellationToken);
}
await stepContext.Context.SendActivityAsync(MessageFactory.Text("Login was not successful please try again."), cancellationToken);
return await stepContext.EndDialogAsync();
}
private async Task<DialogTurnResult> AddressAsync(WaterfallStepContext stepContext, CancellationToken cancellationToken)
{
var input = JsonConvert.DeserializeObject<Address>(stepContext.Context.Activity.Value.ToString());
stepContext.Values["address"] = input.Address[0];
return await stepContext.BeginDialogAsync(nameof(OAuthPrompt), null, cancellationToken);
}
` Address
using System;
using System.Collections.Generic;
public class Address
{
public List<string> Address { get; set; }
}