Virtual Assistant Project and Skill Project.
Typescript.
From MS Teams Channel, when trying to update an activity from a Skill, the Virtual Assistant will error out.
updateActivity
function is not implemented in the provided "SkillHandler")onUpdateActivity
: protected async onUpdateActivity(claimsIdentity: ClaimsIdentity, conversationId: string, activityId: string, activity: Activity): Promise<ResourceResponse> {
return await this.updateActivity(claimsIdentity, conversationId, activityId, activity);
}
and the updateActivity
function looks like this:
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
declaration : // Register the request handler.
const handler: CustomSkillHandler = new CustomSkillHandler(adapter, bot, skillConversationIdFactory, credentialProvider, authenticationConfiguration);
const skillEndpoint = new ChannelServiceRoutes(handler);
skillEndpoint.register(server, '/api/skills');
The Card is updated in Teams
The error is shown when the VA tries to update the activity from the previous described function 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)
Channel Teams
Thanks @tommyJimmy87 for reporting this issue, we are still reviewing it. As soon as we have any update we will be back to you 😊!
Hi @tommyjimmy87, I need you to give an extra repro steps of what you're doing in order to figure out what's wrong as we couldn't reproduce the issue that you are facing.
The Card is updated in Teams
?CustomSkillHandler
?Here is the branch with our latest changes that we made to reproduce this issue.
generator-bot-virtualassistant
botskills connect
commandCustomSkillHandler
CustomSkillHandler
We will be attentive to your answer!
Hi @Batta32, will try to answer your questions :
I mean that I'm trying to update an adaptive card
in MS Teams channel and the result should be that the card is updated after I did some action (the card is within the skill, so basically the test is the updateActivity
from the skill to the VA).
Yes, both VA and Skill are in Typescript
In the skill I have an adaptive card
, after an action from the user this card should be updated with different content. From the skill I call the updateActivity
:
dc.context.updateActivity(previouslySentActivity);
previouslySentActivity
it's the activity that we want to update, we save the activity in the state in order to be able to update it later. This use to work in the previous version, but the flow of sending and update activity as far as I understand changed with the new version.
This will call the VA endpoint (this is working) which should then update the activity. The call comes into the CustomSkillHandler
in the onUpdateActivity
method but then I get the error when the activity is sent to MS Teams.
Let me know if you need more context, meanwhile, maybe I can try this out also on your branch and check if I have the same error.
Hi @Batta32, I tested it from the branch you are using to test. I created a fork here: https://github.com/tommyJimmy87/botframework-solutions/tree/feature/southworks/conversationid-issue
I changed your branch to reproduce the same error. Within the testSkillHandler
I added a try-catch to get the error :
try{
await context.updateActivity(activity);
}catch(e){
console.log(e);
}
This is the actual error I'm getting from the updateActivity
call :
{ body: '{"error":{"code":"ServiceError","message":"Unknown"}}',
headers: HttpHeaders { _headersMap: [Object] },
status: 400 },
body: { error: { code: 'ServiceError', message: 'Unknown' } } }
Which is the same I get in my project.
This is the test I did:
I created a new Dialog inside the sample-skill testUpdateActivityDialog
where in the beginDialog I send a TestCard
with a text. In the onContinueDialog
I send the same card but with a different text;
Connect the VA to the Skill.
Call the VA with some intent that will call the Skill and start the Test Dialog and show the card;
Call the VA with some intent that will call the Skill and the continueDialog
of the Test Dialog;
The skill will call the VA in order to update the card and then you get the error.
Great @tommyJimmy87 ! We will review it with this new information, thank you very much 😊.
Hi @tommyJimmy87! We successfully reproduced the scenario using your latest changes and the mentioned repro steps.
We will continue researching about this issue. As soon as we have any update, we will back to you 😊.
_We tested the connection between the VA & Skill bots detecting the same issue when the skills sends the activity information to the VA_
Hi @DiegoCardozo94,
Thanks for the update.
Do you have any idea when this might be released?
Do you think this can be released before the 17th, since we have a strictly release from our side we would like just to understand if the 17th date is feasible or not ? :)
Thanks
Hi @tommyJimmy87, sorry for the delay.
We managed to validate that this issue happens in C# as well so it appears not to be related to TypeScript only.
We found some many related issues:
SkillHandler
generates a fake ResourceResponse
when it forwards activities from the skill to the channel. This means that operations like update
and delete
won't work.SkillHandler
class does not implement OnUpdateActivityAsync
.Last but not least, we validated the following scenarios using the mentioned steps:
@darrenj, we replicated this issue using C# bots too.
Our test environment:
Our repro steps:
_The Virtual Assistant will throw an exception when trying to update an activity_
_TypeScript Skill successfully running in Microsoft Teams Channel, updating the card which was previously sent_
Hi, https://github.com/microsoft/botframework-sdk/issues/5919 has nee addressed on all 3 supported languages, you can try if that solution helps using one of the daily builds starting tomorrow.
Hi @Batta32, here it's something that you have to update first right? It's not something I can try already?
Hi @tommyJimmy87! Yes, we will be validating what @gabog mentioned for TypeScript and C#.
We will be updating this branch adding the last updates and incorporating the botbuilder-v4-js-daily daily build of the SDK that contains the microsoft/botbuilder-js#2489 and microsoft/botbuilder-dotnet#4264 .
As soon as we have any update, we will back to you 😊.
Hi @tommyJimmy87, we successfully confirmed that applying the changes of microsoft/botbuilder-js#2489 in the testSkillHandler
this issue is solved and the activity is correctly updated using Microsoft Teams channel.
Check this commit in order to identify the changes that you should apply in your testSkillHandler
, specifically in the processActivity
method.
@darrenj & @gabog - we successfully validated the changes of microsoft/botbuilder-dotnet#4264 using C# bots too.
Our test environment:
Repro steps:
_Changes made on the processActivity method of testSkillHandler_
_TypeScript Virtual Assistant successfully running in Microsoft Teams Channel, updating the card which was previously sent_
We will be attentive to your answer!
Hi @Batta32, thanks for the update, we will try this out asap. Just one question from my side: is any library version changed or it's just the commit you posted above? Thanks
@tommyJimmy87 - Just the commit we've posted above!
Hi again @Batta32 :) Also this one looks like solved! I will do some more deep tests tomorrow but seems to be ok with the changes in the Test Skill Handler class you provided. Thanks!
Thanks @tommyJimmy87! As soon as you can confirm this, we can close this issue 😊.
Hi @Batta32! We can gladly close this issue :)
Thanks @tommyJimmy87 for confirming this!
@darrenj - we can close this issue as it was solved by the SDK team!
Most helpful comment
Hi again @Batta32 :) Also this one looks like solved! I will do some more deep tests tomorrow but seems to be ok with the changes in the Test Skill Handler class you provided. Thanks!