Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
chtrembl committed Nov 8, 2023
1 parent e41bfef commit ac659cb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<style>
</style>

<iframe id="soulmachines" th:src="@{'https://azurepetstore.com/static/index.html?sid=' + ${sid} + '&csrf=' + ${_csrf.token}}" style="overflow: hidden; top:0; left:0; bottom:0; right:0; width:100%; height:520px; border:none; margin:0; padding:0;" scrolling="no">
<iframe id="soulmachines" th:src="@{'http://localhost:8080/static/index.html?sid=' + ${sid} + '&csrf=' + ${_csrf.token}}" style="overflow: hidden; top:0; left:0; bottom:0; right:0; width:100%; height:524px; border:none; margin:0; padding:0;" scrolling="no">
Your browser doesn't support iframes
</iframe>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.springframework.context.annotation.Import;

import com.microsoft.bot.builder.Bot;
import com.microsoft.bot.builder.UserState;
import com.microsoft.bot.integration.AdapterWithErrorHandler;
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
import com.microsoft.bot.integration.Configuration;
Expand Down Expand Up @@ -49,8 +50,8 @@ public static void main(String[] args) {
* @return The Bot implementation for this application.
*/
@Bean
public Bot getBot() {
return new PetStoreAssistantBot();
public Bot getBot(UserState userState) {
return new PetStoreAssistantBot(userState);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package com.chtrembl.petstoreassistant;

import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import org.apache.commons.lang3.StringUtils;
Expand All @@ -21,7 +20,6 @@
import com.chtrembl.petstoreassistant.service.IAzurePetStore;
import com.chtrembl.petstoreassistant.utility.PetStoreAssistantUtilities;
import com.codepoetics.protonpack.collectors.CompletableFutures;
import com.fasterxml.jackson.databind.JsonNode;
import com.microsoft.bot.builder.ActivityHandler;
import com.microsoft.bot.builder.MessageFactory;
import com.microsoft.bot.builder.StatePropertyAccessor;
Expand All @@ -45,24 +43,27 @@
@Primary
public class PetStoreAssistantBot extends ActivityHandler {
private static final Logger LOGGER = LoggerFactory.getLogger(PetStoreAssistantBot.class);

@Autowired
private IAzureOpenAI azureOpenAI;

@Autowired
private IAzurePetStore azurePetStore;

@Autowired
private String WELCOME_MESSAGE = "Hello and welcome to the Azure Pet Store, you can ask me questions about our products, your shopping cart and your order, you can also ask me for information about pet animals. How can I help you?";

private UserState userState;

private String WELCOME_MESSAGE = "Hello and welcome to the Azure Pet Store, you can ask me questions about our products, your shopping cart and your order, you can also ask me for information about pet animals. How can I help you?";

public PetStoreAssistantBot(UserState userState) {
this.userState = userState;
}

@Override
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
String text = turnContext.getActivity().getText().toLowerCase();

StatePropertyAccessor<String> sessionIDProperty = userState.createProperty("sessionID");
StatePropertyAccessor<String> csrfTokenProperty = userState.createProperty("csrfToken");
StatePropertyAccessor<String> sessionIDProperty = this.userState.createProperty("sessionID");
StatePropertyAccessor<String> csrfTokenProperty = this.userState.createProperty("csrfToken");

String sessionID = sessionIDProperty.get(turnContext).join();
String csrfToken = csrfTokenProperty.get(turnContext).join();
Expand All @@ -80,7 +81,7 @@ protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
sessionIDProperty.set(turnContext, azurePetStoreSessionInfo.getSessionID()).join();
csrfTokenProperty.set(turnContext, azurePetStoreSessionInfo.getCsrfToken()).join();
// save the user state changes
userState.saveChanges(turnContext).join();
this.userState.saveChanges(turnContext).join();

// send welcome message
return turnContext.sendActivity(
Expand Down

0 comments on commit ac659cb

Please sign in to comment.