Variables setting




variable is an object that can store dynamic value (user input, data from a 3rd party source, etc.) and be changed depending on different conditions in a voice application. In Vuix you find Internal variables and Amazon variables.



To start with, let's create our project and go to the Variables tab.

Clicking on the "New variable" button in the top right corner will open up the following popup:

The first field is Type - we're talking about Amazon variables right now, so you need to select Amazon here.

Name - it needs to be unique, it's the keyword that you'll need to use your variable in the skill. For me, it will be firstNameOne - to store the first name of our first player. Note: It cannot contain digits or spaces, it needs to be one word.

I am doing the same process with the second variable called firstNameTwo to save the first name of the second player.


Done.


Internal 




This type of variables represents internal Vuix objects that can store data from external sources and use it in Alexa replies. For example, you can use an internal variable to store the response from an API call.


Amazon


Amazon variables (aka Slots) define how Alexa recognizes user input.

For example, you can use an Amazon variable with the data type "First Name" to extract first names from user replies.

It will ask names of two players, save them into variables, and then Alexa will use it to adress . Pretty simple, but it's an excellent example to explain how variables work.


Ok, I've created two variables, now I need to use them in our skill.

TIP: Click on the variable name to copy it.

My skill's Welcome Block asks users who are playing the game, expecting an answer like "Paul and Jessica" or "Ryan and Chris," basically two first names.

To handle that, I'll add a user reply with variables inside, like this:

{firstNameOne} and {firstNameTwo}

So, I've just replaced names of people from my examples with names of variables is single curly braces.

To make it easier for Alexa to understand this phrase, let's also add a couple of synonyms:

{firstNameOne} and {firstNameTwo} are playing
{firstNameOne} is playing with {firstNameTwo}
{firstNameTwo} is playing with {firstNameOne}
{firstNameOne} is playing and {firstNameTwo} is also playing
{firstNameOne} is fighting with {firstNameTwo}

So final user reply setup with synonyms should look like this:

Cool, now create a new block from this user reply, and there you can use these variables filled with user data.

So, you can ask your players if they're ready to start the game, by wrapping variable names in single curly braces.

That's it, that simple. You can use these variables later in the skill, wherever you want.

IMPORTANT: Be sure to add an else reply to this block to handle the case when something is not recognized, and the variable is not set, saying something like: "Sorry, I didn't get your names correctly, could you please repeat them?".



Didn't find an answer to your question?

Get in touch with us for details on additional services and custom work pricing

Open a Ticket