Skip to content

Commit

Permalink
Update PetStoreAssistantBot.java
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Jan 10, 2024
1 parent aa258a9 commit d97ff4f
Showing 1 changed file with 49 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,29 +74,35 @@ public PetStoreAssistantBot(UserState withUserState) {
// onTurn processing isn't working with DP, not being used to manage state...
@Override
public CompletableFuture<Void> onTurn(TurnContext turnContext) {
String text = turnContext.getActivity().getText().toLowerCase().trim();

LOGGER.info("onTurn incoming text: " + turnContext.getActivity().getText());
try
{
String text = turnContext.getActivity().getText().toLowerCase().trim();
LOGGER.info("onTurn incoming text: " + turnContext.getActivity().getText());

if (isErroneousRequest(text)) {
return null;
}
if (isErroneousRequest(text)) {
return null;
}

AzurePetStoreSessionInfo azurePetStoreSessionInfo = configureSession(turnContext, text);
AzurePetStoreSessionInfo azurePetStoreSessionInfo = configureSession(turnContext, text);

if (azurePetStoreSessionInfo != null && azurePetStoreSessionInfo.getNewText() != null) {
// get the text without the session id and csrf token
text = azurePetStoreSessionInfo.getNewText();
}
if (azurePetStoreSessionInfo != null && azurePetStoreSessionInfo.getNewText() != null) {
// get the text without the session id and csrf token
text = azurePetStoreSessionInfo.getNewText();
}

// the client browser initialized
if (text.equals("...")) {
return turnContext.sendActivity(
MessageFactory.text(WELCOME_MESSAGE)).thenApply(sendResult -> null);
// the client browser initialized
if (text.equals("...")) {
return turnContext.sendActivity(
MessageFactory.text(WELCOME_MESSAGE)).thenApply(sendResult -> null);
}
}

catch (Exception e)
{
LOGGER.info("onTurn incoming activity does not exist");
}

return super.onTurn(turnContext)
.thenCompose(saveResult -> userState.saveChanges(turnContext));
.thenCompose(saveResult -> userState.saveChanges(turnContext));
}

@Override
Expand Down Expand Up @@ -231,7 +237,32 @@ protected CompletableFuture<Void> onMembersAdded(
// .collect(CompletableFutures.toFutureList()).thenApply(resourceResponses ->
// null);

LOGGER.info("onMembersAdded...");
try
{
String text = turnContext.getActivity().getText().toLowerCase().trim();
LOGGER.info("onMembersAdded incoming text: " + turnContext.getActivity().getText());

if (isErroneousRequest(text)) {
return null;
}

AzurePetStoreSessionInfo azurePetStoreSessionInfo = configureSession(turnContext, text);

if (azurePetStoreSessionInfo != null && azurePetStoreSessionInfo.getNewText() != null) {
// get the text without the session id and csrf token
text = azurePetStoreSessionInfo.getNewText();
}

// the client browser initialized
if (text.equals("...")) {
return turnContext.sendActivity(
MessageFactory.text(WELCOME_MESSAGE)).thenApply(sendResult -> null);
}
}
catch (Exception e)
{
LOGGER.info("onMembersAdded incoming activity does not exist");
}

return turnContext.sendActivity(
MessageFactory.text("")).thenApply(sendResult -> null);
Expand Down

0 comments on commit d97ff4f

Please sign in to comment.