Skip to content

Releases: PowerBotKit/botbuilder-spring-boot

v0.0.3

06 Jan 14:58
Compare
Choose a tag to compare

Please refer to CHANGELOG.md for details.

v0.0.2

24 Sep 08:14
Compare
Choose a tag to compare

Bug Fixes

  • implement com.microsoft.bot.integration.Configuration#methods (9c1ef3f)

v0.0.1

23 Sep 13:05
Compare
Choose a tag to compare

Usage

add dependency

<dependency>
    <groupId>io.github.powerbotkit</groupId>
    <artifactId>botbuilder-spring-boot-starter</artifactId>
    <version>0.0.1</version>
</dependency>

enable botbuilder support

@SpringBootApplication
@EnableBotBuilder
public class EchoBotApplication {

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

}

create a spring bean what Implement an interface

@Component
public class EchoBot extends ActivityHandler {

    @Override
    protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
        return turnContext.sendActivity(
                MessageFactory.text("Echo: " + turnContext.getActivity().getText())
        ).thenApply(sendResult -> null);
    }

    @Override
    protected CompletableFuture<Void> onMembersAdded(
            List<ChannelAccount> membersAdded,
            TurnContext turnContext
    ) {
        return membersAdded.stream()
                .filter(
                        member -> !StringUtils
                                .equals(member.getId(), turnContext.getActivity().getRecipient().getId())
                ).map(channel -> turnContext.sendActivity(MessageFactory.text("Hello and welcome!")))
                .collect(CompletableFutures.toFutureList()).thenApply(resourceResponses -> null);
    }
}