问题
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