Getting Started with the Cake Time Course: Using Auto-Delegation to Collect Slots Turn by Turn
Justin Jeffress Jun 10, 2019
Tips & Tools Tutorial Beginner

Editor’s Note: We recently launched a new training course called Cake Time: Build an Engaging Alexa Skill. The course is a self-paced, skill-building course that offers guidance on how to build a high-quality skill from start to finish. In this 4-part blog series, we’re going to dive deep into the coding modules within the course. You can read part 1 on designing the voice user interface for Cake Time here.

Editor’s Note: We have changed the name of the Alexa skill in our beginner tutorial from Cake Walk to Cake Time given the term’s racially insensitive history.


Unlike a Hollywood movie, real conversations are not scripted. There are many factors that can affect conversation such as the number of participants, time of day, mood, amount of caffeine consumed, and so on. When I’m tired, I find it much more difficult to communicate. Have you ever answered a question when you just woke up and in your mind your response made sense, but your friend says, “What? I can’t understand you.” Or they ask you a bunch of questions and you can only recall the last question so you can only provide one answer. In this case, your friend asks follow-up questions until they have the information that they need.

When your Alexa skill lacks all the information necessary to respond effectively to your customer, it needs to ask follow-up questions. Just like our friend. Let’s consider Cake Time. Cake Time is a sample skill that celebrates the customer’s birthday. When first opened, it doesn’t know the customer’s birthday, so it asks, “When were you born?” If the customer replies, “November 7, 1983.” The utterance contains the month, day and year slots, which means we have all the information that we need. However, if the customer left off the year, then the skill needs to follow up by asking what year they were born.

In part 2 of this blog series, I share how we can leverage auto-delegation in the Alexa Skills Kit to collect the necessary slots.

Understanding Situational Design

How do we determine if the skill should ask a follow-up question? We start with situational design, which is a voice-first method to design a voice user interface. Start with a simple dialog that helps keep the focus on the conversation. The situation represents circumstances of the skill. For example, when we first interact with Cake Time, the customer’s birthday is unknown. If they respond “November 7”, then month and day are known while year is unknown. In this case we need ask a follow-up question. The image below shows how our conversation will differ if our customer omits the year.

Alexa Blog

Implementation with Auto-Delegation

Now that we understand the design how do we implement it? The Alexa Skills Kit includes a handy feature called dialog management. You can use it to have Alexa track which slots need to be required. During each turn of the dialog, your skill will receive a JSON request. From your skill code, you can check the state of the conversation and return the Dialog.Delegate directive to have the Alexa service prompt the user for the next slot. You can also use the Dialog.ElicitSlot directive to overide which slot is prompted for next. The Cake Time skill does not require the Dialog.ElicitSlot directive. In this case, we can use auto-delegation, which does not require any modification to our code. Our skill will only receive one request once all of the slots have been created.

Let’s take a look at how take advantage of auto-delegation with Cake Time.

Define the Intents, Slots, and Utterances

We have three slots that we need to capture with Cake Time: month, day, and year. We have defined an intent called CaptureBirthdayIntent and we’ve defined the following utterances:

Copied to clipboard
"{month} {day}",
"{month} {day} {year}",
"{month} {year}",
"I was born on {month} {day} ",
"I was born on {month} {day} {year}",
"I was born on {month} {year}"

Now that we have defined our slots, we need to mark them required.

Make the Slot Required

To make our slots required we’ll need to scroll to the bottom of the CaptureBirthdayIntent edit screen and click on the name of the slot. This will take you to a new page that allows you to edit the slot. Set the “Is this slot required to fulfill the intent?” switch to on so it appears blue.

Alexa Blog

Upon doing so, two input boxes will appear. Alexa speech prompts is where you define what your skill will say to prompt the user to provide the slot. The user utterances allow you to define what the customer might say.

Define Prompts and User Utterances

Let’s consider the month slot.


To prompt the user to fill this missing slot, our skill will say:

Copied to clipboard
I was born in November. When what were you born?
What month were you born?

Notice how we defined two prompts? Alexa will randomly choose a prompt from the two. This will make our skill sound less robotic.

Alexa Blog

With our prompts defined, let’s take a look at the user utterances.

User Utterances

For the month slot, the user might say:

Copied to clipboard
I was born in {month}
I was born {month} {day}
I was born {month} {day} {year}
Alexa Blog

Note: You don’t need to provide the simple month-only slot, “{month}”, as a user utterance for the month slot. The Alexa service will do this for you if you choose to omit it.

You’ll need to repeat the process for the remaining year and day slots.

Ensure Auto-Delegation Is On

Since we created a new skill, the Auto Delegation interface was turned on at the skill level by default. After marking our slots required, and providing prompts and user utterances, the Dialog Delegation Strategy drop down should now say, “fallback to skill setting.”

Alexa Blog

At this point we’re ready to set up our back end.

Defining the CaptureBirthdayIntentHandler

Since our skill will only receive a response once all the slots have been collected, we only need one handler. We’ll call it CaptureBirthdayIntentHandler. Let’s take a look at when our canHandle will return true so that it can handle the request:

  1. The request type is IntentRequest
  2. The request name is CaptureBirthdayIntent

In code that looks like:

Copied to clipboard
canHandle(handlerInput) {
    return handlerInput.requestEnvelope.request.type === 'IntentRequest'
        && === 'CaptureBirthdayIntent';

Our code will access the slot values and use an implicit confirmation to indicate to the user that we heard their birthday correctly. Let’s take a look at the handle function in code:

Copied to clipboard
handle(handlerInput) {
    const year = handlerInput.requestEnvelope.request.intent.slots.year.value;
    const month = handlerInput.requestEnvelope.request.intent.slots.month.value;
    const day =;
    const speakOutput = `Thanks, I'll remember that you were born ${month} ${day} ${year}.`;
    return handlerInput.responseBuilder

First we access the year, month, and day slots and store their values to variables. Then we pass the variables to a javascript template literal to build our implicit confirmation string. Finally we use the responseBuilder to create the response that our skill returns to the Alexa Service. We still need to remember our customer’s birthday, but that’s a different topic we’ll cover later.


As you can see, auto-delegation is a great tool at your disposal that you can use to add conversational flexibility to your skill. Now that you’ve learned how to use auto-delegation, think about how you can use it in your own skills. If you’d like to continue the discussion or have questions, reach out to me on Twitter at @SleepyDeveloper.

Stay tuned for the next post in this series to learn how to persistent attributes to store information for later use. We’ll be storing our customer’s birthday so we don’t have to ask for it every time they open the skill.

Related Content