Pass custom debug information to Microsoft bot framework emulator

佐手、 提交于 2020-01-03 20:58:45

问题


I am developing a bot based on a .NET Bot Builder SDK.

Is it possible for a bot to pass some debug information together with the message, so I can see it in the Details section of the Bot Framework Chanel Emulator when the message is clicked?


回答1:


Great Question. Yes, it is entirely possible. You can use the ChannelData property of your activity you are responding with. The data entered into the ChannelData property must be valid JSON For example:

var reply = activity.CreateReply("test");
string json = @"{
    CustomField1: 'Field one value',
    CustomField2Array: [
        'First Element',
        'Second Element'
        ]
    }";


reply.ChannelData = JObject.Parse(json);
await context.PostAsync(reply);

In the emulator this will appear as:

"channelData": {
    "CustomField1": "Field one value",
    "CustomField2Array": [
      "First Element",
      "Second Element"
    ]
  }


来源:https://stackoverflow.com/questions/46001873/pass-custom-debug-information-to-microsoft-bot-framework-emulator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!