Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return ResourceResponse from SkillHandler.processActivity #2489

Merged
merged 4 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions libraries/botbuilder/src/skills/skillHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@ export class SkillHandler extends ChannelServiceHandler {
throw new Error('conversationReference not found.');
}

// If an activity is sent, return the ResourceResponse
let resourceResponse: ResourceResponse;

/**
* Callback passed to the BotFrameworkAdapter.createConversation() call.
* This function does the following:
Expand Down Expand Up @@ -207,7 +210,7 @@ export class SkillHandler extends ChannelServiceHandler {
await this.bot.run(context);
break;
default:
await context.sendActivity(activity);
resourceResponse = await context.sendActivity(activity);
break;
}
};
Expand All @@ -218,7 +221,11 @@ export class SkillHandler extends ChannelServiceHandler {
AppCredentials.trustServiceUrl(skillConversationReference.conversationReference.serviceUrl);

await (this.adapter as BotFrameworkAdapter).continueConversation(skillConversationReference.conversationReference, skillConversationReference.oAuthScope, callback);
return { id: uuid() };

if (!resourceResponse) {
resourceResponse = { id: uuid() };
gabog marked this conversation as resolved.
Show resolved Hide resolved
}
return resourceResponse;
}
}

Expand Down
7 changes: 6 additions & 1 deletion libraries/botbuilder/tests/skills/skillHandler.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ describe('SkillHandler', function() {
type: ActivityTypes.Message,
serviceUrl, text
};

const rid = 'rId';
// Override sendActivities to do nothing.
adapter.sendActivities = async (context, activities) => {
assert(context);
Expand All @@ -276,8 +278,11 @@ describe('SkillHandler', function() {
strictEqual(activities[0].type, ActivityTypes.Message);
strictEqual(activities[0].text, text);
strictEqual(skillActivity.callerId, undefined);
return [{ id: rid }];
};
await handler.processActivity(identity, 'convId', 'replyId', skillActivity);

const resourceResponse = await handler.processActivity(identity, 'convId', 'replyId', skillActivity);
strictEqual(rid, resourceResponse.id);
});

it(`should use the skill's appId to set the callback's activity.callerId`, async () => {
Expand Down