Microsoft Bot Framework: Exception: The data is changed

后端 未结 2 1128
有刺的猬
有刺的猬 2020-12-21 15:56

I have a bot with the following conversation scenario:

  1. Send text to LUIS
  2. LUIS intent calls context.Call(...) to launch a Dialog
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-21 16:41

    I agree with @Artem (this solved my issue too, thanks!). I would just add the following guideline.

    Use

    var data = context.UserData;
    data.SetValue("field_name", false);
    

    whenever you have a IDialogContext object available, so you let the Bot Framework commit changes.

    Use instead

    StateClient sc = activity.GetStateClient();
    await sc.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);
    

    when you don't have an IDialogContext object, e.g. in the MessageController class.

提交回复
热议问题