Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,55 @@

package com.microsoft.bot.sample.echo;

import com.microsoft.bot.builder.Bot;
import com.microsoft.bot.integration.AdapterWithErrorHandler;
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
import com.microsoft.bot.integration.Configuration;
import com.microsoft.bot.integration.spring.BotController;
import com.microsoft.bot.integration.spring.BotDependencyConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
* This is the starting point of the Sprint Boot Bot application.
* <p>
* This class also provides overrides for dependency injections. A class that extends the {@link
* com.microsoft.bot.builder.Bot} interface should be annotated with @Component.
*
* @see EchoBot
*/
//
// This is the starting point of the Sprint Boot Bot application.
//
@SpringBootApplication

// Use the default BotController to receive incoming Channel messages. A custom
// controller could be used by eliminating this import and creating a new
// RestController.
// org.springframework.web.bind.annotation.RestController.
// The default controller is created by the Spring Boot container using
// dependency injection. The default route is /api/messages.
@Import({BotController.class})

/**
* This class extends the BotDependencyConfiguration which provides the default
* implementations for a Bot application. The Application class should
* override methods in order to provide custom implementations.
*/
public class Application extends BotDependencyConfiguration {

public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

/**
* Returns the Bot for this application.
*
* <p>
* The @Component annotation could be used on the Bot class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Bot implementation for this application.
*/
@Bean
public Bot getBot() {
return new EchoBot();
}

/**
* Returns a custom Adapter that provides error handling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.schema.ChannelAccount;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand All @@ -23,7 +22,6 @@
* #onMembersAdded(List, TurnContext)} will send a greeting to new conversation participants.
* </p>
*/
@Component
public class EchoBot extends ActivityHandler {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,55 @@

package com.microsoft.bot.sample.welcomeuser;

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;
import com.microsoft.bot.integration.spring.BotController;
import com.microsoft.bot.integration.spring.BotDependencyConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
* This is the starting point of the Sprint Boot Bot application.
*
* This class also provides overrides for dependency injections. A class that
* extends the {@link com.microsoft.bot.builder.Bot} interface should be
* annotated with @Component.
*
* @see WelcomeUserBot
*/
//
// This is the starting point of the Sprint Boot Bot application.
//
@SpringBootApplication

// Use the default BotController to receive incoming Channel messages. A custom
// controller could be used by eliminating this import and creating a new
// RestController.
// org.springframework.web.bind.annotation.RestController.
// The default controller is created by the Spring Boot container using
// dependency injection. The default route is /api/messages.
@Import({BotController.class})

/**
* This class extends the BotDependencyConfiguration which provides the default
* implementations for a Bot application. The Application class should
* override methods in order to provide custom implementations.
*/
public class Application extends BotDependencyConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

/**
* Returns the Bot for this application.
*
* <p>
* The @Component annotation could be used on the Bot class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Bot implementation for this application.
*/
@Bean
public Bot getBot(UserState userState) {
return new WelcomeUserBot(userState);
}

/**
* Returns a custom Adapter that provides error handling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import com.microsoft.bot.schema.ResourceResponse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.Collections;
Expand All @@ -36,7 +35,6 @@
*
* @see WelcomeUserState
*/
@Component
public class WelcomeUserBot extends ActivityHandler {
// Messages sent to the user.
private static final String WELCOMEMESSAGE =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,76 @@

package com.microsoft.bot.sample.multiturnprompt;

import com.microsoft.bot.builder.Bot;
import com.microsoft.bot.builder.ConversationState;
import com.microsoft.bot.builder.UserState;
import com.microsoft.bot.dialogs.Dialog;
import com.microsoft.bot.integration.AdapterWithErrorHandler;
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
import com.microsoft.bot.integration.Configuration;
import com.microsoft.bot.integration.spring.BotController;
import com.microsoft.bot.integration.spring.BotDependencyConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
* This is the starting point of the Sprint Boot Bot application.
*
* This class also provides overrides for dependency injections. A class that
* extends the {@link com.microsoft.bot.builder.Bot} interface should be
* annotated with @Component.
*
* @see DialogBot
*/
//
// This is the starting point of the Sprint Boot Bot application.
//
@SpringBootApplication

// Use the default BotController to receive incoming Channel messages. A custom
// controller could be used by eliminating this import and creating a new
// RestController.
// org.springframework.web.bind.annotation.RestController.
// The default controller is created by the Spring Boot container using
// dependency injection. The default route is /api/messages.
@Import({BotController.class})

/**
* This class extends the BotDependencyConfiguration which provides the default
* implementations for a Bot application. The Application class should
* override methods in order to provide custom implementations.
*/
public class Application extends BotDependencyConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

/**
* Returns the Bot for this application.
*
* <p>
* The @Component annotation could be used on the Bot class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Bot implementation for this application.
*/
@Bean
public Bot getBot(
ConversationState conversationState,
UserState userState,
Dialog dialog
) {
return new DialogBot(conversationState, userState, dialog);
}

/**
* Returns the starting Dialog for this application.
*
* <p>
* The @Component annotation could be used on the Dialog class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Dialog implementation for this application.
*/
@Bean
public Dialog getRootDialog(UserState userState) {
return new UserProfileDialog(userState);
}

/**
* Returns a custom Adapter that provides error handling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.UserState;
import java.util.concurrent.CompletableFuture;
import org.springframework.stereotype.Component;

/**
* This IBot implementation can run any type of Dialog. The use of type parameterization is to
Expand All @@ -21,7 +20,6 @@
* been used in a Dialog implementation, and the requirement is that all BotState objects are
* saved at the end of a turn.
*/
@Component
public class DialogBot extends ActivityHandler {
protected Dialog dialog;
protected BotState conversationState;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

@Component
public class UserProfileDialog extends ComponentDialog {
private StatePropertyAccessor<UserProfile> userProfileAccessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,76 @@

package com.microsoft.bot.sample.usingcards;

import com.microsoft.bot.builder.Bot;
import com.microsoft.bot.builder.ConversationState;
import com.microsoft.bot.builder.UserState;
import com.microsoft.bot.dialogs.Dialog;
import com.microsoft.bot.integration.AdapterWithErrorHandler;
import com.microsoft.bot.integration.BotFrameworkHttpAdapter;
import com.microsoft.bot.integration.Configuration;
import com.microsoft.bot.integration.spring.BotController;
import com.microsoft.bot.integration.spring.BotDependencyConfiguration;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;

/**
* This is the starting point of the Sprint Boot Bot application.
*
* This class also provides overrides for dependency injections. A class that
* extends the {@link com.microsoft.bot.builder.Bot} interface should be
* annotated with @Component.
*
* @see RichCardsBot
*/
//
// This is the starting point of the Sprint Boot Bot application.
//
@SpringBootApplication

// Use the default BotController to receive incoming Channel messages. A custom
// controller could be used by eliminating this import and creating a new
// RestController.
// org.springframework.web.bind.annotation.RestController.
// The default controller is created by the Spring Boot container using
// dependency injection. The default route is /api/messages.
@Import({BotController.class})

/**
* This class extends the BotDependencyConfiguration which provides the default
* implementations for a Bot application. The Application class should
* override methods in order to provide custom implementations.
*/
public class Application extends BotDependencyConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

/**
* Returns the Bot for this application.
*
* <p>
* The @Component annotation could be used on the Bot class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Bot implementation for this application.
*/
@Bean
public Bot getBot(
ConversationState conversationState,
UserState userState,
Dialog rootDialog
) {
return new RichCardsBot(conversationState, userState, rootDialog);
}

/**
* Returns the starting Dialog for this application.
*
* <p>
* The @Component annotation could be used on the Dialog class instead of this method
* with the @Bean annotation.
* </p>
*
* @return The Dialog implementation for this application.
*/
@Bean
public Dialog getRootDialog() {
return new MainDialog();
}

/**
* Returns a custom Adapter that provides error handling.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.springframework.stereotype.Component;

@Component
public class MainDialog extends ComponentDialog {
public MainDialog() {
super("MainDialog");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,21 @@
import com.microsoft.bot.builder.MessageFactory;
import com.microsoft.bot.builder.TurnContext;
import com.microsoft.bot.builder.UserState;
import com.microsoft.bot.dialogs.Dialog;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ChannelAccount;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;

// RichCardsBot prompts a user to select a Rich Card and then returns the card
// that matches the user's selection.
@Component
public class RichCardsBot extends DialogBot<MainDialog> {
public class RichCardsBot extends DialogBot<Dialog> {

public RichCardsBot(
ConversationState withConversationState,
UserState withUserState,
MainDialog withDialog
Dialog withDialog
) {
super(withConversationState, withUserState, withDialog);
}
Expand Down
Loading