In this section, you will learn how to deal with entities and slot values provided by your users.
We call user input any additional information your user provides besides an
intent. On Amazon Alexa, input is usually called a
slot, on Google Assistant/Dialogflow an
With the update to Jovo v2, we changed the way you can access input values. Please read more below, or take a look at our migration document.
You can access the complete object of inputs with
this.$inputs, and a specific input by its name:
Each input is an object which looks like this:
For example, if we want to access the value of an input
name provided by the user, we can do so by using
Other parameters (like
id or platform specific elements) can be found in the object as well.
intentMap, there are cases where it might be valuable (due to naming conventions on different platforms or built-in input types) to map different input entities to one defined Jovo
inputName. You can add this to the configuration section of your voice app:
Example: You want to ask your users for their name and created a slot called
name on the Amazon Developer Platform. However, on Dialogflow, you decided to use the pre-defined entity
given-name. You can now use an inputMap to match incoming inputs from Alexa and Google.
With this, you can use
name to get the input with both Alexa and Google requests:
Since v2.3.0 we support input validation, which allows you to register multiple validators per input in your intent.
After defining your schema, where you define how you want to validate your inputs for the current intent, the core function of input validation
this.validate() will be called. This will return an object containing a function
failed(). You can use it to check, if the validation failed for a specific case.
You can validate your input in multiple ways, either as a specific Validator, your own function or a mixture from both in an array. The Validation Plugin already offers you multiple built-in Validators to choose from, each with its own functionality and set of parameter attributes.
Each Validator derives from a base abstract class
Validator, which contains an abstract function
validate() that gets overwritten by each deriving Validator. This means that besides using a function, you can easily write your own Validators and use them with the built-in Validators.
Regardless of whether you're using your own function or Validator, whenever you want to mark a path as failed you need to throw a ValidationError. This class expects at least a Validator identifier and an optional error message. Both of these can be used as a filter in the returned
failed() function. This can be useful if you want to throw multiple ValidationErrors per function.
You can even use async/await in your own function/Validator for asynchronous calls. For this, simply use
await this.validateAsync() instead of