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

Commit 1248b45

Browse files
Implemented ResumeDialog in Skills (#1140)
Co-authored-by: tracyboehrer <tracyboehrer@users.noreply.github.com>
1 parent a72d4c4 commit 1248b45

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

libraries/bot-builder/src/main/java/com/microsoft/bot/builder/skills/SkillConversationIdFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import java.util.HashMap;
77
import java.util.Map;
8+
import java.util.UUID;
89
import java.util.concurrent.CompletableFuture;
910

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

5857
SkillConversationReference skillConversationReference = new SkillConversationReference();
5958
skillConversationReference.setConversationReference(conversationReference);

libraries/bot-builder/src/test/java/com/microsoft/bot/builder/SkillConversationIdFactoryTests.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ public void SkillConversationIdFactoryHappyPath() {
6464
Assert.assertNull(deletedConversationReference);
6565
}
6666

67+
@Test
68+
public void IdIsUniqueEachTime() {
69+
ConversationReference conversationReference = buildConversationReference();
70+
71+
// Create skill conversation
72+
SkillConversationIdFactoryOptions options1 = new SkillConversationIdFactoryOptions();
73+
options1.setActivity(buildMessageActivity(conversationReference));
74+
options1.setBotFrameworkSkill(buildBotFrameworkSkill());
75+
options1.setFromBotId(botId);
76+
options1.setFromBotOAuthScope(botId);
77+
78+
String firstId = skillConversationIdFactory.createSkillConversationId(options1).join();
79+
80+
81+
SkillConversationIdFactoryOptions options2 = new SkillConversationIdFactoryOptions();
82+
options2.setActivity(buildMessageActivity(conversationReference));
83+
options2.setBotFrameworkSkill(buildBotFrameworkSkill());
84+
options2.setFromBotId(botId);
85+
options2.setFromBotOAuthScope(botId);
86+
87+
String secondId = skillConversationIdFactory.createSkillConversationId(options2).join();
88+
89+
// Ensure that we get a different conversationId each time we call CreateSkillConversationIdAsync
90+
Assert.assertNotEquals(firstId, secondId);
91+
}
92+
93+
94+
6795
private static ConversationReference buildConversationReference() {
6896
ConversationReference conversationReference = new ConversationReference();
6997
conversationReference.setConversation(new ConversationAccount(UUID.randomUUID().toString()));

libraries/bot-dialogs/src/main/java/com/microsoft/bot/dialogs/SkillDialog.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ public CompletableFuture<DialogTurnResult> beginDialog(DialogContext dc, Object
116116
*/
117117
@Override
118118
public CompletableFuture<DialogTurnResult> continueDialog(DialogContext dc) {
119+
120+
Boolean interrupted = dc.getState().getValue(TurnPath.INTERRUPTED, false, Boolean.class);
121+
if (interrupted) {
122+
dc.getState().setValue(TurnPath.INTERRUPTED, false);
123+
return resumeDialog(dc, DialogReason.END_CALLED);
124+
}
125+
126+
119127
if (!onValidateActivity(dc.getContext().getActivity())) {
120128
return CompletableFuture.completedFuture(END_OF_TURN);
121129
}

0 commit comments

Comments
 (0)