私はMS Bot FrameworkとLUISを使用してボットを開発しています。会話フローにボタン付きのアダプティブカードがたくさんあります。このフローをボタンで処理する方法が必要です(正確にはAction.Submitボタン)。LuisIntentメソッド内のAdaptive Adaptive Cardボタンを処理
私が最初に試さ:
public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
{
if (activity.Type == ActivityTypes.Message)
{
if (activity.Text != null & activity.Value == null)
{
await Conversation.SendAsync(activity,() => new RootLuisDialog());
}
else if (activity.Text == null & activity.Value != null)
{
await Conversation.SendAsync(activity,() => new ButtonHandler());
}
}
else
{
this.HandleSystemMessage(activity);
}
var response = Request.CreateResponse(HttpStatusCode.OK);
return response;
}
適応カード上のボタンがクリックされたときにactivity.Value
がAction.Submitボタンのプロパティが含まれているため。
ボタンコントローラーとインテントコントローラー(つまり、RootLuisDialog()
)を分けることができるという考えがありました。しかし、それは動作しませんでした、私は理由を知らない:このコードでは、常にRootLuisDialog()
出口が取られます。言い換えると、ダイアログがRootLuisDialog()
セカンドアイデアはとても似None
ルイス・インテントを使用していた内部のまま:これは動作しますが
[LuisIntent("")]
[LuisIntent("None")]
public async Task None(IDialogContext context, LuisResult result)
{
var act = context.Activity as IMessageActivity;
string message = String.Empty;
if (act.Text != null & act.Value == null)
{
message = $"Sorry, I did not understand '{act.Text}'. Type 'help' if you need assistance.";
}
else if (act.Text == null & act.Value != null)
{
Button btn = JsonConvert.DeserializeObject<Button>(act.Value.ToString());
message = $"You clicked on {btn.Type}";
}
await context.PostAsync(message);
context.Wait(this.MessageReceived);
}
が、それは権利がNone
意図の下にボタンのコードをプッシュするようには見えません。 buttonHandler
がボタンを押して処理するための非同期関数である私もcontext.Wait(buttonHandler)
を試してみましたが、その後、私は、このエラーメッセージまし
:私は私が達成しようとしているものを確信しています
"exceptionMessage": "Object reference not set to an instance of an object.",
"exceptionType": "System.NullReferenceException",
はすでに良い答えを持っていますが、これは私の最初のC#プロジェクト/タスクであり、私はこれをソートするために助けが必要です。 事前に多くの感謝!!!