0
votes

I am currently building a custom skill for Alexa in Java.

I want Alexa to set an appointment using an existing Exchange Server.

For the appointment I want Alexa to check wether a name, a date and a time are given by the user. I do so using if-statements like:

if(date.getValue() == null) { return askResponse("Please give a date in order to create an appointment")

What happens is Alexa asks for the missing slot but when I answer the skill just quits. I don't know how to have Alexa recognize my response.

Code is as follows:

public SpeechletResponse getTerminResponse(Slot name, Slot date, Slot time, Session session, IntentRequest request) throws Exception {

    if(time.getValue() == null) {
            return askResponse("Please insert time");
        } else if (date.getValue() == null) {
            return askResponse("Please insert date");
        } else if (name.getValue() == null) {
            return askResponse("Please insert name");
        } else {

            try {

                String[] datumArray = date.getValue().split("-");
                String[] zeitArray = time.getValue().split(":");

                Date startDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0])), (Integer.parseInt(zeitArray[1])), 0);
                Date endDate = new Date((Integer.parseInt(datumArray[0])-1900), (Integer.parseInt(datumArray[1])-1), (Integer.parseInt(datumArray[2])), (Integer.parseInt(zeitArray[0]))+1, (Integer.parseInt(zeitArray[1])), 0);

                System.out.println(startDatum.toString());
                System.out.println(endDatum.toString());
                ExchangeHelper eh = new ExchangeHelper();
                eh.createMeeting(name.getValue(), "Test", startDate, endDate);

                return getTellSpeechletResponse("Appointment created successfully");    

            } catch (Exception e) {
                System.out.println(e);
                return askResponse("Failed to create appointment");
            }
        }
}

Here is my Interaction Model

Any help would be highly appreciated since I have been researching documentations and examples for days and I just can not get it to work.

Best regards

1
can you put your interaction model you did in the developer portal? (interaction model, custom slots, utterances)Taís Bellini
@TaísBellini I edited my original post because I don't know how to add pictures to comments. Please excuse the German intents and slots, Datum means date, Zeit means time and Name is self explaining I guess ;)MCR
Ok, this interface is new to me. You can put the prompts "Please insert time" etc. directly in that skill builder, no need to put in the code. Did you do that? If you click in the slot you should see the "Prompts" field, then it will handle for you. What I guess right now is that since you are treating it in the code, your utterances do not expect a single slot response as an entry, so it closes because there is no match.Taís Bellini
@TaísBellini I had the prompts filled out before, now I removed the if-clauses and started with the try-statements. Whenever I leave a slot empty using Alexa the try-block is left instantly because of a NullPointerException (which makes sense since the slot is empty) and Alexa doesn't ask for the missing value. Have you gotten it to work successfully before?MCR
I've started to use it now, and it appears to be in Beta version, and the prompt doesn't really comes out so it doesn't look trustfull. What I suggest you to do is add the utterances "TerminIntent {name}", "TerminIntent {date}", etc. so that the answers get to your code instead of closing the session. Then in the code you treat the answers. You can keep what has been already answered in sessionAttributes.Taís Bellini

1 Answers

0
votes

Can you give the code for getTellSpeechletResponse? According to the picture you attached you are using the "new" Dialog model so that Amazon collect all the slots for you intent. https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/dialog-interface-reference#directives

Most probably you forgot to send back the DelegateDirective (via speechletResponse.setDirectives(...)) to amazon to tell Alexa to take care for collecting the slot values. But this only can be answered if you send the code. I would also like to see an Dialog Java example by amazon but haven't found yet.

If you are using this dialog model you also don't need the if elses as alexa recognize itself which slots are missing. You have to mark this "Is this slot required to fulfill the intent" with yes in the interaction model. Than you also don't need to create own ask responses but just to give utterances in interaction model for your 4 slots.