question

newuser-45292da8-69e1-4ad3-91d1-c5aab4716d2b avatar image

Dialog directive functionality without using :dialog or Skill Builder

I've built a small prototype of a skill using the dialog directive and the Skill Builder. Because of some of the limitations of using the Dialog directive and the overhead of making changes to both code and the interaction model within the Skill Builder (which has no way to export intents or lists of valid utterances), I'm now attempting to migrate away from the dialog directive & Skill Builder while still supporting multi-turn conversations.

The issue I'm having is capturing slot values. Here's a sample of some code from my skill:

if (!this.event.request.intent.slots.ReservedObject.value) {
      speechOutput = repromptText = this.t("What would you like to reserve?");
      return this.emit(":ask", speechOutput, repromptText);
}

if (!this.event.request.intent.slots.Date.value) {
      speechOutput = repromptText = this.t("What day would you like to reserve the ") + this.t(this.event.request.intent.slots.ReservedObject.value);
      return this.emit(":ask", speechOutput, repromptText);
}

if (!this.event.request.intent.slots.StartTime.value) {
      speechOutput = repromptText = this.t("What time would you like to reserve the ") + this.t(this.event.request.intent.slots.ReservedObject.value);
      return this.emit(":ask", speechOutput, repromptText);
}

Each if statement corresponds to the elicitation of an unfilled slot. The issue I'm having is that slot values are not persisting between requests as they do when using the dialog directive. As an example, if I invoke the intent that this code is found in without filling any slots, the first if statement collects the value for ReservedObject. The second if statement then elicits and collects the value for the Date slot. However, after Date is filled, the value for ReservedObject is then cleared and the first if statement is executed again. This is leading to an infinite loop between the first and second if statements. Without using the Skill Builder and dialog directive, how should I go about persisting slot values between requests?

alexa skills kitskillinteraction modeldialog model
10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

LiamDeLee avatar image
LiamDeLee answered

Hi there

I am using the dialog directive but can see why you want to move away.

The problem you are having can be solved with attributes. As Amazon says here in a quote:

"In addition, a response can include attributes to save with the current session. This is useful for persisting data within a session."

A good example on how to use it can be found here (written in node.js). This will actually make it that you will send data with your skill to Alexa and Alexa will send it back to you. Then you check what is filled in in these attributes, check what is filled in in the slot and add it to this data. Keep going this way until every slot in your attributes is filled. If everything is filled use this filled in attribute and run the code you want to run. still recommend using the dialog diretive (a lot easier ;)) to solve your problem of copy pasting just create a small script that does the work for you.

I hope thi helps you forward a bit good luck coding for Alexa :)

10 |5000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.