Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Implemented ResumeDialog in Skills #1140

Merged
merged 3 commits into from
Apr 8, 2021
Merged
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
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

import com.microsoft.bot.builder.Storage;
@@ -51,9 +52,7 @@ public CompletableFuture<String> createSkillConversationId(SkillConversationIdFa
Async.completeExceptionally(new IllegalArgumentException("options cannot be null."));
}
ConversationReference conversationReference = options.getActivity().getConversationReference();
String skillConversationId = String.format("%s-%s-%s-skillconvo",
conversationReference.getConversation().getId(), options.getBotFrameworkSkill().getId(),
conversationReference.getChannelId());
String skillConversationId = UUID.randomUUID().toString();

SkillConversationReference skillConversationReference = new SkillConversationReference();
skillConversationReference.setConversationReference(conversationReference);
Original file line number Diff line number Diff line change
@@ -64,6 +64,34 @@ public void SkillConversationIdFactoryHappyPath() {
Assert.assertNull(deletedConversationReference);
}

@Test
public void IdIsUniqueEachTime() {
ConversationReference conversationReference = buildConversationReference();

// Create skill conversation
SkillConversationIdFactoryOptions options1 = new SkillConversationIdFactoryOptions();
options1.setActivity(buildMessageActivity(conversationReference));
options1.setBotFrameworkSkill(buildBotFrameworkSkill());
options1.setFromBotId(botId);
options1.setFromBotOAuthScope(botId);

String firstId = skillConversationIdFactory.createSkillConversationId(options1).join();


SkillConversationIdFactoryOptions options2 = new SkillConversationIdFactoryOptions();
options2.setActivity(buildMessageActivity(conversationReference));
options2.setBotFrameworkSkill(buildBotFrameworkSkill());
options2.setFromBotId(botId);
options2.setFromBotOAuthScope(botId);

String secondId = skillConversationIdFactory.createSkillConversationId(options2).join();

// Ensure that we get a different conversationId each time we call CreateSkillConversationIdAsync
Assert.assertNotEquals(firstId, secondId);
}



private static ConversationReference buildConversationReference() {
ConversationReference conversationReference = new ConversationReference();
conversationReference.setConversation(new ConversationAccount(UUID.randomUUID().toString()));
Original file line number Diff line number Diff line change
@@ -116,6 +116,14 @@ public CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object
*/
@Override
public CompletableFuture<DialogTurnResult> continueDialog(DialogContext dc) {

Boolean interrupted = dc.getState().getValue(TurnPath.INTERRUPTED, false, Boolean.class);
if (interrupted) {
dc.getState().setValue(TurnPath.INTERRUPTED, false);
return resumeDialog(dc, DialogReason.END_CALLED);
}


if (!onValidateActivity(dc.getContext().getActivity())) {
return CompletableFuture.completedFuture(END_OF_TURN);
}