Java Alexa Skills Kit SDK가 OSGi를 지원하지 않으며 서블릿이 Sling에서 작동하지 않는다는 것이 옳습니다. 그러나 서블릿을 제외한 API의 나머지 부분은 일반 자바 객체로 구성되어 있으므로 슬링과 함께 사용할 수 있습니다. 이것이 서비스와 DI 메커니즘을 사용할 수 있도록 Java Alexa Skills Kit SDK를 슬링 기능으로 포장 한 alexa-skills-sling 라이브러리를 만든 이유입니다. OSGi 번들로
<dependency>
<groupId>eu.zacheusz.sling.alexa</groupId>
<artifactId>alexa-skills-sling</artifactId>
<version>1.2.1</version>
</dependency>
설치 :
는 종속성을 추가 할 필요가 그것을 사용합니다. 예를 들어 :
<plugins>
<plugin>
<groupId>org.apache.sling</groupId>
<artifactId>maven-sling-plugin</artifactId>
<executions>
<execution>
<id>install-dependency</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>install</phase>
<configuration>
<!-- install dependency to test AEM Server -->
<slingUrl>http://${vm.host}:${vm.port}/apps/alexa/install</slingUrl>
<deploymentMethod>WebDAV</deploymentMethod>
<user>${vm.username}</user>
<password>${vm.password}</password>
<groupId>eu.zacheusz.sling.alexa</groupId>
<artifactId>alexa-skills-sling</artifactId>
<version>${alexa-skills-sling.version}</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
그런 다음 하나의 의도 논리가 바로 구현에 슬링 주석을 추가 구현과 라이브러리에 의해 선택 될 것이다. 의도 로직 구현 및
you can find more examples in this project의
@Component
@Service(IntentHandler.class)
Here is a very basic example :
@Component
@Service(IntentHandler.class)
public class ExampleSimpleIntentHandlerService implements IntentHandler {
private static final String SLOT_NAME = "mySlot";
private static final String INTENT_NAME = "myIntent";
@Override
public boolean supportsIntent(String intentName) {
return INTENT_NAME.equals(intentName);
}
@Override
public SpeechletResponse handleIntent(final SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
final IntentRequest request = requestEnvelope.getRequest();
final Intent intent = request.getIntent();
final Slot slot = intent.getSlot(SLOT_NAME);
final String responseMessage;
if (slot == null) {
responseMessage = format(
"I got your request, but there is no slot %",
SLOT_NAME);
} else {
responseMessage = format(
"I got your request. Slot value is %s. Thanks!",
slot.getValue());
}
return newTellResponse(responseMessage);
}
private SpeechletResponse newTellResponse(final String text) {
return SpeechletResponse.newTellResponse(newPlainTextOutputSpeech(text));
}
private PlainTextOutputSpeech newPlainTextOutputSpeech(final String text) {
final PlainTextOutputSpeech speech = new PlainTextOutputSpeech();
speech.setText(text);
return speech;
}
}
감사합니다 -이 내가 필요하고 내가 찾던 정확히 것입니다. 이상한 것은 아무도 전에 그것을 한 적이 없다는 것입니다. – John