虚拟助理项目和技能项目。
打字稿。
在 MS Teams 频道中,尝试从技能更新活动时,虚拟助手将出错。
updateActivity
函数没有在提供的“SkillHandler”中实现)onUpdateActivity
: protected async onUpdateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse> {
return await this.updateActivity(claimsIdentity, conversationId, activityId, activity);
}
updateActivity
函数如下所示:
private async updateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, replyToActivityId: string, activity: Activity): Promise<ResourceResponse> {
let skillConversationReference: SkillConversationReference;
try {
skillConversationReference = await this.conversationIdFactory.getSkillConversationReference(conversationId);
} catch (err) {
// If the factory has overridden getSkillConversationReference, call the deprecated getConversationReference().
// In this scenario, the oAuthScope paired with the ConversationReference can only be used for talking with
// an official channel, not another bot.
if (err.message === 'Not Implemented') {
const conversationReference = await this.conversationIdFactory.getConversationReference(conversationId);
skillConversationReference = {
conversationReference,
oAuthScope: JwtTokenValidation.isGovernment(this.channelService) ?
GovernmentConstants.ToChannelFromBotOAuthScope :
AuthenticationConstants.ToChannelFromBotOAuthScope
};
} else {
// Re-throw all other errors.
throw err;
}
}
if (!skillConversationReference) {
throw new Error('skillConversationReference not found');
}
if (!skillConversationReference.conversationReference) {
throw new Error('conversationReference not found.');
}
const activityConversationReference = TurnContext.getConversationReference(activity);
const callback = async (context: TurnContext): Promise<void> => {
const adapter: BotFrameworkAdapter = (context.adapter as BotFrameworkAdapter);
// Cache the ClaimsIdentity and ConnectorClient on the context so that it's available inside of the bot's logic.
context.turnState.set(adapter.BotIdentityKey, claimsIdentity);
context.turnState.set(this.SkillConversationReferenceKey, activityConversationReference);
activity = TurnContext.applyConversationReference(activity, skillConversationReference.conversationReference) as Activity;
const client = adapter.createConnectorClient(activity.serviceUrl);
context.turnState.set(adapter.ConnectorClientKey, client);
context.activity.id = replyToActivityId;
await context.updateActivity(context.activity);
return;
};
AppCredentials.trustServiceUrl(skillConversationReference.conversationReference.serviceUrl);
await (this.adapter as BotFrameworkAdapter).continueConversation(skillConversationReference.conversationReference, skillConversationReference.oAuthScope, callback);
return { id: uuid() };
}
SkillHandler
声明:// Register the request handler.
const handler: CustomSkillHandler = new CustomSkillHandler(adapter, bot, skillConversationIdFactory, credentialProvider, authenticationConfiguration);
const skillEndpoint = new ChannelServiceRoutes(handler);
skillEndpoint.register(server, '/api/skills');
卡片在 Teams 中更新
当 VA 尝试从先前描述的函数onUpdateActivity
更新活动时,会显示该错误。
(node:13410) UnhandledPromiseRejectionWarning: Error: Failed to decrypt conversation id
at new RestError (/Users/xxxx/Desktop/repository/xxx/virtual-assistant/node_modules/botframework-connector/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1397:28)
at /Users/xxxx/Desktop/repository/xxx/virtual-assistant/node_modules/botframework-connector/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1849:37
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:13410) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)
渠道团队
感谢@tommyJimmy87报告此问题,我们仍在审核中。 一旦有任何更新,我们会尽快回复您😊!
嗨@tommyjimmy87 ,我需要你对你正在做的事情提供额外的重现步骤,以便找出问题所在,因为我们无法重现你所面临的问题。
The Card is updated in Teams
是什么意思?CustomSkillHandler
?这是我们为重现此问题所做的最新更改的分支。
generator-bot-virtualassistant
部署 VA 和技能botskills connect
命令连接 VA & SkillCustomSkillHandler
上添加onUpdateActivity和updateActivity方法CustomSkillHandler
我们会留意您的回答!
嗨@Batta32 ,将尝试回答您的问题:
我的意思是我正在尝试在 MS Teams 频道中更新adaptive card
,结果应该是在我做了一些操作后更新了卡片(卡片在技能范围内,所以基本上测试是updateActivity
从技能到 VA)。
是的,VA 和 Skill 都在 Typescript 中
在技能中,我有一个adaptive card
,在用户执行操作后,这张卡片应该更新为不同的内容。 从我称之为updateActivity
的技能中:
dc.context.updateActivity(previouslySentActivity);
previouslySentActivity
是我们要更新的活动,我们将活动保存在状态中以便以后能够更新它。 这用于在以前的版本中工作,但据我所知,发送和更新活动的流程随着新版本而改变。
这将调用 VA 端点(这是有效的),然后应该更新活动。 电话打进来到CustomSkillHandler
的onUpdateActivity
方法,但后来我得到的错误,当活动被发送到MS队。
让我知道您是否需要更多上下文,同时,也许我也可以在您的分支上尝试此操作并检查我是否有相同的错误。
嗨@Batta32 ,我从你用来测试的分支测试了它。 我在这里创建了一个分支: https :
我更改了您的分支以重现相同的错误。 在testSkillHandler
我添加了一个 try-catch 来获取错误:
try{
await context.updateActivity(activity);
}catch(e){
console.log(e);
}
这是我从updateActivity
调用中得到的实际错误:
{ body: '{"error":{"code":"ServiceError","message":"Unknown"}}',
headers: HttpHeaders { _headersMap: [Object] },
status: 400 },
body: { error: { code: 'ServiceError', message: 'Unknown' } } }
这与我在我的项目中得到的相同。
这是我做的测试:
我在示例技能testUpdateActivityDialog
中创建了一个新对话框,其中在 beginDialog 中我发送了一个带有文本的TestCard
。 在onContinueDialog
我发送了相同的卡片,但文本不同;
将 VA 连接到技能。
以某种意图呼叫 VA,这将调用技能并启动测试对话框并显示卡片;
以某种意图调用 VA,该意图将调用测试对话框的技能和continueDialog
;
该技能将调用 VA 以更新卡,然后您会收到错误消息。
伟大的@tommyJimmy87 ! 我们将使用此新信息对其进行审核,非常感谢😊。
嗨@tommyJimmy87! 我们使用您的最新更改和提到的重现步骤成功地重现了该场景。
我们将继续研究这个问题。 一旦有任何更新,我们会尽快回复您😊。
_我们测试了 VA 和 Skill 机器人之间的连接,当技能将活动信息发送到 VA 时检测到相同的问题_
嗨@DiegoCardozo94 ,
感谢您的更新。
你知道什么时候可以发布吗?
您认为这可以在 17 号之前发布吗,因为我们这边有严格的发布,我们只想了解 17 号日期是否可行? :)
谢谢
嗨@tommyJimmy87 ,抱歉耽搁了。
我们设法验证这个问题也发生在 C# 中,因此它似乎不仅仅与 TypeScript 相关。
我们发现了一些相关的问题:
SkillHandler
ResourceResponse
在将活动从技能转发到频道时会生成假的update
和delete
将不起作用。SkillHandler
类没有实现OnUpdateActivityAsync
。最后但同样重要的是,我们使用上述步骤验证了以下场景:
@darrenj ,我们也使用 C# 机器人复制了这个问题。
我们的测试环境:
我们的重现步骤:
_虚拟助手在尝试更新活动时会抛出异常_
_TypeScript Skill 在 Microsoft Teams Channel 成功运行,更新之前发送的卡片_
嗨, https://github.com/microsoft/botframework-sdk/issues/5919已经解决了所有 3 种支持的语言,您可以尝试该解决方案是否有助于使用明天开始的每日构建之一。
嗨@Batta32 ,这是您必须先更新的内容,对吗? 这不是我可以尝试的吗?
嗨@tommyJimmy87! 是的,我们将验证@gabog提到的 TypeScript 和 C# 内容。
我们将更新此分支,添加最新更新,并合并包含 microsoft/botbuilder-js#2489 和 microsoft/botbuilder-dotnet#4264 的 SDK 的botbuilder-v4-js-daily每日构建。
一旦有任何更新,我们会尽快回复您😊。
嗨@tommyJimmy87 ,我们成功确认在testSkillHandler
中应用microsoft/botbuilder-js#2489 的更改已解决此问题,并且活动已使用Microsoft Teams 频道正确更新。
检查此提交以确定您应该在testSkillHandler
应用的更改,特别是在processActivity
方法中。
@darrenj & @gabog - 我们也使用C#机器人成功验证了 microsoft/botbuilder-dotnet#4264 的更改。
我们的测试环境:
复现步骤:
_对 testSkillHandler 的 processActivity 方法所做的更改_
_TypeScript 虚拟助手在 Microsoft Teams 频道成功运行,更新之前发送的卡片_
我们会留意您的回答!
嗨@Batta32 ,感谢您的更新,我们会尽快尝试。 我这边只有一个问题:是否有任何库版本发生了变化,或者只是您在上面发布的提交? 谢谢
@tommyJimmy87 - 只是我们上面发布的提交!
再次嗨@Batta32 :) 这个看起来也解决了! 明天我会做一些更深入的测试,但似乎可以接受您提供的测试技能处理程序类的更改。 谢谢!
谢谢@tommyJimmy87! 一旦您确认这一点,我们就可以关闭此问题😊。
嗨@Batta32! 我们很乐意关闭这个问题:)
感谢@tommyJimmy87确认这一点!
@darrenj - 我们可以关闭此问题,因为它已由 SDK 团队解决!
最有用的评论
再次嗨@Batta32 :) 这个看起来也解决了! 明天我会做一些更深入的测试,但似乎可以接受您提供的测试技能处理程序类的更改。 谢谢!