简体   繁体   中英

Can Spring MVC or Spring Boot work with Amazon Alexa?

I am trying to develop a small Alexa skill with Spring Boot and Spring MVC framework via https (I tried both of them). However when I tried to add alexa-skill-kit maven dependency in pom.xml. I got so many different kinds of errors. like 'servlet.init() error','can't create a child container' etc. It seems like the newest version of Alexa Java SDK has some conflicts with my spring set up... Is there anyone who has set up amazon alexa with spring successfully? Or a 'Hello world' sample project shared in github? Thank you.

I've developed a alexa skill using spring boot successfully. Here's the dependency definition from my pom.xml.

<dependency>
    <groupId>com.amazon.alexa</groupId>
    <artifactId>alexa-skills-kit</artifactId>
    <version>1.3.1</version>
    <exclusions>
        <exclusion>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </exclusion>
        <exclusion>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Hopefully that clears up your issues.

Also to use the sdks message objects you can add the bean

@Bean
Module speechletRequestModule() {
    return new SpeechletRequestModule();
}

and then a request mapping in your rest controller is simply

@RequestMapping(value = "skills/myskill", method = RequestMethod.POST)
public SpeechletResponseEnvelope handle(@RequestBody final SpeechletRequestEnvelope speechletRequestEnvelope) {}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM