Predefined slots

You can use predefined slots to let Alan identify and retrieve some common types of data from the user’s input. Alan offers the following types of predefined slots:

Slot type

Short description

DATE

Matches a correct date in the user’s input, for example, today, March 3rd or two days ago

TIME

Matches time information in the user’s input, for example, 10:00 AM

NUMBER

Matches cardinal numbers in the user’s input, for example, 3 or 25

ORDINAL

Matches ordinal numbers in the user’s input, for example, first or 22nd

LOC

Matches a location in the user’s input, for example, a city, district or address

NAME

Matches a name, surname or both in the user’s input, for example, John Doe

DATE

The DATE slot matches the user’s input when it can be represented as a correct date. For example, the DATE slot can match user inputs like today, last friday, tomorrow, yesterday, March 3rd, 2 days ago and so on.

Voice script
intent('What is $(DATE)', p => {
    console.log(p.DATE.moment);
    p.play(`${p.DATE.value} is a date`);
    p.play(`It is ${p.DATE.moment.format("dddd, MMMM Do YYYY")}`);
});

Each DATE slot contains two special fields:

  • moment: date object from the moment.js library

  • luxon: the luxon date object

You can call all available methods for date formatting or any kind of calculations on dates. These two objects already use the date in the user timezone which is also always available in p.timeZone.

Voice script
intent('What is (my|) timezone', p => {
    p.play(`Your current timezone is ${p.timeZone}`);
});

TIME

The TIME slot matches time information in the user’s input. If the user inputs time, the corresponding TIME slot value will be interpreted as time, and the slot is filled with time data.

Voice script
intent('I will come at $(TIME)', p => {
    p.play(`Ok, we are waiting for you at ${p.TIME.value}`);
});

You can use the special .time field of the TIME object to get the number of seconds from midnight.

Voice script
intent('How many seconds passed till $(TIME)', p => {
    p.play(`${p.TIME.time} seconds passed from midnight till ${p.TIME.value}`);
});

NUMBER

The NUMBER slot matches any cardinal number, for example 5, three, 256, one million. The .value field will contain the user’s input and the .number field will contain a numerical representation of this input.

Voice script
intent('I want to order $(NUMBER) items', p => {
    console.log('User input:', p.NUMBER.value);
    console.log('Parsed number:', p.NUMBER.number);
    p.play(`You have ordered ${p.NUMBER.number} items`);
});

ORDINAL

You can use the ORDINAL slot to get ordinal numbers like fist, second, 21st, 3rd. Its .value field will contain the user’s input and .number field will contain a numerical representation of this input.

Voice script
const LIST = ["Anna", "Michael", "Lisa", "Alex"]

intent('Who is the $(ORDINAL) in the list?', p => {
    let member = LIST[p.ORDINAL.number - 1];
    p.play(`${member} is the ${p.ORDINAL.value} in the list`);
})

LOC

The LOC slot interprets the user’s input as a location. It can be a city, district, or full address string. For example, Washington, 36 West Bedford and so on.

Voice script
intent('Navigate me to $(LOC)', p => {
    p.play(`OK! Calculating a route to ${p.LOC.value}.`);
});

NAME

The NAME slot interprets the user’s input as a person. It can be a name, surname, or both. So Alan, Turing, and Alan Turing all can be matched using this slot.

Voice script
intent('Show contact details for $(NAME)', p => {
    p.play(`Getting contact details for ${p.NAME.value}`);
});

Note

When testing voice commands with $(NAME) and $(LOC) slots in patterns in the Debugging Chat, type the street and name values with the initial capitals. Do not use abbreviations like ave. or dr.

Custom names for predefined slots

To access data captured by predefined slots, you can use system names of these slots or specify custom names. For example, to get a location, you can use the LOC slot:

Voice script
intent('I need a ticket to $(LOC)', p => {
    p.play(`You have ordered a ticket to ${p.LOC.value}. Is it correct?`);
});

Alternatively, you can specify custom names for the predefined LOC slot and access the captured locations using these custom names:

Voice script
intent('I need a ticket to $(toDirection LOC) and a ticket back to $(backDirection LOC)', p => {
    p.play(`You have ordered a ticket to ${p.toDirection.value} and a ticket to ${p.backDirection.value}`);
    p.play('Is it correct?');
});

Multiple values in slots

If you need to capture multiple slot values at once, you can add a predefined slot to a pattern several times. For details, see User-defined slots.

You can access slot values by addressing a specific element in the array or define custom slot names. For details, see Custom names for predefined slots.

Predefined slot limitations

You cannot make predefined slots optional in patterns. Only user-defined slots can be made optional.