Bot Framework Channel Emulator 的频道 ID 无效?
Bot Framework Channel Emulator has invalid channel ID?
我正在使用 C# Bot Framework 库从 Bot State Service 检索一些数据。每当下面的代码中 channelId == "emulator"
时,它都会失败并显示 400 Bad Request
。看起来 Emulator 版本 3.0.0.59 和 3.5.27 都使用此通道 ID。这是返回的有效载荷:
{
"error": {
"code": "BadArgument",
"message": "Invalid channel ID"
}
}
请注意,如果我将 channelId
更改为 "skype"
等其他内容,它会按预期工作。
var credentials = new MicrosoftAppCredentials(id, password);
this.botState = new BotState(new StateClient(credentials));
var channelId = activity.ChannelId;
await botState.GetUserDataAsync(channelId, activity.From.Id);
Received this answer 来自 Bot Framework 团队:
For emulator they need to use the activity’s serviceurl when create the state client. Builder automatically does that in the connector client factory:
if (IsEmulator(this.address))
{
// for emulator we should use serviceUri of the emulator for storage
return new StateClient(this.serviceUri, this.credentials);
}
That error is from state.botframework.com (which is the default endpoint for stateclient) since emulator is not a valid channelid for the state service.
我正在使用 C# Bot Framework 库从 Bot State Service 检索一些数据。每当下面的代码中 channelId == "emulator"
时,它都会失败并显示 400 Bad Request
。看起来 Emulator 版本 3.0.0.59 和 3.5.27 都使用此通道 ID。这是返回的有效载荷:
{
"error": {
"code": "BadArgument",
"message": "Invalid channel ID"
}
}
请注意,如果我将 channelId
更改为 "skype"
等其他内容,它会按预期工作。
var credentials = new MicrosoftAppCredentials(id, password);
this.botState = new BotState(new StateClient(credentials));
var channelId = activity.ChannelId;
await botState.GetUserDataAsync(channelId, activity.From.Id);
Received this answer 来自 Bot Framework 团队:
For emulator they need to use the activity’s serviceurl when create the state client. Builder automatically does that in the connector client factory:
if (IsEmulator(this.address)) { // for emulator we should use serviceUri of the emulator for storage return new StateClient(this.serviceUri, this.credentials); }
That error is from state.botframework.com (which is the default endpoint for stateclient) since emulator is not a valid channelid for the state service.