Skip to content

Repository files navigation

botbuilder-spring-boot

a simple starter for spring boot and bot framework

Usage

add dependency

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

enable botbuilder support

@SpringBootApplication@EnableBotBuilderpublicclassEchoBotApplication {
publicstaticvoidmain(String[] args) {
SpringApplication.run(EchoBotApplication.class, args);
}
}

create a spring bean what Implement an interface

@ComponentpublicclassEchoBotextendsActivityHandler {
@OverrideprotectedCompletableFuture<Void> onMessageActivity(TurnContextturnContext) {
returnturnContext.sendActivity(
MessageFactory.text("Echo: " + turnContext.getActivity().getText())
).thenApply(sendResult -> null);
}
@OverrideprotectedCompletableFuture<Void> onMembersAdded(
List<ChannelAccount> membersAdded,
TurnContextturnContext
) {
returnmembersAdded.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);
}
}

Samples

more samples

License

MIT © PowerBotKit Team

About

a simple starter for spring boot and bot framework

Topics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages