Install plugin to use AWS Lambda from Eclipse Please refer to this as it is introduced in the ↓. [AWS Toolkit for Eclipse --Yamamugi] (https://www.yamamanx.com/aws-toolkit-eclipse/)
First, [Amazon Developer Portal] Go to (https://developer.amazon.com/en/) and go to the Alexa skill creation screen.
Decide on a skill name. Please use Japanese as the language.
This time select a custom skill.
Decide on a call name. It is the part of ** "○○" ** of "Alexa, open ** ○○ **" and "△△ with ** ○○ **".
Make an intent. Corresponds to the ** "△△" ** part of "○○ de ** △△**
For the time being, I made an intent called ** "Hello Intent" **.
Next, we will set utterance examples for HelloIntent, I'm going to use the intent slot as well, so I set an intent slot called ** "Location" ** and I'm going to use Amazon's standard slot ** AMAZON.City **. ** {Location} ** is a common place name already registered on Amazon. Maybe there is also Osaka city. I don't know.
After that, entwin the intent slot you made earlier with the sample utterance, Register some utterance examples that the user is likely to say. After registering to some extent, press ** "Save Model" ** and ** "Build Model" **. Once the build is successful, work on the Alexa Admin Portal is interrupted here.
This time, using the AWS Toolkit for Eclipse installed first, Create a Lambda function from Eclipse.
Since we are using the Java sample project on GitHub, [here] Clone from (https://github.com/alexa/skill-samples-java) to Eclipse. After cloning, import only the helloworld project and edit HelloWorldSpeechlet.java.
HelloWorldSpeechlet.java(Line 49)
@Override
public SpeechletResponse onIntent(SpeechletRequestEnvelope<IntentRequest> requestEnvelope) {
IntentRequest request = requestEnvelope.getRequest();
log.info("onIntent requestId={}, sessionId={}", request.getRequestId(),
requestEnvelope.getSession().getSessionId());
//Get intent from request
Intent intent = request.getIntent();
String intentName = (intent != null) ? intent.getName() : null;
//Get the slot value from the intent
Slot slot = intent.getSlot("Location");
String slotValue = slot.getValue();
if ("HelloIntent".equals(intentName)) {
//Change to pass the slot value as an argument
return getHelloResponse(slotValue);
} else if ("AMAZON.HelpIntent".equals(intentName)) {
return getHelpResponse();
} else {
return getAskResponse("HelloWorld", "This is unsupported. Please try something else.");
}
}
HelloWorldSpeechlet.java(Line 93)
private SpeechletResponse getHelloResponse(String slotValue) {
String speechText = null;
if(slotValue != null && slotValue.contains("Osaka")) {
//To the value of the slot"Osaka"If included
speechText = "Oops, is it profitable?";
} else {
//Otherwise
speechText = "Hello, how are you?";
}
// Create the Simple card content.
SimpleCard card = getSimpleCard("HelloWorld", speechText);
// Create the plain text output.
PlainTextOutputSpeech speech = getPlainTextOutputSpeech(speechText);
return SpeechletResponse.newTellResponse(speech, card);
}
Right-click HelloWorldSpeechlet.java in the Eclipse Project Explorer and select ** Upload Function to AWS Lambda ** from the Amazon Web Services. (For Windows, right-click on the helloworld project to display it.)
Select an S3 bucket or role and proceed through the screen to complete the Lambda function upload.
In the Lambda management screen of the AWS console, select the Lambda you uploaded earlier and select Under Add Trigger, select Alexa Skills Kit. Then, at the bottom of the screen, a form for specifying the skill ID of Alexa Skill will appear.
Return to the Alexa Developer Portal screen and Copy and paste the ** Skill ID ** starting with "amzn1.ask.skill." In the endpoint menu. Finally, press "Save" on the upper right to finish.
Next, on the contrary, the ARN starting with "arn: aws: lambda:" at the top right of the Lambda function management screen, Paste it into the ** Default Region ** form in the Alexa Admin Portal endpoint menu. Finally, press ** "Save Endpoint" ** and you're ready to go.
Go to the ** Test ** menu in the Alexa admin portal Try typing "Greeting Osaka with sample skills". If Alexa answers, "Oh, are you making money?", You're successful!
Thank you for your hard work!
Recommended Posts