concept entity in category alexa

appears as: entities, An entity, entity, entities, n entity
Voice Applications for Alexa and Google Assistant

This is an excerpt from Manning's book Voice Applications for Alexa and Google Assistant.

Previously the slots consisted of a simple set of values. Now the slots also have IDs and synonyms. The best way to consider slot types now is to think of them as entities. An entity has an ID, a standard (or canonical) value, and a list of synonyms.

Listing 4.5 Responding based on the sleep quality ID (./lambda/custom/index.js)
handle(handlerInput) {
  const slots = handlerInput.requestEnvelope.request.intent.slots;
  ...
  // const quality = slots.SleepQuality && slots.SleepQuality.value;    #1  
  // const good = ["good", "well", "wonderfully", "a lot", "amazing",    #1  
  //               "fantastic", "great", "not bad"];    #1  
  // const bad = ["bad", "poorly", "little", "very little", "not at all"];    #1  

  if (Number.isInteger(adjustedHours)) {
    let speech = "";

    const resolutionValues = slots.SleepQuality &&    #2  
      slots.SleepQuality.resolutions &&    #2  
      slots.SleepQuality.resolutions.resolutionsPerAuthority[0] &&    #2  
      slots.SleepQuality.resolutions.resolutionsPerAuthority[0].values;    #2  

    if (resolutionValues) {
      const quality = resolutionValues[0].value.id;    #3  

      if (quality === "good") {
        adjustedHours += 1;
        speech = "You slept well last night, and ";
      }

      if (quality === "bad") {
        adjustedHours -= 1;
        speech = "You slept poorly last night, and ";
      }
    }
    ...
  }
  ...
}
...

#1   Grabs the value without entity resolution
#2   There could potentially be more than one value if you add the same synonym to multiple canonical values.
#3   Grabs the ID of the entity

The grouping of values that a user might provide is known as an entity. The exact value that a user then provides is known as a parameter. Each parameter will have an associated entity, and an entity can lend itself to multiple parameters. If we think back to our experience with Alexa, a parameter is equivalent to a slot and an entity is similar to a slot type. You can provide values to the entities within Dialogflow. All that’s needed is the name of the entity (such as “room”) and the values that go toward training it.