可能的原因是缺少 OnTurnAsync() 方法的 override,或者 OnTurnAsync() 方法返回的仅仅是 BadRequest。需要将 OnTurnAsync() 方法重写进行处理。
以下示例是一个 OnTurnAsync() 方法的完整重写:
public override async Task OnTurnAsync(ITurnContext turnContext, CancellationToken cancellationToken)
{
if (turnContext.Activity.Type == ActivityTypes.Message)
{
// process message activity
}
else if (turnContext.Activity.Type == ActivityTypes.Invoke)
{
var activity = turnContext.Activity;
// Adaptive Card Submit Action
if (activity.Name == "adaptiveCardAction")
{
// get the adaptive card data
var data = JsonConvert.DeserializeObject>(activity.Value.ToString());
// process the data
// send a message back to user
await turnContext.SendActivityAsync(MessageFactory.Text("Received your submission!"), cancellationToken);
}
else
{
// Handle other invoke activities
}
}
}
以上示例假定了你有适应卡片在 bot 中,并且你是需要进行后续修改的。