简体   繁体   中英

Using java.awt.Desktop inside Alexa Skill's Intent handler

I am developing my firsts skills using ask-sdk-java and Skillservlet. I have successfully implemented my custom skill handler and communication with alexa.

Now I would like to run some code inside the handler, like opening a web browser using java.awt.Desktop:

public Optional<Response> handle(HandlerInput input){
 
Desktop.getDesktop().browse(new URI("http://www.google.com"));
 
        String speechText = "Of course";
        return input.getResponseBuilder()
                .withSpeech(speechText)
                .build();
}

I am building it as a .war file and running into tomcat server.

When calling the intent, I receive the alexa response, but no web browser is opened.

It is possible to achieve this?

Kind Regards,

Are you expecting the browser to open on the server running the skill or on your Echo device? ASK-SDK is server side and your response to the device will always be mediated by the Alexa Voice Service. You cannot run arbitrary Java code on a customer device.

You can run HTML and JavaScript in a response, but only using the Alexa Web API for Games, and only on devices that support it.

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