# Pre-built Slots

# What are pre-built slots?

# Pre-built slots v1

Template slots are pre-built slot extractors to help you quickly extract values that belong to that specific slot. It doesn't require training data upfront and is non-configurable. The Platform currently supports money and date.

Let's take a deeper look of the fields inside the DATE and MONEY list (you can find it in the query sidebar or full response payload):

"slot values": {
    "_DATE_": [
      {
        "type": "DATE",
        "startDate": "2020-02-07T00:00:00Z",
        "endDate": "2020-02-07T23:59:59Z",
        "period": "P1D",
        "altDates": [
          {
            "descriptor": "PAST_RESOLVE",
            "startDate": "2019-02-07T00:00:00Z",
            "endDate": "2019-02-07T23:59:59Z"
          },
          {
            "descriptor": "FUTURE_RESOLVE",
            "startDate": "2021-02-07T00:00:00Z",
            "endDate": "2021-02-07T23:59:59Z"
          }
        ],
        "anchor": null,
        "tokens": "today"
      }
    ],
    "_MONEY_": [
      {
        "tokens": "$ 200",
        "value": 200,
        "currency": "dollars",
        "visual": "$200.00",
        "speakable": "two hundred dollars"
      }
    ]
  },

# DATE

Key Value Description
type string: DATE, DURATION, TIME, or SET DATE: a calendar date or period. It can be last week, this year or a specific holiday.
DURATION: a span of time (or range) for example from March to May, since June, after September.
TIME: a time of day or offset for example 9am, 2 o’clock, morning evening etc. The Z in the startDate or endDate field is short for "zulu" time i.e. GMT/UTC time.
SET: a recurrence of dates or times for example every month, weekly etc.
startDate/ endDate string Identified start time and end time respectively. The format come out as standard python date format. It consists of year, month, day, hour, minute, second and time offset.
period string Amount of time between the startDate and endDate. "P1W" stands for period of 1 week; "P1M" stands for period of 1 month; "PT24H" stands for period of time of 24 hours.
altDates list altDates conditionally contains extra dates when a date can be cast into the past or future. This is especially useful for ambiguous dates. For example, "June" may return the month of June for the current year as well as last June, next June, or both depending on where we are at in the year [show past_resolve and future resolve in the payload].
anchor string anchor is used with recurrences (like yearly, each month, etc.) to give a point of reference for the recurrence. These anchor values conform to the TimeML standard.
tokens key string Tokens extracted from the query to build the date object

# MONEY

Key Value Description
tokens string Value extracted from the query
value integer The numerical value converted from the token extracted
currency string The currency type The platform currently supports USD and synonyms such as dollar, buck, and euros, pounds and Turkish lira.
visual string The human readable format meant for visual display
speakable string The extended format meant to be used in text to speech services

# Pre-built slots v2

Version 2 pre-built slots offers more capabilities number, position, phone, and email.

"slot values": {
  "_DATE_": [
    {
      "value": {
        "grain": "day",
        "from": "2021-02-06T00:00:00+00:00",
        "to": "2021-02-06T23:59:59+00:00",
        "normalized": {
          "unit": "second",
          "value": 86400
        },
        "visual": "on February 6th, 2021",
        "speakable": "on february sixth"
      },
      "alt_values": [
        {
          "grain": "day",
          "from": "2021-02-13T00:00:00+00:00",
          "to": "2021-02-13T23:59:59+00:00",
          "normalized": {
            "unit": "second",
            "value": 86400
          },
          "descriptor": "future",
          "visual": "on February 13th, 2021",
          "speakable": "on february thirteenth"
        },
        {
          "grain": "day",
          "from": "2021-01-30T00:00:00+00:00",
          "to": "2021-01-30T23:59:59+00:00",
          "normalized": {
            "unit": "second",
            "value": 86400
          },
          "descriptor": "past",
          "visual": "on January 30th, 2021",
          "speakable": "on january thirtieth"
        }
      ],
      "type": "time",
      "tokens": "on saturday",
      "version": "2"
    }
  ],
  "_MONEY_": {
    "type": "dict",
    "values": [
      {
        "currency": "dollars",
        "speakable": "thirty five dollars",
        "status": "MAPPED",
        "tokens": "$ 35",
        "value": 35,
        "visual": "$35.00"
      }
    ]
  },
  "_EMAIL_": [
    {
      "value": "john@example.com",
      "tokens": "john@example.com",
      "version": "2"
    }
  ],
  "_PHONE_": [
    {
      "value": "5555555555",
      "tokens": "(555)555-5555",
      "version": "2"
    }
  ],
  "_POSITION_": [
    {
      "offset": 0,
      "span": 3,
      "anchor": "start",
      "type": "position",
      "tokens": "first three",
      "version": "2"
    }
  ],
"_NUMBER_": [
    {
      "value": 22,
      "words": "twenty two",
      "digits": "two two",
      "type": "number",
      "tokens": "twenty two",
      "version": "2"
    }
  ]
}

# Date

Date is either a time, duration, or recurrence (depending on the type).

Key Value Description
from string the starting point of time
to string the ending point of time (inclusive)
grain string the granularity of the time (e.g. day, year)
value integer how many of the grain are in the recurrence
times integer how many times the recurrence happens given the grain and value
anchor object an anchor time which to base the recurrence off of
inner object a basis to build a recurrence which cannot be represented by an anchor from
inner.grain string the granularity of the recurrent time (e.g. day, year)
inner.day integer the day within inner.grain (e.g. 1 => first day)
inner.instance integer the instance of inner.grain within grain to repeat (e.g. 2 => 2nd instance)
total_seconds string amount of time in seconds between from/to
offset_seconds string amount of time in seconds since now
visual string the time for visual display (e.g. on December 2nd, 2019)
speakable string the time for speakable display (e.g. on december second)
alt_values list alternative values given ambiguous cases
type string time, duration or recurrence
tokens string extracted tokens
version string 2 (duckling version number)

Alternative values can be helpful depending on your use case. You can always choose a future value for a transfer or a past value for transaction searching. It works the same as the altDates from the pre-built slots v1.

Note: Fields to/from will be null whenever it is an open-ended range (e.g. "since monday" or "before saturday")

# Money

Key Value Description
value integer/ float the money value as a number
currency string the currency of the extraction
descriptor string (max
visual string the money amount for visual display (e.g. $20.00)
speakable string the money amount for speakable display (e.g. twenty dollars)
tokens string extracted tokens
version string 2 (duckling version number)

Duckling for the most part follows the ISO 4217 standard for currencies (using EUR, etc. as the currency code), but uses symbols/words for ambiguous currencies (e.g. dollar or pound). The extraction can also be max/min value in which case the slot value has an extra descriptor field which is either max or min.

# Phone

Key Value Description
value string the phone number value formatted properly
tokens string extracted tokens
version string 2 (duckling version number)

# Email

Key Value Description
value string the email value formatted properly
tokens string extracted tokens
version string 2 (duckling version number)

# Number

Number is a decimal or ordinal number with several helpers.

Key Value Description
value integer/ float the number value
words string the number written out as words (e.g. twenty third or fifty)
digits string the number written out as digits (e.g. 23rd or five zero)
type string number or ordinal
tokens string extracted tokens
version string 2 (duckling version number)

# Position

Position is a list selection helper that enables the user to refer to a list of items given their position (as opposed to their content).

Key Value Description
offset integer the starting position given the anchor
span integer how many indices to include given the offset
anchor string (start
type string ordinal or position
tokens string extracted tokens
version string 2 (duckling version number)

To help visualize how offset works, here are a few examples:

first
offset: 0
span: 1
anchor: start
0 1 2 3 4 5
^

last two:
offset: -2
span: 2
anchor: end
-5 -4 -3 -2 -1
          ^  ^

three in the middle:
offset: -1
span: 3
anchor: middle
-5 -4 -3 -2 -1 0 1 2 3 4 5
             ^ ^ ^

# How to add/remove pre-built slots?

In the competency sidebar,

  1. In the overflow menu more next to the competency name in the competency sidebar, select edit.

  2. In the modal popped up, select the pre-built slots you wish to add to your competency.

  3. Click Save.

add remove pre-built slots